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

Remove Invalid Hawkular Endpoints #14990

Merged
merged 1 commit into from
Jun 13, 2017
Merged

Conversation

moolitayer
Copy link

@moolitayer moolitayer commented May 4, 2017

Depends on: ManageIQ/manageiq-ui-classic#1205

Before this migration a disabled hawkular is expressed by an endpoint with a nil hostname.
After, a provider with a disabled hawkular will only have the default endpoint.

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1437138

@moolitayer
Copy link
Author

cc @cben @zeari @simon3z

Endpoint.where(
:resource_type => "ExtManagementSystem",
:role => 'hawkular',
:hostname => nil
Copy link
Contributor

Choose a reason for hiding this comment

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

can it also be blank string?

Copy link
Author

Choose a reason for hiding this comment

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

nil in the bug description[1] but it's a good idea to test both options

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1437138#c19

ExtManagementSystem.where(
:type => %w(ManageIQ::Providers::Openshift::ContainerManager ManageIQ::Providers::Kubernetes::ContainerManager)
).each do |ems|
Endpoint.create!(
Copy link
Contributor

Choose a reason for hiding this comment

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

what about providers that have both endpoints?
wouldn't this create a 3rd one going back?

Copy link
Author

Choose a reason for hiding this comment

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

Right, updated

Copy link
Contributor

@cben cben left a comment

Choose a reason for hiding this comment

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

what about the Authentication associated with hawkular?
I believe we should delete it too, to preserve 1:1 correspondence we had till now.

@moolitayer
Copy link
Author

@miq-bot add_label fine/yes

@cben
Copy link
Contributor

cben commented May 9, 2017

isn't fine schema frozen?

@moolitayer moolitayer force-pushed the migrate_endpoint branch 3 times, most recently from 1169423 to 2f44340 Compare May 9, 2017 11:14
@moolitayer
Copy link
Author

isn't fine schema frozen?

I hope this will be considered for the next zstream, especially since It is an update and not a schema change(ddl). If it is rejected we will have a separate change for fine (probably in manageiq-ui-classic) and this one for master

@moolitayer moolitayer force-pushed the migrate_endpoint branch 2 times, most recently from 52c81d1 to 09791d2 Compare May 9, 2017 11:29
@simon3z
Copy link
Contributor

simon3z commented May 9, 2017

@moolitayer @cben currently my vote is to have no migrations (of any kind) in z-stream.

I'll leave to @Fryguy to approve a special exception if he thinks otherwise.

@moolitayer
Copy link
Author

Lets leave the label for later
@cben @simon3z please review

@miq-bot remove_label fine/yes

@miq-bot miq-bot removed the fine/yes label May 10, 2017
def up
Endpoint.where(
:resource_type => "ExtManagementSystem",
:role => 'hawkular',
Copy link
Contributor

Choose a reason for hiding this comment

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

are we sure say middleware providers don't use this role?
perhaps constrain EMS types like you did in down.

Copy link
Author

Choose a reason for hiding this comment

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

@cben
Copy link
Contributor

cben commented May 11, 2017

Code looks plausible, but see comment above about Authentication.

Have you tested by actually creating providers on old releases and migrating forward? I've done that before, can help.
Can this benefit from a spec? I'm not sure what exactly to test.

@moolitayer moolitayer force-pushed the migrate_endpoint branch 2 times, most recently from 4783a56 to faa2ee4 Compare May 11, 2017 13:48
@moolitayer
Copy link
Author

Have you tested by actually creating providers on old releases and migrating forward? I've done that before, can help.

Yes I have, added a spec

@moolitayer
Copy link
Author

@Fryguy please review this change

@moolitayer
Copy link
Author

@cben @yaacov please review

Copy link
Contributor

@cben cben left a comment

Choose a reason for hiding this comment

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

👍 ♻️
I'm really glad that you're digging us out of the "unofficially optional hawkular" mess...

:resource_id => ems.id
)
migrate
expect(endpoint_stub.count).to eq(1)
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 really expect it to remove the wrong one, but still maybe test which one got removed...
E.g. expect(endpoint_stub.pluck(:role)).to contain_exactly("default")

@simon3z
Copy link
Contributor

simon3z commented May 17, 2017

LGTM 👍
cc @Fryguy

@moolitayer
Copy link
Author

@Fryguy please reivew

@moolitayer
Copy link
Author

@Fryguy please review

@moolitayer
Copy link
Author

Added deletion of the Hawkular authentication. That required some changes since polymorphic associations do not work well with migration stubs.

@cben @Fryguy please review

@moolitayer moolitayer force-pushed the migrate_endpoint branch 3 times, most recently from a2d968d to 6bcc22b Compare May 28, 2017 11:00
:resource_id => ems_container_ids,
:role => "hawkular",
)
create_ids = ems_container_ids - ems_with_hawkular
Copy link
Contributor

Choose a reason for hiding this comment

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

does [ids] - [records] work?
Id add .pluck(:id) anyway

Copy link
Contributor

Choose a reason for hiding this comment

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

actually ems_with_hawkular will be Endpoint, so pluck :resource_id ?

@miq-bot
Copy link
Member

miq-bot commented May 28, 2017

Checked commit moolitayer@865b040 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. 👍

@cben
Copy link
Contributor

cben commented May 28, 2017

LGTM

@moolitayer
Copy link
Author

@cben much appreciated
@Fryguy Please review

@chessbyte
Copy link
Member

@Fryguy bump

@moolitayer
Copy link
Author

@Fryguy please review

2 similar comments
@moolitayer
Copy link
Author

@Fryguy please review

@moolitayer
Copy link
Author

@Fryguy please review

@moolitayer
Copy link
Author

@miq-bot add_label fine/no

def down
ems_containers_by_id = ExtManagementSystem.where(
:type => %w(ManageIQ::Providers::Openshift::ContainerManager ManageIQ::Providers::Kubernetes::ContainerManager)
).map { |ems| [ems.id, ems] }.to_h
Copy link
Member

Choose a reason for hiding this comment

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

Minor, but .map { |ems| [ems.id, ems] }.to_h can be shortened to .index_by(&:id)

@Fryguy Fryguy merged commit d8687aa into ManageIQ:master Jun 13, 2017
@Fryguy Fryguy added this to the Sprint 63 Ending Jun 19, 2017 milestone Jun 13, 2017
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.

7 participants