Update deckHand_get_design Dag

This dag is likely going to be used by Shipyard in actions other
than 'deploy_site'.  Hence we should not be hard-coding values in
the dag as it limits its reusability, e.g. it is likely going to
be used in 'update_site' and in 'redeploy_server' as well.  Hence
there is a need to make use of the values that are passed into the
function instead.

This P.S. is meant to correct the current behavior.

Change-Id: Ia88e91dbb114c34530e3240f120df8c11325090b
This commit is contained in:
Anthony Lin 2017-10-09 00:43:36 +00:00
parent 457aa782ba
commit 28e112dfdd
1 changed files with 15 additions and 13 deletions

View File

@ -20,13 +20,6 @@ from airflow.operators.subdag_operator import SubDagOperator
# Location of shiyard.conf
config_path = '/usr/local/airflow/plugins/shipyard.conf'
# Define Variables
parent_dag = 'deploy_site'
child_dag = 'deploy_site.deckhand_get_design_version'
# Names used for sub-subdags in the deckhand subdag
DECKHAND_GET_DESIGN_VERSION_DAG_NAME = 'deckhand_get_design_version'
def get_design_version(parent_dag_name, child_dag_name, args):
'''
@ -36,12 +29,21 @@ def get_design_version(parent_dag_name, child_dag_name, args):
'{}.{}'.format(parent_dag_name, child_dag_name),
default_args=args)
# Note that in the event where the 'deploy_site' Action is
# triggered from Shipyard, the 'parent_dag_name' variable
# gets assigned with 'deploy_site.deckhand_get_design_version'.
# This is the name that we want to assign to the subdag so
# that we can reference it for xcom. The name of the main
# dag will be the front part of that value, i.e. 'deploy_site'.
# Hence we will extract the front part and assign it to main_dag.
# We will reuse this pattern for other Actions, e.g. update_site,
# redeploy_site as well.
operator = DeckhandOperator(
task_id=DECKHAND_GET_DESIGN_VERSION_DAG_NAME,
task_id=child_dag_name,
shipyard_conf=config_path,
action=DECKHAND_GET_DESIGN_VERSION_DAG_NAME,
main_dag_name=parent_dag,
sub_dag_name=child_dag,
action=child_dag_name,
main_dag_name=parent_dag_name[0:parent_dag_name.find('.')],
sub_dag_name=parent_dag_name,
dag=dag)
return dag
@ -57,9 +59,9 @@ def get_design_deckhand(parent_dag_name, child_dag_name, args):
deckhand_design = SubDagOperator(
subdag=get_design_version(dag.dag_id,
DECKHAND_GET_DESIGN_VERSION_DAG_NAME,
child_dag_name,
args),
task_id=DECKHAND_GET_DESIGN_VERSION_DAG_NAME,
task_id=child_dag_name,
dag=dag)
return dag