Merge "GCE: add use-internal-ip option"

This commit is contained in:
Zuul 2019-12-14 15:04:29 +00:00 committed by Gerrit Code Review
commit b42d2955e4
3 changed files with 16 additions and 1 deletions

View File

@ -2007,6 +2007,12 @@ section of the configuration.
booted. This might be needed if nodepool-launcher and the nodes it
launches are on different networks. The default value is True.
.. attr:: use-internal-ip
:default: False
Whether to access the instance with the internal or external IP
address.
.. attr:: labels
:type: list

View File

@ -80,6 +80,7 @@ class ProviderPool(ConfigPool):
def __init__(self):
self.name = None
self.host_key_checking = True
self.use_internal_ip = False
self.labels = None
# The ProviderConfig object that owns this pool.
self.provider = None
@ -94,6 +95,8 @@ class ProviderPool(ConfigPool):
self.host_key_checking = bool(
pool_config.get('host-key-checking', True))
self.use_internal_ip = bool(
pool_config.get('use-internal-ip', False))
for label in pool_config.get('labels', []):
pl = ProviderLabel()
@ -124,6 +127,7 @@ class ProviderPool(ConfigPool):
return (super().__eq__(other)
and other.name == self.name
and other.host_key_checking == self.host_key_checking
and other.use_internal_ip == self.use_internal_ip
and other.labels == self.labels)
return False
@ -218,6 +222,7 @@ class GCEProviderConfig(ProviderConfig):
pool.update({
v.Required('name'): str,
v.Required('labels'): [pool_label],
'use-internal-ip': bool,
})
provider_cloud_images = {
@ -239,6 +244,7 @@ class GCEProviderConfig(ProviderConfig):
'cloud-images': [provider_cloud_images],
'boot-timeout': int,
'launch-retries': int,
'rate-limit': int,
})
return v.Schema(provider)

View File

@ -106,7 +106,10 @@ class SimpleTaskManagerLauncher(NodeLauncher):
self.log.debug("Created instance %s", repr(instance))
server_ip = instance.interface_ip
if self.pool.use_internal_ip:
server_ip = instance.private_ipv4
else:
server_ip = instance.interface_ip
self.node.connection_port = self.label.cloud_image.connection_port
self.node.connection_type = self.label.cloud_image.connection_type