Browse Source

Merge "plugins: Add get_releases to Armada base operator"

changes/63/607063/7
Zuul 3 years ago
committed by Gerrit Code Review
parent
commit
e11c621a84
  1. 19
      src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_base_operator.py
  2. 17
      src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_get_releases.py

19
src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_base_operator.py

@ -20,6 +20,7 @@ from airflow.utils.decorators import apply_defaults
import armada.common.client as client
import armada.common.session as session
from armada.exceptions import api_exceptions as errors
try:
from get_k8s_pod_port_ip import get_pod_port_ip
@ -89,6 +90,11 @@ class ArmadaBaseOperator(UcpBaseOperator):
self.svc_token
)
# Retrieve Tiller Information
# TODO(@drewwalters96): This should be explicit. Refactor in
# conjunction with `get_pod_port_ip` decorator.
self.get_tiller_info(pods_ip_port={})
@staticmethod
def _init_armada_client(armada_svc_endpoint, svc_token):
@ -125,6 +131,19 @@ class ArmadaBaseOperator(UcpBaseOperator):
else:
raise AirflowException("Failed to set up Armada client!")
def get_releases(self):
"""Retrieve all deployed releases"""
try:
get_releases_resp = self.armada_client.get_releases(
query=self.query,
timeout=self.dc['armada.get_releases_timeout']
)
return get_releases_resp['releases']
except errors.ClientError as client_error:
# Dump logs from Armada pods
self.get_k8s_logs()
raise AirflowException(client_error)
@get_pod_port_ip('tiller', namespace='kube-system')
def get_tiller_info(self, pods_ip_port={}):

17
src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_get_releases.py

@ -21,7 +21,6 @@ try:
except ImportError:
from shipyard_airflow.plugins.armada_base_operator import \
ArmadaBaseOperator
from armada.exceptions import api_exceptions as errors
LOG = logging.getLogger(__name__)
@ -36,23 +35,9 @@ class ArmadaGetReleasesOperator(ArmadaBaseOperator):
"""
def do_execute(self):
# Retrieve Tiller Information
self.get_tiller_info(pods_ip_port={})
# Retrieve read timeout
timeout = self.dc['armada.get_releases_timeout']
# Retrieve Armada Releases after deployment
LOG.info("Retrieving Helm charts releases after deployment..")
try:
armada_get_releases = self.armada_client.get_releases(
self.query,
timeout=timeout)
except errors.ClientError as client_error:
raise AirflowException(client_error)
armada_get_releases = self.get_releases()
if armada_get_releases:
LOG.info("Successfully retrieved Helm charts releases")

Loading…
Cancel
Save