-
Notifications
You must be signed in to change notification settings - Fork 357
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
Fix Nuage provider update #3337
Conversation
cc @miha-plesko |
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.
@sasoc please see the two comments I have, otherwise it looks great and I can confirm it works as expected. Thanks!
return 'none' if amqp_auth.nil? | ||
return 'amqp' | ||
end | ||
'ceilometer' |
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 like that 'ceilometer' is fallback when nothing else is true, can you please reorganize function to following shape:
return 'amqp' if ...
return 'ceilometer' if ...
return 'none'
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.
Also, please add unit test for this function, e.g. in a new file spec/controllers/mixins/ems_common_angular_spec.rb
.
551ed14
to
a9d90fb
Compare
return "amqp" if @ems.connection_configurations.ceilometer.try(:endpoint).nil? && @ems.connection_configurations.amqp.try(:endpoint) | ||
"ceilometer" | ||
amqp_auth = @ems.authentications.detect { |a| a.authtype == 'amqp' } | ||
return 'amqp' if @ems.connection_configurations.ceilometer.try(:endpoint).nil? && @ems.connection_configurations.amqp.try(:endpoint) && !amqp_auth.nil? |
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.
return 'amqp' if @ems.connection_configurations.amqp&.endpoint&.hostname&.present?
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 we need to check both auth and endpoint, it should suffice to have a valid hostname where to connect to, please see example above.
"ceilometer" | ||
amqp_auth = @ems.authentications.detect { |a| a.authtype == 'amqp' } | ||
return 'amqp' if @ems.connection_configurations.ceilometer.try(:endpoint).nil? && @ems.connection_configurations.amqp.try(:endpoint) && !amqp_auth.nil? | ||
return 'ceilometer' if @ems.connection_configurations.ceilometer.try(:endpoint) && @ems.connection_configurations.amqp.try(:endpoint).nil? |
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.
return 'ceilometer' if @ems.connection_configurations.ceilometer&.endpoint&.hostname&.present?
let(:ems_nuage) { FactoryGirl.create(:ems_nuage_network_with_authentication) } | ||
|
||
it 'when amqp' do | ||
ems_nuage.endpoints << Endpoint.create(:role => 'amqp') |
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.
Endpoint.create(:role => 'amqp', hostname => 'hostname')
expect(network_controller.send(:retrieve_event_stream_selection)).to eq('none') | ||
end | ||
end | ||
end |
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.
Can you please add also following tests:
- AMQP when ceilometer has empty hostname
- CEILOMETER when amqp has empty hostname
- NONE when amqp and ceilometer have nil endpoints
- NONE when amqp and cailometer have empty hostnames
a9d90fb
to
3b4ea7b
Compare
@miha-plesko I've committed changes. Can you take a look if I understood and implemented additional tests as you imagined. |
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.
@sasoc thanks, yes, I had such additional tests in mind. Please apply the one little comment that I have now, then its LGTM
expect(network_controller.send(:retrieve_event_stream_selection)).to eq('amqp') | ||
end | ||
|
||
it 'none when amqp and ceilometer have nil endpoints' 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.
This is the very same as we already have in L51, please remove it.
3b4ea7b
to
f17b43a
Compare
@AparnaKarve I kindly ask for a review/merge. The problem that we're addressing here is blocking integration tests for Nuage provider, because simple CRUD operations fail due to bug on the UI. Bug was there for a long time now, but no one noticed... @miq-bot assign @AparnaKarve /cc @juliancheal |
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.
LGTM
@miha-plesko Need a little clarification here. Incidentally, I can open the edit page for Amazon Network Provider (even without this PR) |
@AparnaKarve I think the "Edit NetworkProvider" option should be disabled for any other provider but Nuage. Probably we've accidentaly enabled it for all providers when we were integrating Nuage. We've also tested if editing works for Amazon NetworkManager but it didn't (it's broken on many places, as you've correctly noticed) therefore we were brave enough to assume May I suggest following procedure:
Wdyt? P.S.: Not sure how familiar are you with Nuage provider, so let me quickly put some context for you. Nuage Provider is "one of a kind" among providers because it no CloudManager, only NetworkManager. Other providers (like Amazon) only allow you to add a new CloudProvider and then Network-, Storage-, ... managers are added automatically (you are not even able to edit them). When you remove Amazon CloudProvider, also all its Managers are removed. Well, this is not the case with Nuage, where there is no CloudProvider, only a standalone NetworkManager -> and that's the source of our problem, because UI does not assume Manager editing. Luckily, the fixes seem to be quite simple 😄 Please let me know if this makes any sense. |
"ceilometer" | ||
return 'amqp' if @ems.connection_configurations.amqp&.endpoint&.hostname&.present? | ||
return 'ceilometer' if @ems.connection_configurations.ceilometer&.endpoint&.hostname&.present? | ||
'none' |
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.
Noticed that a hostname&.present?
condition has been added which did not exist before.
Should not matter for OpenStack Cloud/Infra Provider I think (where this method is used), but just wanted to know if it's absolutely needed for Nuage?
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.
Could you post a screenshot of the Nuage Edit Network Provider page?
Does it have AMQP/Ceilometer Radio buttons 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.
I think the above change may affect how we display the Radio buttons for OpenStack.
OpenStack selects the Ceilometer radiobutton by default if the AMQP endpoint does not exist.
But with the above change, there is an explicit check for the Ceilometer endpoint.
If both AMQP and Ceilometer endpoints do not exist, none of the radiobuttons would be selected -- which is not what we want.
Let's keep the OpenStack UI unaffected by this change.
@miha-plesko Thanks for the detailed explanation above - it did make sense :) I have a few inline comments. |
There were two problems when editing Nuage network provider. If network that you edited had no event, there would still be AMQP selected under the Events tab. That made Save button disabled since hostname must not be empty and everything has to be verified. Now None is selected in case of no event. The second problem was that when a network was updated error occurred while redirecting, since you would only get one argument and `ems_path` required two. Now `ems_path` works same as in the cloud provider controller. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1534457
f17b43a
to
c525ab7
Compare
@AparnaKarve I've changed Screenshot of Nuage network edit page, where you can see that there is oly AMQP radio button: |
Checked commit sasoc@c525ab7 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.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've tested this again (for Nuage provider) and it works like a charm, thanks @sasoc.
@AparnaKarve unfortuantely I don't have OpenStack testbed at hand to test if everything works also there, but looking at implementation I'm confident it should. I'm sorry to push you, but may I ask for another pass of review? We really need to be able to update Nuage provider from GUI in integration tests and we're catching 5.9.1 code-freeze date...
@sasoc @miha-plesko This looks good now. @dclarizio Can we merge this? |
@miha-plesko Regarding the follow-up PR as mentioned in #3337 (comment) -- is that something you would be able to address? |
Thanks for merging. @AparnaKarve yes, let me prepare followup PR for you. I think it should be a matter of a single IF statement, I'll take a look on Monday. |
Fix Nuage provider update (cherry picked from commit 02e1a70) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1552895
Gaprindashvili backport details:
|
There were two problems when editing Nuage network provider. If
network that you edited had no event, there would still be AMQP
selected under the Events tab. That made Save button disabled
since hostname must not be empty and everything has to be verified.
Now None is selected in case of no event.
The second problem was that when a network was updated error occurred
while redirecting, since you would only get one argument and
ems_path
required two. Nowems_path
works same asin the cloud provider controller.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1534457