def ReportDailySuccessful(task_instance, **kwargs):
    """Set this release as the candidate if it is the latest."""
    date = kwargs['execution_date']
    branch = istio_common_dag.GetSettingPython(task_instance, 'BRANCH')
    latest_run = float(
        istio_common_dag.GetVariableOrDefault(
            branch + 'latest_daily_timestamp', 0))

    timestamp = time.mktime(date.timetuple())
    logging.info(
        "Current run's timestamp: %s \n"
        "latest_daily's timestamp: %s", timestamp, latest_run)
    if timestamp >= latest_run:
        run_sha = task_instance.xcom_pull(task_ids='get_git_commit')
        latest_version = istio_common_dag.GetSettingPython(
            task_instance, 'VERSION')

        Variable.set(branch + '_latest_sha', run_sha)
        Variable.set(branch + '_latest_daily', latest_version)
        Variable.set(branch + '_latest_daily_timestamp', timestamp)

        logging.info('%s_latest_sha set to %s', branch, run_sha)
        logging.info('setting latest green daily of %s branch to: %s', branch,
                     run_sha)
        return 'tag_daily_gcr'
    return 'skip_tag_daily_gcr'
Exemple #2
0
def ReportDailySuccessful(task_instance, **kwargs):
    """Set this release as the candidate if it is the latest."""
    date = kwargs['execution_date']
    branch = istio_common_dag.GetSettingPython(task_instance, 'BRANCH')
    latest_run = float(
        istio_common_dag.GetVariableOrDefault(
            branch + 'latest_daily_timestamp', 0))

    timestamp = time.mktime(date.timetuple())
    logging.info(
        "Current run's timestamp: %s \n"
        "latest_daily's timestamp: %s", timestamp, latest_run)
def ReportMonthlySuccessful(task_instance, **kwargs):
    del kwargs
    version = istio_common_dag.GetSettingPython(task_instance, 'VERSION')
    try:
        match = re.match(r'([0-9])\.([0-9])\.([0-9]).*', version)
        major, minor, patch = match.group(1), match.group(2), match.group(3)
        Variable.set('major_version', major)
        Variable.set('released_version_minor', minor)
        Variable.set('released_version_patch', patch)
    except (IndexError, AttributeError):
        logging.error('Could not extract released version infomation. \n'
                      'Please set airflow version Variables manually.'
                      'After you are done hit Mark Success.')