瀏覽代碼

Explicitly set schedulable when masters == nodes.

When the masters are the only nodes in play, we need to explicitly set
schedulable to True due to logic in openshift_facts.py which assumes that if
the node is also a master, schedulable should be false.
Devan Goodwin 9 年之前
父節點
當前提交
80c166ab60
共有 2 個文件被更改,包括 25 次插入25 次删除
  1. 13 5
      utils/src/ooinstall/openshift_ansible.py
  2. 12 20
      utils/test/cli_installer_tests.py

+ 13 - 5
utils/src/ooinstall/openshift_ansible.py

@@ -62,12 +62,12 @@ def generate_inventory(hosts):
     # and store it on the Node object.
     if set(nodes) == set(masters):
         for node in nodes:
-            write_host(node, base_inventory)
+            write_host(node, base_inventory, True)
     else:
         for node in nodes:
             # TODO: Until the Master can run the SDN itself we have to configure the Masters
             # as Nodes too.
-            scheduleable = True
+            scheduleable = None
             if node in masters:
                 scheduleable = False
             write_host(node, base_inventory, scheduleable)
@@ -112,7 +112,7 @@ def write_inventory_vars(base_inventory, multiple_masters, proxy):
         base_inventory.write("openshift_master_cluster_public_hostname={}\n".format(proxy.public_hostname))
 
 
-def write_host(host, inventory, scheduleable=True):
+def write_host(host, inventory, scheduleable=None):
     global CFG
 
     facts = ''
@@ -126,8 +126,16 @@ def write_host(host, inventory, scheduleable=True):
         facts += ' openshift_public_hostname={}'.format(host.public_hostname)
     # TODO: For not write_host is handles both master and nodes.
     # Technically only nodes will ever need this.
-    if not scheduleable:
-        facts += ' openshift_scheduleable=False'
+
+    # Distinguish between three states, no schedulability specified (use default),
+    # explicitly set to True, or explicitly set to False:
+    if scheduleable is None:
+        pass
+    elif scheduleable:
+        facts += ' openshift_schedulable=True'
+    elif not scheduleable:
+        facts += ' openshift_schedulable=False'
+
     installer_host = socket.gethostname()
     if installer_host in [host.connect_to, host.hostname, host.public_hostname]:
         facts += ' ansible_connection=local'

+ 12 - 20
utils/test/cli_installer_tests.py

@@ -209,7 +209,6 @@ class OOCliFixture(OOInstallFixture):
         self.assertEquals(exp_hosts_to_run_on_len, len(hosts_to_run_on))
 
     def _verify_config_hosts(self, written_config, host_count):
-        print written_config['hosts']
         self.assertEquals(host_count, len(written_config['hosts']))
         for h in written_config['hosts']:
             self.assertTrue('hostname' in h)
@@ -712,7 +711,7 @@ class AttendedCliTests(OOCliFixture):
         inventory = ConfigParser.ConfigParser(allow_no_value=True)
         inventory.read(os.path.join(self.work_dir, '.ansible/hosts'))
         self.assertEquals('False',
-            inventory.get('nodes', '10.0.0.1  openshift_scheduleable'))
+            inventory.get('nodes', '10.0.0.1  openshift_schedulable'))
         self.assertEquals(None,
             inventory.get('nodes', '10.0.0.2'))
         self.assertEquals(None,
@@ -744,7 +743,6 @@ class AttendedCliTests(OOCliFixture):
         result = self.runner.invoke(cli.cli,
                                     self.cli_args,
                                     input=cli_input)
-        print result
         self.assert_result(result, 0)
 
         self._verify_load_facts(load_facts_mock)
@@ -830,15 +828,13 @@ class AttendedCliTests(OOCliFixture):
         inventory = ConfigParser.ConfigParser(allow_no_value=True)
         inventory.read(os.path.join(self.work_dir, '.ansible/hosts'))
         self.assertEquals('False',
-            inventory.get('nodes', '10.0.0.1  openshift_scheduleable'))
+            inventory.get('nodes', '10.0.0.1  openshift_schedulable'))
         self.assertEquals('False',
-            inventory.get('nodes', '10.0.0.2  openshift_scheduleable'))
+            inventory.get('nodes', '10.0.0.2  openshift_schedulable'))
         self.assertEquals(None,
             inventory.get('nodes', '10.0.0.3'))
         self.assertEquals('False',
-            inventory.get('nodes', '10.0.0.4  openshift_scheduleable'))
-
-        return
+            inventory.get('nodes', '10.0.0.4  openshift_schedulable'))
 
     #interactive multimaster: equal number masters and nodes
     @patch('ooinstall.openshift_ansible.run_main_playbook')
@@ -868,14 +864,12 @@ class AttendedCliTests(OOCliFixture):
 
         inventory = ConfigParser.ConfigParser(allow_no_value=True)
         inventory.read(os.path.join(self.work_dir, '.ansible/hosts'))
-        self.assertEquals(None,
-            inventory.get('nodes', '10.0.0.1'))
-        self.assertEquals(None,
-            inventory.get('nodes', '10.0.0.2'))
-        self.assertEquals(None,
-            inventory.get('nodes', '10.0.0.3'))
-
-        return
+        self.assertEquals('True',
+            inventory.get('nodes', '10.0.0.1  openshift_schedulable'))
+        self.assertEquals('True',
+            inventory.get('nodes', '10.0.0.2  openshift_schedulable'))
+        self.assertEquals('True',
+            inventory.get('nodes', '10.0.0.3  openshift_schedulable'))
 
     #interactive all-in-one
     @patch('ooinstall.openshift_ansible.run_main_playbook')
@@ -902,10 +896,8 @@ class AttendedCliTests(OOCliFixture):
 
         inventory = ConfigParser.ConfigParser(allow_no_value=True)
         inventory.read(os.path.join(self.work_dir, '.ansible/hosts'))
-        self.assertEquals(None,
-            inventory.get('nodes', '10.0.0.1'))
-
-        return
+        self.assertEquals('True',
+            inventory.get('nodes', '10.0.0.1  openshift_schedulable'))
 
 # TODO: test with config file, attended add node
 # TODO: test with config file, attended new node already in config file