-
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
Synchronize provider with server when zone changes #18272
Synchronize provider with server when zone changes #18272
Conversation
579a921
to
f4725de
Compare
@@ -99,7 +99,13 @@ | |||
runner.instance_variable_set(:@job_data_retention, ::Settings.embedded_ansible.job_data_retention_days) | |||
end | |||
|
|||
after do |
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 do we need this block? Doesn't the runner
get re-evaluated for each example? It's defined in a let
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.
Ah, good point... I could have sworn they were class methods but clearly not... I'll verify but yeah, I think the runner should be new for each example.
@@ -133,12 +139,48 @@ | |||
|
|||
it "sets the embedded ansible job data retention value when the setting changes" do | |||
allow(embedded_ansible_instance).to receive(:alive?).and_return(true) | |||
allow(runner).to receive(:provider).and_return(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.
Why can this be removed here, but not in the other examples above it?
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.
It was part of my change to add the after
....I can remove this change if I remove the after
.
We only needed this line in the other examples because we set an expectation on the provider
object in those examples... therefore, we needed to make sure the runner.provider
returns this object and not the completely different ruby object returned from first_or_initialize
from the "normal" provider
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.
Yeah, I think I'd prefer to remove the after
block and add this back.
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.
Sounds good
provider.save! | ||
end | ||
|
||
def provider_matches_server? |
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 we could probably name this better as it's handling both the time aspect as well as the matching.
Unfortunately the best I could come up with was synchronize_provider_with_server?
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.
It was first matches_stuff?
, I renamed it and gave up because it won't matter until a few eyes come up with a better name.
I'm glad you win the 🏆 of "find the part Joe bailed on trying to name correctly."
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 like synchronize_provider_with_server
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, that's funny... looking at it now, I like provider_out_of_sync_with_server?
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.
lol, double negative... provider_in_sync_with_server?
@@ -109,7 +115,7 @@ | |||
end | |||
|
|||
context "with a provider" do | |||
let(:provider) { FactoryGirl.create(:provider_embedded_ansible, :with_authentication) } | |||
let!(:provider) { FactoryGirl.create(:provider_embedded_ansible, :with_authentication) } |
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 was added because all examples were already calling provider
and my new example wasn't, but still needed it created.
As for updating just the zone (fixing only the bug) vs updating the zone and URL, I prefer fixing both. The simplicity of this change which refactors existing, tested, code into a new method which is called additional times feels more stable than implementing something new, or changing the existing code block to update only the zone while leaving the URL alone. |
f4725de
to
4685f22
Compare
4685f22
to
52497e4
Compare
Checked commits jrafanie/manageiq@62049ee~...52497e4 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@@ -22,6 +23,7 @@ def heartbeat | |||
end | |||
|
|||
def do_work | |||
synchronize_provider_with_server unless provider_in_sync_with_server? |
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 new method name looks better... @carbonin what do you think?
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 the same problem is still there.
The name only mentions that we're checking the properties, not that we are also returning true based on some timeframe. It doesn't really matter though. I'm not going to hold this up for a better name though.
…ver_when_zone_changes Synchronize provider with server when zone changes (cherry picked from commit a2592e8) https://bugzilla.redhat.com/show_bug.cgi?id=1656308
Hammer backport details:
|
If an appliance's zone (or hostname/ipaddress) changes, we don't update the related "hidden" provider's zone (and URL), requiring users to restart the embedded ansible role or reboot the whole appliance. This PR checks for these changes and updates the provider.
I added a commit to check for URL changes, in case they renamed the appliance (hostname) or the ip address. I can do this as a followup if need be, but it's a tiny change so I included it.
https://bugzilla.redhat.com/show_bug.cgi?id=1656308