Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #15630: Add file content type API #6176

Merged
merged 1 commit into from Sep 6, 2016
Merged

Conversation

ehelms
Copy link
Member

@ehelms ehelms commented Jul 8, 2016

No description provided.

@theforeman-bot
Copy link

There were the following issues with the commit message:

  • length of the first commit message line for 06829af375b1beb6972e6937d2be1dfd9ce16ec0 exceeds 65 characters

If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@ehelms
Copy link
Member Author

ehelms commented Jul 8, 2016

Will require #5770


def update_from_json(json)
keys = %w(name checksum)
custom_json = json.clone.delete_if { |key, _value| !keys.include?(key) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems weird to be using clone and delete_if instead of just reject. Better yet, just use slice:

custom_json = json.slice('name', 'checksum')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this -- do you think this changed should be made everywhere? Given every repository type implements this function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just here is fine. Unless you feel the need to update it everywhere. Conversely, if you want to keep this the way it is to be consistent with other repository types, that's fine too. Your call.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bam

@ehelms
Copy link
Member Author

ehelms commented Aug 8, 2016

Rebased on top of the recently merged file PR

@ehelms
Copy link
Member Author

ehelms commented Aug 9, 2016

This still needs some tests added to it but if someone wants to review it for the basic design and data model that would be greatly appreciated.

@jlsherrill
Copy link
Member

getting this when syncing:

uninitialized constant Actions::Pulp::Repository::Presenters::FileUnitPresenter (NameError)
/home/vagrant/git/katello/app/lib/actions/pulp/repository/sync.rb:89:in `presenter'
/home/vagrant/git/katello/app/lib/actions/helpers/presenter.rb:9:in `humanized_output'
/home/vagrant/git/katello/app/lib/

@jlsherrill
Copy link
Member

jlsherrill commented Aug 9, 2016

Error when indexing content

ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR:  column "file_unit_id" does not exist
LINE 1: SELECT file_unit_id FROM "katello_repository_files" WHERE "k...
               ^
: SELECT file_unit_id FROM "katello_repository_files" WHERE "katello_repository_files"."repository_id" = 141
    from /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `async_exec'
    from /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `block in exec_no_cache'
    from /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'
    from /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activesupport-4.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `log'
    from /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `exec_no_cache'
    from /home/vagrant/.rvm/gems/ruby-2.2.4/gem

Looks like pulp_database_unit#sync_repository_associations is expecting the class name to match the attribute name on the join relation.

@ehelms
Copy link
Member Author

ehelms commented Aug 26, 2016

@jlsherrill updated

@daviddavis
Copy link
Contributor

What about this comment: #6176 (comment)

@ehelms
Copy link
Member Author

ehelms commented Aug 26, 2016

@daviddavis addressed

t.timestamps
t.string "uuid", :null => false, :limit => 255
t.string 'name', :limit => 255
t.string 'checksum', :limit => 255
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does name and checksum really need to be limited to 255?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following the other content types that were set to this based on (#5837). If you think I should open this up to unlimited then I shall.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlsherrill locally I have it looking like this:

{
id: 6,
name: "katello-ca-consumer-latest.noarch.rpm",
path: "pops/hey/WHAT",
uuid: "9d03acff-e674-4f49-8753-f900e7d22d12",
checksum: "24065bf79b81abd806fbe989edcfffcc1e3b4bb8a02726cbfbc957de3df166fd"
},

Do you think the full path would be better there? or just let users and interfaces construct it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might would just have the full path and not the partial path. That seems simpler and the user can do with it what they want.

name: "katello-ca-consumer-latest.noarch.rpm",
path: "pops/hey/WHAT/katello-ca-consumer-latest.noarch.rpm"

@ehelms
Copy link
Member Author

ehelms commented Sep 2, 2016

Updated:

  • renamed controller and view paths to 'file_units' to match with model name
  • add path to model and storing the full path or what Pulp considers the 'name'
  • name is now just the basename of the file
  • added path as a scoped search option and to the API response

@jlsherrill
Copy link
Member

https://github.com/Katello/katello/blob/master/app/controllers/katello/concerns/api/v2/repository_content_controller.rb#L187-L204 needs to be updated otherwise requests for nonexistant files throws an error:

GET http://robot:3000/katello/api/v2/files/zoom

"Can't find resource class: Katello::FileUnit"

This also adds importing of file type data into the database as
that is needed in ordered to display the API information.
@ehelms
Copy link
Member Author

ehelms commented Sep 2, 2016

@jlsherrill Good catch -- updated

@jlsherrill
Copy link
Member

APJ

@ehelms
Copy link
Member Author

ehelms commented Sep 2, 2016

[test]

@ehelms ehelms merged commit 8fac5be into Katello:master Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants