Browse Source

Disallow to change operating system during upgrade

Changing of an operating system for clouds nodes is not supported and is
not tested at all. That's why this additional validation was added.

Change-Id: Ibf6db17f783879eff88e2366dfdb0a2871e2aa0a
Ilya Kharin 2 years ago
parent
commit
7cf3fe9b3a

+ 4
- 0
cluster_upgrade/objects/adapters.py View File

@@ -100,6 +100,10 @@ class NailgunReleaseAdapter(object):
100 100
             uid, fail_if_not_found=fail_if_not_found)
101 101
         return release
102 102
 
103
+    @property
104
+    def operating_system(self):
105
+        return self.release.operating_system
106
+
103 107
     @property
104 108
     def is_deployable(self):
105 109
         return objects.Release.is_deployable(self.release)

+ 8
- 0
cluster_upgrade/tests/test_validators.py View File

@@ -58,6 +58,14 @@ class TestClusterUpgradeValidator(tests_base.BaseCloneClusterTest):
58 58
             self.validator.validate_release_upgrade(self.dst_release,
59 59
                                                     self.src_release)
60 60
 
61
+    def test_validate_release_upgrade_to_different_os(self):
62
+        self.dst_release.operating_system = consts.RELEASE_OS.centos
63
+        msg = "^Changing of operating system is not possible during upgrade " \
64
+              "\(from {0} to {1}\).$".format("Ubuntu", "CentOS")
65
+        with self.assertRaisesRegexp(errors.InvalidData, msg):
66
+            self.validator.validate_release_upgrade(self.src_release,
67
+                                                    self.dst_release)
68
+
61 69
     def test_validate_cluster_name(self):
62 70
         self.validator.validate_cluster_name("cluster-42")
63 71
 

+ 6
- 0
cluster_upgrade/validators.py View File

@@ -62,6 +62,12 @@ class ClusterUpgradeValidator(base.BasicValidator):
62 62
                 "this release is equal or lower than the release of the "
63 63
                 "original cluster.".format(new_release.id),
64 64
                 log_message=True)
65
+        if orig_release.operating_system != new_release.operating_system:
66
+            raise errors.InvalidData(
67
+                "Changing of operating system is not possible during upgrade "
68
+                "(from {0} to {1}).".format(orig_release.operating_system,
69
+                                            new_release.operating_system),
70
+                log_message=True)
65 71
 
66 72
     @classmethod
67 73
     def validate_cluster_name(cls, cluster_name):

Loading…
Cancel
Save