LGTM, Thanks.

On Mon, May 20, 2013 at 5:11 PM, Bernardo Dal Seno <[email protected]>wrote:

> The configuration is still the same as in 2.8 (the reference stable version
> for this branch), so downgrade shouldn't do anything.
>
> Unit tests are also updated, with a new 2.8 configuration file. The
> configuration file used for the upgrade+downgrade test was tailored to the
> 2.7 downgrade, and it's not needed any more.
>
> Signed-off-by: Bernardo Dal Seno <[email protected]>
> ---
>  Makefile.am                                        |   2 +-
>  ...downgraded_2.7.json => cluster_config_2.8.json} | 103
> +++++++++++++--------
>  test/py/cfgupgrade_unittest.py                     |   7 +-
>  tools/cfgupgrade                                   |  53 +----------
>  4 files changed, 73 insertions(+), 92 deletions(-)
>  rename test/data/{cluster_config_downgraded_2.7.json =>
> cluster_config_2.8.json} (88%)
>
> diff --git a/Makefile.am b/Makefile.am
> index 27c9b97..137ffbc 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -1093,7 +1093,7 @@ TEST_FILES = \
>         test/data/cert1.pem \
>         test/data/cert2.pem \
>         test/data/cluster_config_2.7.json \
> -       test/data/cluster_config_downgraded_2.7.json \
> +       test/data/cluster_config_2.8.json \
>         test/data/instance-minor-pairing.txt \
>         test/data/ip-addr-show-dummy0.txt \
>         test/data/ip-addr-show-lo-ipv4.txt \
> diff --git a/test/data/cluster_config_downgraded_2.7.json
> b/test/data/cluster_config_2.8.json
> similarity index 88%
> rename from test/data/cluster_config_downgraded_2.7.json
> rename to test/data/cluster_config_2.8.json
> index 8f3847a..b0dba99 100644
> --- a/test/data/cluster_config_downgraded_2.7.json
> +++ b/test/data/cluster_config_2.8.json
> @@ -46,6 +46,12 @@
>        "sharedfile": {}
>      },
>      "drbd_usermode_helper": "/bin/true",
> +    "enabled_disk_templates": [
> +      "drbd",
> +      "plain",
> +      "file",
> +      "sharedfile"
> +    ],
>      "enabled_hypervisors": [
>        "xen-pvm"
>      ],
> @@ -175,22 +181,26 @@
>          "file",
>          "rbd"
>        ],
> -      "max": {
> -        "cpu-count": 8,
> -        "disk-count": 16,
> -        "disk-size": 1048576,
> -        "memory-size": 32768,
> -        "nic-count": 8,
> -        "spindle-use": 12
> -      },
> -      "min": {
> -        "cpu-count": 1,
> -        "disk-count": 1,
> -        "disk-size": 1024,
> -        "memory-size": 128,
> -        "nic-count": 1,
> -        "spindle-use": 1
> -      },
> +      "minmax": [
> +        {
> +          "max": {
> +            "cpu-count": 8,
> +            "disk-count": 16,
> +            "disk-size": 1048576,
> +            "memory-size": 32768,
> +            "nic-count": 8,
> +            "spindle-use": 12
> +          },
> +          "min": {
> +            "cpu-count": 1,
> +            "disk-count": 1,
> +            "disk-size": 1024,
> +            "memory-size": 128,
> +            "nic-count": 1,
> +            "spindle-use": 1
> +          }
> +        }
> +      ],
>        "spindle-ratio": 32.0,
>        "std": {
>          "cpu-count": 1,
> @@ -312,7 +322,8 @@
>              0,
>              "d3c3fd475fcbaf5fd177fb245ac43b71247ada38"
>            ],
> -          "size": 1024
> +          "size": 1024,
> +          "uuid": "77ced3a5-6756-49ae-8d1f-274e27664c05"
>          }
>        ],
>        "hvparams": {},
> @@ -322,7 +333,8 @@
>        "nics": [
>          {
>            "mac": "aa:bb:cc:b2:6e:0b",
> -          "nicparams": {}
> +          "nicparams": {},
> +          "uuid": "2c953d72-fac4-4aa9-a225-4131bb271791"
>          }
>        ],
>        "os": "busybox",
> @@ -350,7 +362,8 @@
>              "xenvg",
>              "3e559cd7-1024-4294-a923-a9fd13182b2f.disk0"
>            ],
> -          "size": 102400
> +          "size": 102400,
> +          "uuid": "79acf611-be58-4334-9fe4-4f2b73ae8abb"
>          }
>        ],
>        "hvparams": {},
> @@ -360,7 +373,8 @@
>        "nics": [
>          {
>            "mac": "aa:bb:cc:56:83:fb",
> -          "nicparams": {}
> +          "nicparams": {},
> +          "uuid": "1cf95562-e676-4fd0-8214-e8b84a2f7bd1"
>          }
>        ],
>        "os": "debian-image",
> @@ -389,7 +403,8 @@
>              "xenvg",
>              "b27a576a-13f7-4f07-885c-63fcad4fdfcc.disk0"
>            ],
> -          "size": 1280
> +          "size": 1280,
> +          "uuid": "150bd154-8e23-44d1-b762-5065ae5a507b"
>          }
>        ],
>        "hvparams": {},
> @@ -399,7 +414,8 @@
>        "nics": [
>          {
>            "mac": "aa:bb:cc:5e:5c:75",
> -          "nicparams": {}
> +          "nicparams": {},
> +          "uuid": "1ab090c1-e017-406c-afb4-fc285cb43e31"
>          }
>        ],
>        "os": "debian-image",
> @@ -410,7 +426,7 @@
>        "uuid": "4e091bdc-e205-4ed7-8a47-0c9130a6619f"
>      }
>    },
> -  "mtime": 1361984633.373014,
> +  "mtime": 1367352404.758083,
>    "networks": {
>      "99f0128a-1c84-44da-90b9-9581ea00c075": {
>        "ext_reservations":
> "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
> @@ -425,11 +441,7 @@
>      "5244a46d-7506-4e14-922d-02b58153dde1": {
>        "alloc_policy": "preferred",
>        "diskparams": {},
> -      "ipolicy": {
> -        "max": {},
> -        "min": {},
> -        "std": {}
> -      },
> +      "ipolicy": {},
>        "mtime": 1361963775.575009,
>        "name": "default",
>        "ndparams": {},
> @@ -442,14 +454,31 @@
>        "alloc_policy": "preferred",
>        "diskparams": {},
>        "ipolicy": {
> -       "disk-templates": [
> -         "plain"
> -       ],
> -       "max": {},
> -       "min": {},
> -       "spindle-ratio": 5.2,
> -       "std": {},
> -       "vcpu-ratio": 3.14
> +        "disk-templates": [
> +          "plain"
> +        ],
> +        "minmax": [
> +          {
> +            "max": {
> +              "cpu-count": 8,
> +              "disk-count": 16,
> +              "disk-size": 1048576,
> +              "memory-size": 32768,
> +              "nic-count": 18,
> +              "spindle-use": 14
> +            },
> +            "min": {
> +              "cpu-count": 2,
> +              "disk-count": 2,
> +              "disk-size": 1024,
> +              "memory-size": 128,
> +              "nic-count": 1,
> +              "spindle-use": 1
> +            }
> +          }
> +        ],
> +        "spindle-ratio": 5.2,
> +        "vcpu-ratio": 3.14
>        },
>        "mtime": 1361963775.575009,
>        "name": "another",
> @@ -518,6 +547,6 @@
>        "vm_capable": true
>      }
>    },
> -  "serial_no": 7624,
> +  "serial_no": 7625,
>    "version": 2070000
>  }
> diff --git a/test/py/cfgupgrade_unittest.py
> b/test/py/cfgupgrade_unittest.py
> index 52a9299..9d6c9e3 100755
> --- a/test/py/cfgupgrade_unittest.py
> +++ b/test/py/cfgupgrade_unittest.py
> @@ -365,6 +365,9 @@ class TestCfgupgrade(unittest.TestCase):
>    def testUpgradeFullConfigFrom_2_7(self):
>      self._TestUpgradeFromFile("cluster_config_2.7.json", False)
>
> +  def testUpgradeFullConfigFrom_2_8(self):
> +    self._TestUpgradeFromFile("cluster_config_2.8.json", False)
> +
>    def testUpgradeCurrent(self):
>      self._TestSimpleUpgrade(constants.CONFIG_VERSION, False)
>
> @@ -382,9 +385,7 @@ class TestCfgupgrade(unittest.TestCase):
>    def testDowngradeFullConfig(self):
>      """Test for upgrade + downgrade combination."""
>      # This test can work only with the previous version of a
> configuration!
> -    # For 2.7, downgrading returns the original file only if group
> policies
> -    # don't override instance specs, so we need to use an ad-hoc
> configuration.
> -    oldconfname = "cluster_config_downgraded_2.7.json"
> +    oldconfname = "cluster_config_2.8.json"
>      self._TestUpgradeFromFile(oldconfname, False)
>      _RunUpgrade(self.tmpdir, False, True, downgrade=True)
>      oldconf = self._LoadTestDataConfig(oldconfname)
> diff --git a/tools/cfgupgrade b/tools/cfgupgrade
> index 0526b1a..cb65cdf 100755
> --- a/tools/cfgupgrade
> +++ b/tools/cfgupgrade
> @@ -260,60 +260,11 @@ def UpgradeAll(config_data):
>    UpgradeInstances(config_data)
>
>
> -def DowngradeIPolicy(ipolicy, owner):
> -  # Downgrade IPolicy to 2.7 (stable)
> -  minmax_keys = ["min", "max"]
> -  specs_is_split = any((k in ipolicy) for k in minmax_keys)
> -  if not specs_is_split:
> -    if "minmax" in ipolicy:
> -      if type(ipolicy["minmax"]) is not list:
> -        raise Error("Invalid minmax type in %s ipolicy: %s" %
> -                    (owner, type(ipolicy["minmax"])))
> -      if len(ipolicy["minmax"]) > 1:
> -        logging.warning("Discarding some limit specs values from %s
> policy",
> -                        owner)
> -      minmax = ipolicy["minmax"][0]
> -      del ipolicy["minmax"]
> -    else:
> -      minmax = {}
> -    for key in minmax_keys:
> -      spec = minmax.get(key, {})
> -      ipolicy[key] = spec
> -    if "std" not in ipolicy:
> -      ipolicy["std"] = {}
> -
> -
> -def DowngradeGroups(config_data):
> -  for group in config_data["nodegroups"].values():
> -    ipolicy = group.get("ipolicy", None)
> -    if ipolicy is not None:
> -      DowngradeIPolicy(ipolicy, "group \"%s\"" % group.get("name"))
> -
> -
> -def DowngradeEnabledTemplates(cluster):
> -  # Remove enabled disk templates to downgrade to 2.7
> -  edt_key = "enabled_disk_templates"
> -  if edt_key in cluster:
> -    logging.warning("Removing cluster's enabled disk templates; value =
> %s",
> -                    utils.CommaJoin(cluster[edt_key]))
> -    del cluster[edt_key]
> -
> -
> -def DowngradeCluster(config_data):
> -  cluster = config_data.get("cluster", None)
> -  if cluster is None:
> -    raise Error("Cannot find cluster")
> -  DowngradeEnabledTemplates(cluster)
> -  ipolicy = cluster.get("ipolicy", None)
> -  if ipolicy:
> -    DowngradeIPolicy(ipolicy, "cluster")
> -
> -
>  def DowngradeAll(config_data):
> +  # Unused arguments, pylint: disable=W0613
>    # Any code specific to a particular version should be labeled that way,
> so
>    # it can be removed when updating to the next version.
> -  DowngradeCluster(config_data)
> -  DowngradeGroups(config_data)
> +  pass
>
>
>  def main():
> --
> 1.8.2.1
>
>


-- 
Thomas Thrainer | Software Engineer | [email protected] |

Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Katherine Stephens

Reply via email to