summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Belanger <pabelanger@redhat.com>2018-12-05 19:02:51 -0500
committerPaul Belanger <pabelanger@redhat.com>2018-12-06 18:49:48 -0500
commitcc994d3a6afddf8efcd1562f7a3013653e2dd257 (patch)
tree8b1c80f7a649836fb8b6924c3cd56b7facb56c1c
parenta3e9ebf9f15c9cf184ec70ddb62f7473f5649c7c (diff)
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>
Notes
Notes (review): Code-Review+2: David Shrewsbury <shrewsbury.dave@gmail.com> Code-Review+2: Tobias Henkel <tobias.henkel@bmw.de> Workflow+1: Tobias Henkel <tobias.henkel@bmw.de> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Fri, 07 Dec 2018 14:10:48 +0000 Reviewed-on: https://review.openstack.org/623107 Project: openstack-infra/nodepool Branch: refs/heads/master
-rw-r--r--nodepool/driver/fake/provider.py4
-rw-r--r--nodepool/driver/openstack/handler.py5
-rw-r--r--nodepool/tests/unit/test_launcher.py2
-rw-r--r--nodepool/tests/unit/test_zk.py4
-rwxr-xr-xnodepool/zk.py4
5 files changed, 17 insertions, 2 deletions
diff --git a/nodepool/driver/fake/provider.py b/nodepool/driver/fake/provider.py
index 9a52c87..5d67914 100644
--- a/nodepool/driver/fake/provider.py
+++ b/nodepool/driver/fake/provider.py
@@ -141,6 +141,7 @@ class FakeOpenStackCloud(object):
141 public_v6 = 'fake_v6' 141 public_v6 = 'fake_v6'
142 public_v4 = 'fake' 142 public_v4 = 'fake'
143 private_v4 = 'fake' 143 private_v4 = 'fake'
144 host_id = 'fake_host_id'
144 interface_ip = 'fake_v6' 145 interface_ip = 'fake_v6'
145 break 146 break
146 if not addresses: 147 if not addresses:
@@ -151,6 +152,7 @@ class FakeOpenStackCloud(object):
151 public_v6 = '' 152 public_v6 = ''
152 public_v4 = 'fake' 153 public_v4 = 'fake'
153 private_v4 = 'fake' 154 private_v4 = 'fake'
155 host_id = 'fake'
154 interface_ip = 'fake' 156 interface_ip = 'fake'
155 over_quota = False 157 over_quota = False
156 if (instance_type == Dummy.INSTANCE and 158 if (instance_type == Dummy.INSTANCE and
@@ -173,6 +175,7 @@ class FakeOpenStackCloud(object):
173 public_v4=public_v4, 175 public_v4=public_v4,
174 public_v6=public_v6, 176 public_v6=public_v6,
175 private_v4=private_v4, 177 private_v4=private_v4,
178 host_id=host_id,
176 interface_ip=interface_ip, 179 interface_ip=interface_ip,
177 security_groups=security_groups, 180 security_groups=security_groups,
178 location=Dummy(Dummy.LOCATION, zone=kw.get('az')), 181 location=Dummy(Dummy.LOCATION, zone=kw.get('az')),
@@ -238,6 +241,7 @@ class FakeOpenStackCloud(object):
238 server.public_v4 = 'fake' 241 server.public_v4 = 'fake'
239 server.public_v6 = 'fake' 242 server.public_v6 = 'fake'
240 server.private_v4 = 'fake' 243 server.private_v4 = 'fake'
244 server.host_id = 'fake'
241 server.interface_ip = 'fake' 245 server.interface_ip = 'fake'
242 return server 246 return server
243 247
diff --git a/nodepool/driver/openstack/handler.py b/nodepool/driver/openstack/handler.py
index f1e82dd..b72de91 100644
--- a/nodepool/driver/openstack/handler.py
+++ b/nodepool/driver/openstack/handler.py
@@ -189,6 +189,7 @@ class OpenStackNodeLauncher(NodeLauncher):
189 raise exceptions.LaunchNetworkException( 189 raise exceptions.LaunchNetworkException(
190 "Unable to find public IP of server") 190 "Unable to find public IP of server")
191 191
192 self.node.host_id = server.host_id
192 self.node.interface_ip = interface_ip 193 self.node.interface_ip = interface_ip
193 self.node.public_ipv4 = server.public_v4 194 self.node.public_ipv4 = server.public_v4
194 self.node.public_ipv6 = server.public_v6 195 self.node.public_ipv6 = server.public_v6
@@ -204,10 +205,10 @@ class OpenStackNodeLauncher(NodeLauncher):
204 205
205 self.log.debug( 206 self.log.debug(
206 "Node %s is running [region: %s, az: %s, ip: %s ipv4: %s, " 207 "Node %s is running [region: %s, az: %s, ip: %s ipv4: %s, "
207 "ipv6: %s]" % 208 "ipv6: %s, hostid: %s]" %
208 (self.node.id, self.node.region, self.node.az, 209 (self.node.id, self.node.region, self.node.az,
209 self.node.interface_ip, self.node.public_ipv4, 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 # wait and scan the new node and record in ZooKeeper 213 # wait and scan the new node and record in ZooKeeper
213 host_keys = [] 214 host_keys = []
diff --git a/nodepool/tests/unit/test_launcher.py b/nodepool/tests/unit/test_launcher.py
index 46f62d6..f9f0e84 100644
--- a/nodepool/tests/unit/test_launcher.py
+++ b/nodepool/tests/unit/test_launcher.py
@@ -678,12 +678,14 @@ class TestLauncher(tests.DBTestCase):
678 self.assertEqual(label1_nodes[0].public_ipv4, 'fake') 678 self.assertEqual(label1_nodes[0].public_ipv4, 'fake')
679 self.assertEqual(label1_nodes[0].public_ipv6, 'fake_v6') 679 self.assertEqual(label1_nodes[0].public_ipv6, 'fake_v6')
680 self.assertEqual(label1_nodes[0].interface_ip, 'fake_v6') 680 self.assertEqual(label1_nodes[0].interface_ip, 'fake_v6')
681 self.assertEqual(label1_nodes[0].host_id, 'fake_host_id')
681 682
682 # ipv6 address unavailable 683 # ipv6 address unavailable
683 self.assertEqual(label2_nodes[0].provider, 'fake-provider2') 684 self.assertEqual(label2_nodes[0].provider, 'fake-provider2')
684 self.assertEqual(label2_nodes[0].public_ipv4, 'fake') 685 self.assertEqual(label2_nodes[0].public_ipv4, 'fake')
685 self.assertEqual(label2_nodes[0].public_ipv6, '') 686 self.assertEqual(label2_nodes[0].public_ipv6, '')
686 self.assertEqual(label2_nodes[0].interface_ip, 'fake') 687 self.assertEqual(label2_nodes[0].interface_ip, 'fake')
688 self.assertEqual(label2_nodes[0].host_id, 'fake')
687 689
688 def test_node_delete_success(self): 690 def test_node_delete_success(self):
689 configfile = self.setup_config('node.yaml') 691 configfile = self.setup_config('node.yaml')
diff --git a/nodepool/tests/unit/test_zk.py b/nodepool/tests/unit/test_zk.py
index 401196a..857ba14 100644
--- a/nodepool/tests/unit/test_zk.py
+++ b/nodepool/tests/unit/test_zk.py
@@ -855,6 +855,7 @@ class TestZKModel(tests.BaseTestCase):
855 o.public_ipv4 = '<ipv4>' 855 o.public_ipv4 = '<ipv4>'
856 o.private_ipv4 = '<pvt-ipv4>' 856 o.private_ipv4 = '<pvt-ipv4>'
857 o.public_ipv6 = '<ipv6>' 857 o.public_ipv6 = '<ipv6>'
858 o.host_id = 'fake-host-id'
858 o.image_id = 'image-id' 859 o.image_id = 'image-id'
859 o.launcher = 'launcher-id' 860 o.launcher = 'launcher-id'
860 o.external_id = 'ABCD' 861 o.external_id = 'ABCD'
@@ -877,6 +878,7 @@ class TestZKModel(tests.BaseTestCase):
877 self.assertEqual(d['public_ipv4'], o.public_ipv4) 878 self.assertEqual(d['public_ipv4'], o.public_ipv4)
878 self.assertEqual(d['private_ipv4'], o.private_ipv4) 879 self.assertEqual(d['private_ipv4'], o.private_ipv4)
879 self.assertEqual(d['public_ipv6'], o.public_ipv6) 880 self.assertEqual(d['public_ipv6'], o.public_ipv6)
881 self.assertEqual(d['host_id'], o.host_id)
880 self.assertEqual(d['image_id'], o.image_id) 882 self.assertEqual(d['image_id'], o.image_id)
881 self.assertEqual(d['launcher'], o.launcher) 883 self.assertEqual(d['launcher'], o.launcher)
882 self.assertEqual(d['external_id'], o.external_id) 884 self.assertEqual(d['external_id'], o.external_id)
@@ -901,6 +903,7 @@ class TestZKModel(tests.BaseTestCase):
901 'public_ipv4': '<ipv4>', 903 'public_ipv4': '<ipv4>',
902 'private_ipv4': '<pvt-ipv4>', 904 'private_ipv4': '<pvt-ipv4>',
903 'public_ipv6': '<ipv6>', 905 'public_ipv6': '<ipv6>',
906 'host_id': 'fake-host-id',
904 'image_id': 'image-id', 907 'image_id': 'image-id',
905 'launcher': 'launcher-id', 908 'launcher': 'launcher-id',
906 'external_id': 'ABCD', 909 'external_id': 'ABCD',
@@ -925,6 +928,7 @@ class TestZKModel(tests.BaseTestCase):
925 self.assertEqual(o.public_ipv4, d['public_ipv4']) 928 self.assertEqual(o.public_ipv4, d['public_ipv4'])
926 self.assertEqual(o.private_ipv4, d['private_ipv4']) 929 self.assertEqual(o.private_ipv4, d['private_ipv4'])
927 self.assertEqual(o.public_ipv6, d['public_ipv6']) 930 self.assertEqual(o.public_ipv6, d['public_ipv6'])
931 self.assertEqual(o.host_id, d['host_id'])
928 self.assertEqual(o.image_id, d['image_id']) 932 self.assertEqual(o.image_id, d['image_id'])
929 self.assertEqual(o.launcher, d['launcher']) 933 self.assertEqual(o.launcher, d['launcher'])
930 self.assertEqual(o.external_id, d['external_id']) 934 self.assertEqual(o.external_id, d['external_id'])
diff --git a/nodepool/zk.py b/nodepool/zk.py
index e42f644..ee456c4 100755
--- a/nodepool/zk.py
+++ b/nodepool/zk.py
@@ -521,6 +521,7 @@ class Node(BaseModel):
521 self.public_ipv4 = None 521 self.public_ipv4 = None
522 self.private_ipv4 = None 522 self.private_ipv4 = None
523 self.public_ipv6 = None 523 self.public_ipv6 = None
524 self.host_id = None
524 self.interface_ip = None 525 self.interface_ip = None
525 self.connection_port = 22 526 self.connection_port = 22
526 self.image_id = None 527 self.image_id = None
@@ -558,6 +559,7 @@ class Node(BaseModel):
558 self.public_ipv4 == other.public_ipv4 and 559 self.public_ipv4 == other.public_ipv4 and
559 self.private_ipv4 == other.private_ipv4 and 560 self.private_ipv4 == other.private_ipv4 and
560 self.public_ipv6 == other.public_ipv6 and 561 self.public_ipv6 == other.public_ipv6 and
562 self.host_id == other.host_id and
561 self.interface_ip == other.interface_ip and 563 self.interface_ip == other.interface_ip and
562 self.image_id == other.image_id and 564 self.image_id == other.image_id and
563 self.launcher == other.launcher and 565 self.launcher == other.launcher and
@@ -601,6 +603,7 @@ class Node(BaseModel):
601 d['public_ipv4'] = self.public_ipv4 603 d['public_ipv4'] = self.public_ipv4
602 d['private_ipv4'] = self.private_ipv4 604 d['private_ipv4'] = self.private_ipv4
603 d['public_ipv6'] = self.public_ipv6 605 d['public_ipv6'] = self.public_ipv6
606 d['host_id'] = self.host_id
604 d['interface_ip'] = self.interface_ip 607 d['interface_ip'] = self.interface_ip
605 d['connection_port'] = self.connection_port 608 d['connection_port'] = self.connection_port
606 # TODO(tobiash): ssh_port is kept for backwards compatibility reasons 609 # TODO(tobiash): ssh_port is kept for backwards compatibility reasons
@@ -655,6 +658,7 @@ class Node(BaseModel):
655 self.public_ipv4 = d.get('public_ipv4') 658 self.public_ipv4 = d.get('public_ipv4')
656 self.private_ipv4 = d.get('private_ipv4') 659 self.private_ipv4 = d.get('private_ipv4')
657 self.public_ipv6 = d.get('public_ipv6') 660 self.public_ipv6 = d.get('public_ipv6')
661 self.host_id = d.get('host_id')
658 self.interface_ip = d.get('interface_ip') 662 self.interface_ip = d.get('interface_ip')
659 self.connection_port = d.get('connection_port', d.get('ssh_port', 22)) 663 self.connection_port = d.get('connection_port', d.get('ssh_port', 22))
660 self.image_id = d.get('image_id') 664 self.image_id = d.get('image_id')