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 #7891 - Convert Pools/Subscriptions from Elastic Search to the … #5446

Merged
merged 1 commit into from
Sep 28, 2015

Conversation

johnpmitsch
Copy link
Contributor

…database

Opening this up for initial review. This covers adding subscriptions to the database and converting to scoped search on subscriptions/pools.

here is what is left to-do

  • Create Migration and Models
  • Update AR relationships
  • Importing data from candlepin
  • Add importing data to re-index
  • Update API
  • Import/delete data on importing/deleting a manifest, candlepin events, and adding and removing from activation keys.
  • Implement scoped search in the UI
  • Refactor broken tests
  • Write tests for new functionality
  • Clean up

Issues that need to be resolved

  • Adding and removing subscriptions from content hosts functioning but with errors.
  • Autocomplete not showing in UI for activation keys and content hosts
  • Subscription type attribute isn't loading in the UI
  • Subscription table in add and list/remove to activation key isn't showing any message when blank

@johnpmitsch
Copy link
Contributor Author

[test]

@@ -15,6 +14,7 @@
</div>
</div>


Copy link
Member

Choose a reason for hiding this comment

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

Unneeded

@cfouant
Copy link
Member

cfouant commented Sep 4, 2015

Much of the UI seems messed up (specifically the subscriptions tab under content hosts). I would fix the technical errors (indentation mostly, a couple missing semicolons - spelled out in the grunt tests); either you or I can then fix the broken javascript tests from there.

@johnpmitsch
Copy link
Contributor Author

@cfouant hey, ya, so new development, both activation keys and content host had to be converted to use nutupane with subscriptions for scoped search to work on those pages, so I am in the middle of that. Also, I am rebasing now, sorry I didn't see that until now. I'll check in with you when you are online this morning and we can discuss further.

end

def self.pulp_backend_search_classes
[Katello::PuppetModule]
end
Copy link
Member

Choose a reason for hiding this comment

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

I think you actually want to remove these two methods now that you PuppetModules have been converted.

Copy link
Member

Choose a reason for hiding this comment

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

Scratch that. Just return an empty array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cfouant I don't see a need for either method so I removed it completely and wherever it is called in rake tasks

@cfouant
Copy link
Member

cfouant commented Sep 9, 2015

I am getting a 500 ISE when I try under Red Hat Subscriptions box to search by name:
2015-09-09T17:50:16 [app] [I] Completed 500 Internal Server Error in 224.2ms (Views: 0.3ms | ActiveRecord: 1.8ms)
2015-09-09T17:50:16 [app] [D] With body: {"displayMessage":"Field 'name' not recognized for searching!","errors":["Field 'name' not recognized for searching!"]}

I've replicated this with other given search fields (eg cores)

@johnpmitsch
Copy link
Contributor Author

@cfouant Thanks for catching that, kind of the whole point of this PR :) Just pushed up the fix, it had to do with Subscriptions controller really returning Pools, which confused scoped search. I was able to add a resource_class method to subscriptions controller and now both Subscription and Pool fields are searchable!

@johnpmitsch johnpmitsch force-pushed the subscriptions branch 3 times, most recently from cade5f0 to 87c8429 Compare September 10, 2015 16:02
end

def test_search_by_account
assert_equal Pool.search_for("account = #{@pool_one.account_number}").first, @pool_one
Copy link
Member

Choose a reason for hiding this comment

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

I would rather see this broken down like:

pools = Pool.search_for("account = #{@pool_one.account_number}")
assert_equal pools, @pool.one

@johnpmitsch johnpmitsch changed the title [DO NOT MERGE] Fixes #7891 - Convert Pools/Subscriptions from Elastic Search to the … Fixes #7891 - Convert Pools/Subscriptions from Elastic Search to the … Sep 10, 2015
@johnpmitsch
Copy link
Contributor Author

@jlsherrill updated

@ehelms
Copy link
Member

ehelms commented Sep 22, 2015

I am hitting this while running the upgrade rake task:

ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'Katello::MarketingProduct'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Katello::Product.inheritance_column to use another column for that information.
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/inheritance.rb:143:in `rescue in find_sti_class'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/inheritance.rb:136:in `find_sti_class'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/inheritance.rb:62:in `instantiate'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/querying.rb:38:in `block (2 levels) in find_by_sql'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/querying.rb:38:in `collect!'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/querying.rb:38:in `block in find_by_sql'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/explain.rb:41:in `logging_query_plan'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/querying.rb:37:in `find_by_sql'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/relation.rb:171:in `exec_queries'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/relation.rb:160:in `block in to_a'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/explain.rb:34:in `logging_query_plan'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/relation.rb:159:in `to_a'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/bullet-4.14.7/lib/bullet/active_record3x.rb:10:in `to_a'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/relation/finder_methods.rb:381:in `find_first'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/relation/finder_methods.rb:122:in `first'
/home/vagrant/katello/app/models/katello/glue/candlepin/subscription.rb:52:in `block in create_product_associations'
/home/vagrant/katello/app/models/katello/glue/candlepin/subscription.rb:49:in `each'
/home/vagrant/katello/app/models/katello/glue/candlepin/subscription.rb:49:in `create_product_associations'
/home/vagrant/katello/app/models/katello/glue/candlepin/subscription.rb:42:in `import_data'
/home/vagrant/katello/app/models/katello/glue/candlepin/candlepin_object.rb:44:in `block in import_all'
/home/vagrant/katello/app/models/katello/glue/candlepin/candlepin_object.rb:42:in `each'
/home/vagrant/katello/app/models/katello/glue/candlepin/candlepin_object.rb:42:in `import_all'
/home/vagrant/katello/lib/katello/tasks/upgrades/2.4/import_subscriptions.rake:8:in `block (4 levels) in <top (required)>'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/bin/ruby_executable_hooks:15:in `eval'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/bin/ruby_executable_hooks

