-
Notifications
You must be signed in to change notification settings - Fork 287
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 #34110 - Delay host global status update #9842
Conversation
Issues: #34110 |
So I've spent all day this week reproducing this. First, it worked without Katello for me. Then I installed 6.10 and shellhooks would not work for me, it is giving me 404 and I cannot figure out why (if you have an idea). And in the evening, I was at least confirm in production.log this bug, yeah. Omg just a bang! Great work. |
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.
For what it is worth, this also fixes the issue with ansible roles not being applied post provisioning.
However, if I'm reading it right the non-bang variant just calculates a new value for one of the host's attributes, but since it gets set after the host is saved it is a bit pointless
@adamruzicka, what you makes think that global status gets set after the host is saved? This change is actually about not saving (changes to) a host before we actually save it in https://github.com/theforeman/foreman/blob/583ae2b619d813c71f176730a1da4790ecf0c3f1/app/models/host/managed.rb#L398. I've checked via console that if I do an additional change here ( katello/app/models/katello/concerns/host_managed_extensions.rb Lines 108 to 113 in 83a6327
@host.saved_changes after built method finished.
The only similar concern I have is that if this |
Must have been something in my previous environment that was interfering. Checked again with a fresh machine and it works flawlessly. Please disregard the second part my previous comment. |
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.
Let's get this in
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.
ACK based on @lzap and @adamruzicka's testing. Thanks @ofedoren!
(cherry picked from commit 353ebfc)
(cherry picked from commit 353ebfc)
(cherry picked from commit 353ebfc)
(cherry picked from commit 353ebfc)
(cherry picked from commit 353ebfc)
(cherry picked from commit 353ebfc)
(cherry picked from commit 353ebfc)
(cherry picked from commit 353ebfc)
(cherry picked from commit 353ebfc)
Fixes #34110 - Delay host global status update (Katello#9842) (cherry picked from commit 353ebfc)
What are the changes introduced in this pull request?
The issue tells more about what the problem is. I suggest to delay the global status actual save since this is done here [1] afterwards.
Considerations taken when implementing this change?
I've spent a lot of time to dig to this line :/ My steps are following:
saved_changes_to_build?
isfalse
, moreover@host.saved_changes
are totally empty even if it should contain changes.@host.built(false)
, which is actually being called here [3].built
method sets thebuild
flag tofalse
and saves/updates the host.save
inbuilt
is surrounded by [4], thus more tasks are being processed beforesave
inbuilt
.saved_changes
empty is this one [5]refresh_global_status!
, which actually doessave
on@host
and thus we save changes to a host while trying to save changes to a host :/What are the testing steps for this pull request?
Have
foreman_webhooks
plugin installed, configured to listen tobuild_exited
event, ensure it gets triggered. OR simply check the logs ifbuild_exited.event.foreman
gets triggered.[1] - https://github.com/theforeman/foreman/blob/583ae2b619d813c71f176730a1da4790ecf0c3f1/app/models/host/managed.rb#L398
[2] - https://github.com/theforeman/foreman/blob/583ae2b619d813c71f176730a1da4790ecf0c3f1/app/models/host/managed.rb#L54
[3] - https://github.com/theforeman/foreman/blob/583ae2b619d813c71f176730a1da4790ecf0c3f1/app/controllers/hosts_controller.rb#L242-L243
[4] - https://github.com/theforeman/foreman/blob/583ae2b619d813c71f176730a1da4790ecf0c3f1/app/models/concerns/orchestration.rb#L12
[5] -
katello/app/models/katello/concerns/host_managed_extensions.rb
Line 61 in 635132d
[6] -
katello/app/models/katello/concerns/host_managed_extensions.rb
Line 108 in 635132d
[7] - https://github.com/theforeman/foreman/blob/583ae2b619d813c71f176730a1da4790ecf0c3f1/app/models/host/managed.rb#L779