-
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
Changes cloud network list to follow availability zone rules #16688
Conversation
@miq-bot assign @gmcculloug |
@miq-bot add_label bug |
@@ -31,6 +23,12 @@ def allowed_cloud_subnets(_options = {}) | |||
end | |||
end | |||
|
|||
def allowed_cloud_networks(_options = {}) | |||
source = load_ar_obj(get_source_vm) | |||
targets = get_targets_for_ems(source, :cloud_filter, CloudNetwork, 'cloud_networks') |
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.
@d-m-u - I think you may just need to use get_targets_for_source
here as opposed to the _ems
variant.
The original code iterated off the src_obj
without the need to lookup the ems
so you shouldn't need to lookup the ems
with this fix as well.
85ff45a
to
079c8fb
Compare
end | ||
end | ||
end | ||
|
||
def get_source_and_targets(refresh = false) |
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.
@d-m-u - from reading this method it sounds like this loads the cloud_networks associated with the availability zone of the source which is contrary to the PR description, yay or nay?
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. Fixed. Sorry.
@syncrou cool, thanks! can this wait till i'm back? |
@@ -90,6 +88,19 @@ def allowed_ci(ci, relats, filtered_ids = nil) | |||
super(ci, relats, sources, filtered_ids) | |||
end | |||
|
|||
def availability_zone_to_cloud_network(src) |
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.
there seems to be a mapping, other way around in https://github.com/Ladas/manageiq-providers-amazon/blob/6b6cb06d25bd5d38e1c700fd34fcd87a6efec824/app/models/manageiq/providers/amazon/cloud_manager/provision_workflow.rb#L75
Anyway. This seems like Amazon specific code, so this should belong to amazon/cloud_manager/provision_workflow.rb. @bronaghs or do we have similar behavior for e.g. azure?
@syncrou can ya take a look at this please for me? |
Checked commits d-m-u/manageiq@2784dce~...5fa2fce with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@@ -90,6 +88,20 @@ def allowed_ci(ci, relats, filtered_ids = nil) | |||
super(ci, relats, sources, filtered_ids) | |||
end | |||
|
|||
def availability_zone_to_cloud_network(src) | |||
if src[:availability_zone] | |||
load_ar_obj(src[:availability_zone]).cloud_subnets.each_with_object({}) do |cs, hash| |
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.
@d-m-u - Would there be a need for RBAC'd cloud_subnets
here and on line 99?
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.
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.
@gmcculloug - Ahh - missed the get_targets_for_source
that built out the targets list.
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
Changes cloud network list to follow availability zone rules (cherry picked from commit c11b14e) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1533277
Gaprindashvili backport details:
|
def allowed_cloud_networks(_options = {}) | ||
source = load_ar_obj(get_source_vm) | ||
targets = get_targets_for_source(source, :cloud_filter, CloudNetwork, 'cloud_network_id') | ||
allowed_ci(:cloud_network, [:availability_zone], targets.map(&:id)) |
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.
@d-m-u OpenStack CI is now down, most probably because of this line, can you please run all cloud providers specs locally? I think we will need to do this change only in AWS code, to avoid breaking others.
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.
@bronaghs this has probably broken also Azure (there is no spec for allowed_cloud_networks in azure), @d-m-u you have probably missed my comment #16688 (review) ?
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.
@Ladas I think if you look at https://github.com/ManageIQ/manageiq/blob/master/app/models/manageiq/providers/cloud_manager/provision_workflow.rb#L30 you'll see that cloud_network_id is not the line that got merged.
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.
@d-m-u right I mean the allowed_ci(:cloud_network, [:availability_zone], targets.map(&:id))
, for OpenStack it's always returning blank set. The same case might be for the other providers, but the specs are probably missing.
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.
@d-m-u I haven't tried if this breaks the actual Provision dialog, so that is probably a thing for testing for all clouds. But I don't see that we have a relation of AvailabilityZone to cloud_subnets, while AvailabilityZone is being picked in the UI.
So this is being invoked https://github.com/Ladas/manageiq/blob/59ba714ccb71b2eb3cdd46157587e85329af4f3b/app/models/manageiq/providers/cloud_manager/provision_workflow.rb#L92 and always returns blank result.
I don't see AZ associated to subnet in refresh also in Google and Vcloud. Azure seems to have 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.
so back to my comment #16688 (comment)
filters for specific provider should reside in the provider code, if the behavior is not common to all of them. In this case the Amazon workflow file would have
def allowed_cloud_networks(_options = {})
targets = super
allowed_ci(:cloud_network, [:availability_zone], targets.map(&:id))
end
and the generic code for all cloud providers would not have allowed_ci(:cloud_network, [:availability_zone], targets.map(&:id))
@d-m-u seems like OpenStack networks support AvailabilityZones now https://developer.openstack.org/api-ref/network/v2/index.html#show-network-details , but it's has_many relation to network, not belongs to subnet. So probably a thing for OpenStack team to extend cc @aufi , although we need to extend the model. Anyway at minimum, OpenStack behavior is specific. I am not 100% sure about others, not sure if we tested impact on all providers changing this shared code? |
Previously, cloud network list was only updated after selection of security group, or change of tab, or a select set of other actions that completely voided the list of parameters passed to the filtering method. This adds a change so that availability zone updates the selection of cloud network, preventing incorrect cloud networks from showing up in the after the zone dropdown changes.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1518847