Update Shipyard Operators

There are a couple changes in this Patch Set:

1) There has been recent changes in the genesis process and
the Tiller pod now resides in the ucp namespace instead of
kube-system. As such it no longer takes on the IP of the Genesis
Node. The YAMLs continue to be hosted on the nginx server
which resides on the genesis node. Hence we will need to get
the IP of mass-rack pod instead in order to resolve to the
correct IP of the nginx server.

Note that this logic will change in near future when Armada
is integrated with DeckHand. The nginx server concept will
go away at that time.

2) Bug fix in 'cluster_join_check_backoff_time' variable type
in DryDock Operator. That variable needs to take on integer value.

3) Updates to the 'get_k8s_pod_port_ip' Operator. Note that it is
possible for pod to have an IP with no port. For instance the
maas-rack pod takes on genesis node IP and has no port associated
with it. We will assign the value 'None' to the port value in such
cases.

Change-Id: I07dd922c98c63e03a8963f7767b457c932ee772b
This commit is contained in:
Anthony Lin 2017-12-08 15:45:24 +00:00
parent ed8107baad
commit 9f2bbdbd26
3 changed files with 31 additions and 8 deletions

View File

@ -94,6 +94,9 @@ class ArmadaOperator(BaseOperator):
# Retrieve Tiller Information and assign to context 'query'
context['query'] = self.get_tiller_info(context)
# Retrieve Genesis Node IP and assign it to context 'genesis_ip'
context['genesis_ip'] = self.get_genesis_node_info(context)
# Armada API Call
# Armada Status
if self.action == 'armada_status':
@ -243,6 +246,16 @@ class ArmadaOperator(BaseOperator):
else:
raise AirflowException("Failed to retrieve Armada Releases")
@get_pod_port_ip('maas-rack')
def get_genesis_node_info(self, context, *args):
# Get IP and port information of Pods from context
k8s_pods_ip_port = context['pods_ip_port']
# The maas-rack pod has the same IP as the genesis node
# We will retieve that IP and return the value
return k8s_pods_ip_port['maas-rack'].get('ip')
def get_armada_yaml(self, context):
# Initialize Variables
genesis_node_ip = None
@ -253,7 +266,7 @@ class ArmadaOperator(BaseOperator):
# file name is fixed and will always be 'armada_site.yaml'. This file
# will always be under the osh directory. This will change in the near
# future when Armada is integrated with DeckHand.
genesis_node_ip = context['query'].get('tiller_host')
genesis_node_ip = context['genesis_ip']
# Form Endpoint
schema = 'http://'

View File

@ -173,7 +173,7 @@ class DryDockOperator(BaseOperator):
logging.info("All nodes deployed in MAAS")
logging.info("Wait for %d seconds before checking node state...",
int(cluster_join_check_backoff_time))
time.sleep(cluster_join_check_backoff_time)
time.sleep(int(cluster_join_check_backoff_time))
# Check that cluster join process is completed before declaring
# deploy_node as 'completed'. Set time out to 30 minutes and set

View File

@ -74,12 +74,22 @@ def get_pod_port_ip(*pods):
# Get pod port
logging.info("Retrieving %s Port", pod_name)
specs_dict = i.spec.containers[0].__dict__
ports_dict = specs_dict['_ports'][0].__dict__
pod_attr[pod_name]['port'] = (
ports_dict['_container_port'])
logging.info("%s Port is %s", pod_name,
pod_attr[pod_name]['port'])
# It is possible for a pod to have an IP with no
# port. For instance maas-rack takes on genesis
# node IP and has no port associated with it. We
# will assign the value 'None' to the port value
# in such cases.
try:
specs_dict = i.spec.containers[0].__dict__
ports_dict = specs_dict['_ports'][0].__dict__
pod_attr[pod_name]['port'] = (
ports_dict['_container_port'])
logging.info("%s Port is %s", pod_name,
pod_attr[pod_name]['port'])
except:
pod_attr[pod_name]['port'] = 'None'
logging.info("%s Port is None", pod_name)
# Update k8s_pods with new entry
k8s_pods.update(pod_attr)