-
Notifications
You must be signed in to change notification settings - Fork 897
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
Provider to orchestrate_destroy managers first - Alt #16755
Conversation
834b521
to
3649541
Compare
3649541
to
2d3cbcf
Compare
@miq-bot add_labels providers, bug, blocker |
@miq-bot add_lables gaprindashvili/yes |
@jameswnl unrecognized command 'add_lables', ignoring... Accepted commands are: add_label, assign, close_issue, move_issue, remove_label, rm_label, set_milestone |
@miq-bot add_labels gaprindashvili/yes |
179126c
to
eaee53a
Compare
@Fryguy @blomquisg @bdunne please review. thanks |
@@ -36,7 +36,6 @@ def self.should_define_delete_queue_class_method | |||
def self.should_queue_destroy_on_instance(queue_method = "destroy") | |||
it "should queue up destroy on instance" do | |||
cond = ["class_name = ? AND instance_id = ? AND method_name = ?", @obj.class.name, @obj.id, queue_method] | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unintended
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind removing it from the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i did!, but it keeps coming back 👿
@@ -439,22 +440,17 @@ | |||
|
|||
deliver_queue_message | |||
|
|||
expect(MiqQueue.count).to eq(1) | |||
expect(MiqQueue.last.deliver_on).to_not be_nil | |||
expect(MiqQueue.count).to eq(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to update the description of this test since the functionality has changed.
|
||
deliver_queue_message | ||
|
||
expect(MiqQueue.count).to eq(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this test can be merged with the one above since they are effectively testing the same thing now.
@@ -466,8 +462,8 @@ | |||
it "queues up destroy for child_managers" do | |||
described_class.destroy_queue(ems.id) | |||
|
|||
expect(MiqQueue.count).to eq(2) | |||
expect(MiqQueue.pluck(:instance_id)).to include(ems.id, child_manager.id) | |||
expect(MiqQueue.count).to eq(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, the description needs to be updated since the child manager destroy is no longer queued.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I've done some re-arrangement of the specs
spec/models/provider_spec.rb
Outdated
provider.destroy(task.id) | ||
task.reload | ||
expect(task).to have_attributes( | ||
'state' => MiqTask::STATE_FINISHED, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why string keys here and symbols above?
spec/models/provider_spec.rb
Outdated
@@ -1,5 +1,5 @@ | |||
describe Provider do | |||
let(:provider) { described_class.new } | |||
let(:provider) { FactoryGirl.create(:provider) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should have changed for the rest of the tests when only the two new ones require a record be persisted to the database. The remaining tests will be slowed down unnecessarily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got them separately handled
@@ -6,7 +6,7 @@ class ManageIQ::Providers::EmbeddedAnsible::Provider < ::Provider | |||
has_one :automation_manager, | |||
:foreign_key => "provider_id", | |||
:class_name => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager", | |||
:dependent => :destroy, | |||
:dependent => :destroy, # to be removed after ansible_tower side code is updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's now being explicitly called in provider.destroy
d0a8511
to
ca808e9
Compare
ids.each do |id| | ||
MiqQueue.put( | ||
def self._queue_task(task, ids, task_id = nil) | ||
Array.wrap(ids).each do |id| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is ids
no longer an array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to make the other calls lazy like here line 81 and here line 459
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... I'm not a fan. But if you're going to do that, can you update the variable name accordingly? Maybe id_or_ids
if we have to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am neutral to this. so i changed that to your favor.
@@ -6,7 +6,7 @@ class ManageIQ::Providers::EmbeddedAnsible::Provider < ::Provider | |||
has_one :automation_manager, | |||
:foreign_key => "provider_id", | |||
:class_name => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager", | |||
:dependent => :destroy, | |||
:dependent => :destroy, # to be removed after ansible_tower side code is updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't this line be removed now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removal of this will break the spec. We'll need ManageIQ/manageiq-providers-ansible_tower#54 (which is in circular dependency with this one).
If we know we'll merge both at the same(near) time, I can do this now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you meant to link ManageIQ/manageiq-providers-ansible_tower#49 but since that has its own has_one :automation_manager
and it's a different subclass of Provider
, I don't see how they're related.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, specifically needed is this fix of the factory object https://github.com/ManageIQ/manageiq-providers-ansible_tower/pull/49/files#diff-58d459079c55b950f3e93005074af740R25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very lost now..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offline explained this to Brandon that this has to do with an existing bug in the shared Tower spec (linked in my last comment)
app/models/provider.rb
Outdated
|
||
_log.info(msg) | ||
task = MiqTask.create( | ||
:name => "Destroying #{self.class.name} with id: #{id}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not reuse msg
since it's the same string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
end | ||
|
||
def destroy_queue | ||
msg = "Destroying #{self.class.name} with id: #{id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please spell it out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean hard code the class name of current provider? It would then always be the base class, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, "message"
@@ -36,7 +36,6 @@ def self.should_define_delete_queue_class_method | |||
def self.should_queue_destroy_on_instance(queue_method = "destroy") | |||
it "should queue up destroy on instance" do | |||
cond = ["class_name = ? AND instance_id = ? AND method_name = ?", @obj.class.name, @obj.id, queue_method] | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind removing it from the PR?
|
||
expect(MiqQueue.count).to eq(1) | ||
expect(MiqQueue.count).to eq(2) | ||
expect(MiqQueue.pluck(:instance_id)).to include(ems.id, ems2.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be match_array
? I wouldn't expect any other instance_id
s to be on the queue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right!
context "#destroy_queue" do | ||
let(:server) { EvmSpecHelper.local_miq_server } | ||
let(:zone) { server.zone } | ||
let(:ems) { FactoryGirl.create(:ext_management_system, :zone => zone) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort alphabetically please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
deliver_queue_message | ||
task = MiqTask.find(task_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be consolidated to a single expectation:
expect(MiqTask.find(task_id)).to have_attributes(
:state => "Finished",
:status => "Ok",
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
deliver_queue_message | ||
|
||
expect(MiqQueue.count).to eq(0) | ||
expect(ExtManagementSystem.count).to eq(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you also need an expectation that the worker is gone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
expect(task).to have_attributes( | ||
:state => MiqTask::STATE_FINISHED, | ||
:status => MiqTask::STATUS_OK | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expect that the manager is gone too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
ca808e9
to
fe13fef
Compare
fe13fef
to
182b7ba
Compare
Checked commit jameswnl@182b7ba with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 |
Provider to orchestrate_destroy managers first - Alt (cherry picked from commit ef04837) https://bugzilla.redhat.com/show_bug.cgi?id=1536039 https://bugzilla.redhat.com/show_bug.cgi?id=1536041
Gaprindashvili backport details:
|
Change introduced in ManageIQ/manageiq#16755 is not compatible with OSP provider which uses cascade deletion of related providers. Nullification introduced in ManageIQ#198 breaks tests and possibly affects Infra provider deletion. Trying override destroy method with original from AR until we get better solution (preferably in main repo).
https://bugzilla.redhat.com/show_bug.cgi?id=1491704
https://bugzilla.redhat.com/show_bug.cgi?id=1510179
Destroying Ansible Tower Provider and Foreman Provider is being rolled back because the associated manager is being held up by workers (introduced by #14675)
Following this gist
Other required PRs:
A related nice-to-have PR: #16798(Taking this out)