Browse Source

Include host_id for openstack provider

When we create a server using the openstack provider, in certain
conditions it is helpful to collect the host_id value. As an example,
Zuul will pass through this information into a job inventory file which
will allow an operator to better profile where jobs run with in a cloud.

This can be helpful trying to debug random jobs timing out within a
cloud.

Change-Id: If29397e67a470462561f24c746375b8291ac43ab
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
tags/3.4.0
Paul Belanger 6 months ago
parent
commit
cc994d3a6a

+ 4
- 0
nodepool/driver/fake/provider.py View File

@@ -141,6 +141,7 @@ class FakeOpenStackCloud(object):
141 141
             public_v6 = 'fake_v6'
142 142
             public_v4 = 'fake'
143 143
             private_v4 = 'fake'
144
+            host_id = 'fake_host_id'
144 145
             interface_ip = 'fake_v6'
145 146
             break
146 147
         if not addresses:
@@ -151,6 +152,7 @@ class FakeOpenStackCloud(object):
151 152
             public_v6 = ''
152 153
             public_v4 = 'fake'
153 154
             private_v4 = 'fake'
155
+            host_id = 'fake'
154 156
             interface_ip = 'fake'
155 157
         over_quota = False
156 158
         if (instance_type == Dummy.INSTANCE and
@@ -173,6 +175,7 @@ class FakeOpenStackCloud(object):
173 175
                   public_v4=public_v4,
174 176
                   public_v6=public_v6,
175 177
                   private_v4=private_v4,
178
+                  host_id=host_id,
176 179
                   interface_ip=interface_ip,
177 180
                   security_groups=security_groups,
178 181
                   location=Dummy(Dummy.LOCATION, zone=kw.get('az')),
@@ -238,6 +241,7 @@ class FakeOpenStackCloud(object):
238 241
         server.public_v4 = 'fake'
239 242
         server.public_v6 = 'fake'
240 243
         server.private_v4 = 'fake'
244
+        server.host_id = 'fake'
241 245
         server.interface_ip = 'fake'
242 246
         return server
243 247
 

+ 3
- 2
nodepool/driver/openstack/handler.py View File

@@ -189,6 +189,7 @@ class OpenStackNodeLauncher(NodeLauncher):
189 189
             raise exceptions.LaunchNetworkException(
190 190
                 "Unable to find public IP of server")
191 191
 
192
+        self.node.host_id = server.host_id
192 193
         self.node.interface_ip = interface_ip
193 194
         self.node.public_ipv4 = server.public_v4
194 195
         self.node.public_ipv6 = server.public_v6
@@ -204,10 +205,10 @@ class OpenStackNodeLauncher(NodeLauncher):
204 205
 
205 206
         self.log.debug(
206 207
             "Node %s is running [region: %s, az: %s, ip: %s ipv4: %s, "
207
-            "ipv6: %s]" %
208
+            "ipv6: %s, hostid: %s]" %
208 209
             (self.node.id, self.node.region, self.node.az,
209 210
              self.node.interface_ip, self.node.public_ipv4,
210
-             self.node.public_ipv6))
211
+             self.node.public_ipv6, self.node.host_id))
211 212
 
212 213
         # wait and scan the new node and record in ZooKeeper
213 214
         host_keys = []

+ 2
- 0
nodepool/tests/unit/test_launcher.py View File

@@ -678,12 +678,14 @@ class TestLauncher(tests.DBTestCase):
678 678
         self.assertEqual(label1_nodes[0].public_ipv4, 'fake')
679 679
         self.assertEqual(label1_nodes[0].public_ipv6, 'fake_v6')
680 680
         self.assertEqual(label1_nodes[0].interface_ip, 'fake_v6')
681
+        self.assertEqual(label1_nodes[0].host_id, 'fake_host_id')
681 682
 
682 683
         # ipv6 address unavailable
683 684
         self.assertEqual(label2_nodes[0].provider, 'fake-provider2')
684 685
         self.assertEqual(label2_nodes[0].public_ipv4, 'fake')
685 686
         self.assertEqual(label2_nodes[0].public_ipv6, '')
686 687
         self.assertEqual(label2_nodes[0].interface_ip, 'fake')
688
+        self.assertEqual(label2_nodes[0].host_id, 'fake')
687 689
 
