sql: Fix Zones are returned in a random order (#3934)#4494
sql: Fix Zones are returned in a random order (#3934)#4494yadvr merged 1 commit intoapache:masterapache/cloudstack:masterfrom ustcweizhou:4.15-fix-sort-keyustcweizhou/cloudstack:4.15-fix-sort-keyCopy head branch name to clipboard
Conversation
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
| ALTER TABLE `cloud_usage`.`cloud_usage` ADD COLUMN `is_hidden` smallint(1) NOT NULL DEFAULT '0' COMMENT 'is usage hidden'; | ||
|
|
||
| -- Fix Zones are returned in a random order (#3934) | ||
| UPDATE `cloud`.`data_center` JOIN (SELECT COUNT(1) AS count FROM `cloud`.`data_center` WHERE `sort_key` != 0) AS tbl_tmp SET `sort_key` = `id` WHERE count = 0; |
There was a problem hiding this comment.
excuse my ignorance. why not just
UPDATE `cloud`.`data_center` SET `sort_key` = `id` WHERE `sort_key` = 0;
this seems like it going to work as well, but i'm missing the point, i guess. at worst the first in the sortorder has to be put back at the fron, but this should be a onetime effort.
There was a problem hiding this comment.
@DaanHoogland assume the sort_key is 1,0, with your sql sort_key will be changed to 1,2.
the order of zones is changed by the sql.
There was a problem hiding this comment.
so in the case above, sort_key is only changed if there is no sort_key != 0. This would mean that if there are three where it is 0 and one where it is 10, nothing gets changed, does it?
if this is at all possible btw!
There was a problem hiding this comment.
@DaanHoogland exactly.
IMHO, if there is a non-zero sort_key , which mean cloudstack user might use sort_key for ordering, we will not touch it.
if all sort_key are 0, we change sort_key to id.
There was a problem hiding this comment.
ok, sounds reasonable.
|
Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2424 |
|
@blueorangutan test |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-3240)
|
* master: (25 commits) integration test: skip vlan of public ip range in get_free_vlan vpc vr: plugin nics by this order: public/private/guest vpc vr: fix Conflicting device id on private gw nic Adding zone name to physicalnetworkresponse (apache#4510) Disallowing udp for lb rules for haproxy (apache#4501) Make global setting non-dynamic (apache#4505) Adding cpuallocated percentage and value to host and hostsformigrationresponse (apache#4499) kvm: fix router.aggregation.command.each.timeout is reset to 600 when update other kvm configs (apache#4496) fix failures with test_multiple_nic_support.py (apache#4495) Fix hosts for migration count (apache#4500) sql: Fix Zones are returned in a random order (apache#3934) (apache#4494) integration test: update steps integration test: add private gateway in test integration test: verify public nics state bugfix apache#9 vpc vr: Add PREROUTING rule for vm with static nat to multiple private gateways bugfix apache#8 vpc: add rule for traffic between vm and private gateway bugfix apache#7 vpc vr: allow servers in private gateway to reach internet via the VPC VR if it is gateway bugfix apache#6 vpc vr: Add iptables rules for ACL of private gateway Revert "Fix Policy Based Routing for private gateway static routes (apache#3604)" Revert "Add private gateway IP to router initialization config" ...
Description
This PR updates sort_key to id if sort_key of all zones are 0 (including removed zones, which means sort_key is not set by customers), so zones will be ordered by id in listZones response.
Fixes: #3934
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?