@johnpmitsch
Copy link
Contributor Author

@ehelms I'm having trouble reproducing, but following the traceback leads me to believe the "type" column should be dropped in Katello::Product table as we no longer have a need for single table inheritance?

@jlsherrill
Copy link
Member

@ehelms i get the same error, was just about ot paste that.

The issue is that you likely need to import a manifest prior to the upgrade to hit the error

@jlsherrill
Copy link
Member

The fix would be to just delete Products where type => ::Katello::MarketingProduct i believe

@johnpmitsch
Copy link
Contributor Author

@jlsherrill do that when importing subscriptions?

@jlsherrill
Copy link
Member

@johnpmitsch at the very start of the upgrade script I'd say.

@johnpmitsch
Copy link
Contributor Author

@jlsherrill so if there are existing Products with "MarketingProduct" in the type column, those should be deleted before the updgrade task, because that model no long exists, am I on the right track here?

@jlsherrill
Copy link
Member

I would say at the start of the upgrade task, not before it, in the migration. @ehelms may have an opinion about this.

@johnpmitsch
Copy link
Contributor Author

@jlsherrill @ehelms updated the rake task to destroy all where type is MarketingProduct

@ehelms
Copy link
Member

ehelms commented Sep 23, 2015

I still get an error below with this update. The issue now is that it's trying to access a class that no longer exists which means you probably have to try re-defining Katello::MarketingProduct in the rake task or do this in the migration (while also defining that class in the migration like we do in other places).

ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'Katello::MarketingProduct'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Katello::Product.inheritance_column to use another column for that information.
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/inheritance.rb:143:in `rescue in find_sti_class'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/inheritance.rb:136:in `find_sti_class'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/inheritance.rb:62:in `instantiate'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/querying.rb:38:in `block (2 levels) in find_by_sql'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/querying.rb:38:in `collect!'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/querying.rb:38:in `block in find_by_sql'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/explain.rb:41:in `logging_query_plan'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/querying.rb:37:in `find_by_sql'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/relation.rb:171:in `exec_queries'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/relation.rb:160:in `block in to_a'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/explain.rb:34:in `logging_query_plan'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/relation.rb:159:in `to_a'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/bullet-4.14.7/lib/bullet/active_record3x.rb:10:in `to_a'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/relation.rb:355:in `destroy_all'
/home/vagrant/katello/lib/katello/tasks/upgrades/2.4/import_subscriptions.rake:7:in `block (4 levels) in <top (required)>'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/bin/ruby_executable_hooks:15:in `eval'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => katello:upgrades:2.4:import_subscriptions

@johnpmitsch
Copy link
Contributor Author

@ehelms is there a good example I can use where we do that in other places?

@jlsherrill
Copy link
Member

You may just do a delete_all instead of a destroy all. That shouldn't require the class being loaded i don't think.

@ehelms
Copy link
Member

ehelms commented Sep 23, 2015

I also did a grep of 'Marketing' in the app/ directory and found some instances of it.

@jlsherrill Should we drop the inheritance that is still present on the Product model

@jlsherrill
Copy link
Member

@ehelms by drop the inheritance, i assume you mean the 'type' field? I'd say yeah, that'd be smart to do.

@jlsherrill
Copy link
Member

and if we do that, the marking product deletion would need to go in the migration that dropped that field.

@ehelms
Copy link
Member

ehelms commented Sep 23, 2015

Yes, that is what I meant (to drop the type column all together).

@johnpmitsch johnpmitsch force-pushed the subscriptions branch 2 times, most recently from 52a55f4 to cd5a22f Compare September 23, 2015 19:29
@johnpmitsch
Copy link
Contributor Author

@ehelms @jlsherrill updated to remove "type" column and include the class in the migration file. I tested by checking out master branch, reseting, import a manifest, switch to subscriptions branch, migrate, run upgrade script and all seemed to run no problem.

t.integer "engineering_product_id"
end

add_column :katello_products, :type
Copy link
Member

Choose a reason for hiding this comment

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

This throws an error on rollback:

StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (2 for 3)/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/connection_adapters/postgresql_adapter.rb:1017:in `add_column'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/migration.rb:466:in `block in method_missing'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/migration.rb:438:in `block in say_with_time'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/migration.rb:438:in `say_with_time'
/home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/migration.rb:458:in `method_missing'
/home/vagrant/katello/db/migrate/20150908222711_drop_marketing_engineering_products.rb:18:in `down'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ehelms updated add_column to include the missing argument

@ehelms
Copy link
Member

ehelms commented Sep 24, 2015

Tested and ACK for me, final say is on @jlsherrill

drop_table :katello_marketing_engineering_products

remove_column :katello_products, :type
end
Copy link
Member

Choose a reason for hiding this comment

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

I may have missed it, but i don't see you removing the old marketing products prior to dropping the 'type' column?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jlsherrill updated

@jlsherrill
Copy link
Member

ACK thanks @johnpmitsch !

crossing fingers that we didn't miss any issues :)

jlsherrill added a commit that referenced this pull request Sep 28, 2015
Fixes #7891 - Convert Pools/Subscriptions from Elastic Search to the …
@jlsherrill jlsherrill merged commit 0680624 into Katello:master Sep 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants