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

Fix Nuage provider update #3337

Merged
merged 1 commit into from
Feb 9, 2018

Conversation

sasoc
Copy link
Contributor

@sasoc sasoc commented Jan 30, 2018

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

@sasoc
Copy link
Contributor Author

sasoc commented Jan 30, 2018

cc @miha-plesko

Copy link
Contributor

@miha-plesko miha-plesko left a 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'
Copy link
Contributor

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'

Copy link
Contributor

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.

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?
Copy link
Contributor

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?

Copy link
Contributor

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?
Copy link
Contributor

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')
Copy link
Contributor

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
Copy link
Contributor

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

@sasoc
Copy link
Contributor Author

sasoc commented Feb 1, 2018

@miha-plesko I've committed changes. Can you take a look if I understood and implemented additional tests as you imagined.

Copy link
Contributor

@miha-plesko miha-plesko left a 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
Copy link
Contributor

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.

@miha-plesko
Copy link
Contributor

@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
@miq-bot add_label enhancement

/cc @juliancheal

Copy link
Contributor

@miha-plesko miha-plesko left a comment

Choose a reason for hiding this comment

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

LGTM

@AparnaKarve
Copy link
Contributor

@miha-plesko Need a little clarification here.
Is this PR applicable to Nuage Network Providers only?
Or is it applicable to Nuage and Amazon? ( I believe in the BZ you have mentioned Amazon)

Incidentally, I can open the edit page for Amazon Network Provider (even without this PR)
But the form does not populate all the fields.

screen shot 2018-02-01 at 6 44 52 pm

@miha-plesko
Copy link
Contributor

@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 def ems_path(*args) in ems_network_controller.rb is obsolete because no one has used it for a while now - hence this PR.

May I suggest following procedure:

  • this PR: make Nuage NetworkManager editing work
  • followup PR: disable editing for all other NetworkManagers but Nuage

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'
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor

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.

@AparnaKarve
Copy link
Contributor

@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
@sasoc
Copy link
Contributor Author

sasoc commented Feb 6, 2018

@AparnaKarve hostname&.present? was added because there is a bug when you create new Nuage network. When created without endpoints there is still endpoint added to network, which has empty attributes. And before update retrieve_event_stream_selection would return 'amqp' and amqp radio button would be selected in edit page. And since all attributes are empty and
form fields are required, you would have to go to events tab and select none so you would be allowed to save changes(as seen in screenshot). Which creates some unnecessary work.

I've changed retrieve_event_stream_selection to return ceilometer by default for OpenStack. I've also added test for this usecase.

Screenshot of Nuage network edit page, where you can see that there is oly AMQP radio button:
screen shot 2018-02-06 at 10 39 31

@miq-bot
Copy link
Member

miq-bot commented Feb 6, 2018

Checked commit sasoc@c525ab7 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0
3 files checked, 0 offenses detected
Everything looks fine. 🍰

Copy link
Contributor

@miha-plesko miha-plesko left a 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...

@AparnaKarve
Copy link
Contributor

@sasoc @miha-plesko This looks good now.

@dclarizio Can we merge this?

@dclarizio dclarizio merged commit 02e1a70 into ManageIQ:master Feb 9, 2018
@dclarizio dclarizio added this to the Sprint 79 Ending Feb 12, 2018 milestone Feb 9, 2018
@AparnaKarve
Copy link
Contributor

@miha-plesko Regarding the follow-up PR as mentioned in #3337 (comment) -- is that something you would be able to address?
Let us know. Thanks.

@miha-plesko
Copy link
Contributor

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.

simaishi pushed a commit that referenced this pull request Mar 8, 2018
@simaishi
Copy link
Contributor

simaishi commented Mar 8, 2018

Gaprindashvili backport details:

$ git log -1
commit 7bc1af0116223f5ff9eb5aa239ac4b0ba77b9621
Author: Dan Clarizio <dclarizi@redhat.com>
Date:   Fri Feb 9 14:52:50 2018 -0800

    Merge pull request #3337 from sasoc/fix-nuage-provider-update
    
    Fix Nuage provider update
    (cherry picked from commit 02e1a7098b58cff9b7cc309b18e5fda7fe56e17e)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1552895

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