coren has submitted this change and it was merged.

Change subject: Labs: make labs-ip-alias-dump ignore addressless hosts
......................................................................


Labs: make labs-ip-alias-dump ignore addressless hosts

This can happen if the nova scheduler is broken, or in (rare)
race cases.  Since it's harmless to just skip over the hosts
in those instances, just ignore them.

Bug: T120586
Change-Id: I1cb2df0d13d10762aad9b7d3156f869f0bf6680c
---
M modules/dnsrecursor/files/labs-ip-alias-dump.py
1 file changed, 16 insertions(+), 11 deletions(-)

Approvals:
  Andrew Bogott: Looks good to me, but someone else must approve
  coren: Verified; Looks good to me, approved



diff --git a/modules/dnsrecursor/files/labs-ip-alias-dump.py 
b/modules/dnsrecursor/files/labs-ip-alias-dump.py
index ac368ae..6de379e 100644
--- a/modules/dnsrecursor/files/labs-ip-alias-dump.py
+++ b/modules/dnsrecursor/files/labs-ip-alias-dump.py
@@ -37,17 +37,22 @@
 
     for server in client.servers.list():
         serverAddresses = {}
-        private = [
-            str(ip['addr']) for ip in server.addresses['public'] if 
ip['OS-EXT-IPS:type'] == 'fixed'
-        ]
-        public = [
-            str(ip['addr']) for ip in server.addresses['public'] if 
ip['OS-EXT-IPS:type'] == 'floating'
-        ]
-        if public:
-            # Match all possible public IPs to all possible private ones
-            # Technically there can be more than one floating IP and more than 
one private IP
-            # Although this is never practically the case...
-            aliases[server.name] = list(itertools.product(public, private))
+        try:
+            private = [
+                str(ip['addr']) for ip in server.addresses['public'] if 
ip['OS-EXT-IPS:type'] == 'fixed'
+            ]
+            public = [
+                str(ip['addr']) for ip in server.addresses['public'] if 
ip['OS-EXT-IPS:type'] == 'floating'
+            ]
+            if public:
+                # Match all possible public IPs to all possible private ones
+                # Technically there can be more than one floating IP and more 
than one private IP
+                # Although this is never practically the case...
+                aliases[server.name] = list(itertools.product(public, private))
+        except KeyError:
+            # This can happen if a server doesn't (yet) have any addresses, 
while it's being
+            # constructed.  In which case we simply harmlessly ignore it.
+            pass
 
 output = 'aliasmapping = {}\n'
 # Sort to prevent flapping around due to random ordering

-- 
To view, visit https://gerrit.wikimedia.org/r/257323
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1cb2df0d13d10762aad9b7d3156f869f0bf6680c
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: coren <[email protected]>
Gerrit-Reviewer: Andrew Bogott <[email protected]>
Gerrit-Reviewer: Chasemp <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>
Gerrit-Reviewer: coren <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to