Bug 1396330 - Wrong zone set for appliances in global region
Summary: Wrong zone set for appliances in global region
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Appliance
Version: 5.6.0
Hardware: All
OS: All
medium
medium
Target Milestone: GA
: 5.8.0
Assignee: Gregg Tanzillo
QA Contact: Alex Newman
URL:
Whiteboard: zone:distributed
Depends On:
Blocks: 1413167
TreeView+ depends on / blocked
 
Reported: 2016-11-18 03:40 UTC by tachoi
Modified: 2020-04-15 14:52 UTC (History)
8 users (show)

Fixed In Version: 5.8.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1413167 (view as bug list)
Environment:
Last Closed: 2017-06-12 16:54:10 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Comment 2 Gregg Tanzillo 2016-12-07 17:14:31 UTC
This approach seems correct. However, there is a cleaner way of ensuring that the zone instance is for the correct region. You can use the "in_my_region" built-in scope for this. The scope forces a clause to the query that limits the zone id to the range of the current region. ("zones"."id" BETWEEN $1 AND $2). Here's a diff showing the change:

diff --git a/app/models/miq_server/configuration_management.rb b/app/models/miq_server/configuration_management.rb
index 171db37..5ce994f 100644
--- a/app/models/miq_server/configuration_management.rb
+++ b/app/models/miq_server/configuration_management.rb
@@ -39,7 +39,7 @@ module MiqServer::ConfigurationManagement
     end
 
     unless data.zone.nil?
-      self.zone = Zone.find_by(:name => data.zone)
+      self.zone = Zone.in_my_region.find_by(:name => data.zone)
       save
     end
     update_capabilities
(

I'll make this change to the source code.

Comment 3 Gregg Tanzillo 2016-12-09 21:39:13 UTC
Created PR - https://github.com/ManageIQ/manageiq/pull/13100

Comment 4 CFME Bot 2016-12-21 19:51:10 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/0e19e850718479f0f6414eb365cf5d592e9385fb

commit 0e19e850718479f0f6414eb365cf5d592e9385fb
Author:     Gregg Tanzillo <gtanzill>
AuthorDate: Fri Dec 9 16:36:32 2016 -0500
Commit:     Gregg Tanzillo <gtanzill>
CommitDate: Fri Dec 9 17:37:15 2016 -0500

    Scope the zone to the server's region
    
    Ensure the zone is in the server's region when looking up and saving zone during config activation.
    In multi region environments, it's typical to have a zone in the global region that is named the same as one in a lower region.
    This change fixes a bug where a zone from a different region is saved as the server zone during config activation.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1396330

 app/models/miq_server/configuration_management.rb     |  2 +-
 .../miq_server/configuration_management_spec.rb       | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)


Note You need to log in before you can comment on or make changes to this bug.