688 690
     def test_node_delete_success(self):
689 691
         configfile = self.setup_config('node.yaml')

+ 4
- 0
nodepool/tests/unit/test_zk.py View File

@@ -855,6 +855,7 @@ class TestZKModel(tests.BaseTestCase):
855 855
         o.public_ipv4 = '<ipv4>'
856 856
         o.private_ipv4 = '<pvt-ipv4>'
857 857
         o.public_ipv6 = '<ipv6>'
858
+        o.host_id = 'fake-host-id'
858 859
         o.image_id = 'image-id'
859 860
         o.launcher = 'launcher-id'
860 861
         o.external_id = 'ABCD'
@@ -877,6 +878,7 @@ class TestZKModel(tests.BaseTestCase):
877 878
         self.assertEqual(d['public_ipv4'], o.public_ipv4)
878 879
         self.assertEqual(d['private_ipv4'], o.private_ipv4)
879 880
         self.assertEqual(d['public_ipv6'], o.public_ipv6)
881
+        self.assertEqual(d['host_id'], o.host_id)
880 882
         self.assertEqual(d['image_id'], o.image_id)
881 883
         self.assertEqual(d['launcher'], o.launcher)
882 884
         self.assertEqual(d['external_id'], o.external_id)
@@ -901,6 +903,7 @@ class TestZKModel(tests.BaseTestCase):
901 903
             'public_ipv4': '<ipv4>',
902 904
             'private_ipv4': '<pvt-ipv4>',
903 905
             'public_ipv6': '<ipv6>',
906
+            'host_id': 'fake-host-id',
904 907
             'image_id': 'image-id',
905 908
             'launcher': 'launcher-id',
906 909
             'external_id': 'ABCD',
@@ -925,6 +928,7 @@ class TestZKModel(tests.BaseTestCase):
925 928
         self.assertEqual(o.public_ipv4, d['public_ipv4'])
926 929
         self.assertEqual(o.private_ipv4, d['private_ipv4'])
927 930
         self.assertEqual(o.public_ipv6, d['public_ipv6'])
931
+        self.assertEqual(o.host_id, d['host_id'])
928 932
         self.assertEqual(o.image_id, d['image_id'])
929 933
         self.assertEqual(o.launcher, d['launcher'])
930 934
         self.assertEqual(o.external_id, d['external_id'])

+ 4
- 0
nodepool/zk.py View File

@@ -521,6 +521,7 @@ class Node(BaseModel):
521 521
         self.public_ipv4 = None
522 522
         self.private_ipv4 = None
523 523
         self.public_ipv6 = None
524
+        self.host_id = None
524 525
         self.interface_ip = None
525 526
         self.connection_port = 22
526 527
         self.image_id = None
@@ -558,6 +559,7 @@ class Node(BaseModel):
558 559
                     self.public_ipv4 == other.public_ipv4 and
559 560
                     self.private_ipv4 == other.private_ipv4 and
560 561
                     self.public_ipv6 == other.public_ipv6 and
562
+                    self.host_id == other.host_id and
561 563
                     self.interface_ip == other.interface_ip and
562 564
                     self.image_id == other.image_id and
563 565
                     self.launcher == other.launcher and
@@ -601,6 +603,7 @@ class Node(BaseModel):
601 603
         d['public_ipv4'] = self.public_ipv4
602 604
         d['private_ipv4'] = self.private_ipv4
603 605
         d['public_ipv6'] = self.public_ipv6
606
+        d['host_id'] = self.host_id
604 607
         d['interface_ip'] = self.interface_ip
605 608
         d['connection_port'] = self.connection_port
606 609
         # TODO(tobiash): ssh_port is kept for backwards compatibility reasons
@@ -655,6 +658,7 @@ class Node(BaseModel):
655 658
         self.public_ipv4 = d.get('public_ipv4')
656 659
         self.private_ipv4 = d.get('private_ipv4')
657 660
         self.public_ipv6 = d.get('public_ipv6')
661
+        self.host_id = d.get('host_id')
658 662
         self.interface_ip = d.get('interface_ip')
659 663
         self.connection_port = d.get('connection_port', d.get('ssh_port', 22))
660 664
         self.image_id = d.get('image_id')

Loading…
Cancel
Save