Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds build url #360

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ Pipfile.lock
.tox
.coverage
coverage.xml
.coverage.*
.coverage.*
dags/.python-version
24 changes: 21 additions & 3 deletions dags/nocp/tasks/benchmarks/nocp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from os import environ
from os import getenv

from nocp.util import constants
from nocp.util import var_loader as nocp_var_loader
Expand All @@ -11,6 +12,7 @@
from airflow.models import Variable
from airflow.models import DAG
from airflow.utils.task_group import TaskGroup
from airflow.utils.helpers import build_airflow_url_with_query
from kubernetes.client import models as k8s


Expand All @@ -35,6 +37,7 @@ def __init__(self, app, dag, config: DagConfig, task_group="benchmarks"):
"ES_SERVER_BASELINE": self.es_server_baseline,
"ES_SERVER": var_loader.get_secret('elasticsearch'),
"GRAFANA_URL": var_loader.get_secret('grafana'),
"BUILD_URL": self._get_build_url(),
}
self.env.update(self.dag_config.dependencies)
if self.app == "ocm":
Expand All @@ -54,13 +57,13 @@ def __init__(self, app, dag, config: DagConfig, task_group="benchmarks"):

def get_benchmarks(self):
benchmarks = self._get_benchmarks(self.vars["benchmarks"])
return benchmarks
return benchmarks

def _git_name(self):
git_username = var_loader.get_git_user()
if git_username == 'cloud-bulldozer':
return f"perf-ci"
else:
else:
return f"{git_username}"

def _get_benchmarks(self, benchmarks):
Expand All @@ -70,7 +73,7 @@ def _get_benchmarks(self, benchmarks):
elif 'group' in benchmark:
with TaskGroup(benchmark['group'], prefix_group_id=False, dag=self.dag) as task_group:
benchmarks[index] = self._get_benchmarks(benchmark['benchmarks'])
else:
else:
benchmarks[index] = self._get_benchmarks(benchmark['benchmarks'])
return benchmarks

Expand Down Expand Up @@ -123,3 +126,18 @@ def _get_benchmark(self, benchmark):
self._add_cleaner(task, env)

return task

def _get_build_url(self):
dag_id = getenv("AIRFLOW_CTX_DAG_ID", default="")
task_id = getenv("AIRFLOW_CTX_TASK_ID", default="")
dag_execution_date = getenv("AIRFLOW_CTX_EXECUTION_DATE", default="")
dag_run_id = getenv("AIRFLOW_CTX_DAG_RUN_ID", default="")

query = {
"dag_id": dag_id,
"task_id": task_id,
"execution_date": dag_execution_date,
"dag_run_id": dag_run_id,
}

return build_airflow_url_with_query(query)
5 changes: 2 additions & 3 deletions dags/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import pytest
import json

from common.models.dag_config import DagConfig
from openshift_nightlies.models.release import OpenshiftRelease, BaremetalRelease
from openshift_nightlies.models.release import OpenshiftRelease


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -158,7 +157,7 @@ def _populate_task_dir(base_task_dir, task, platform=None):

def _populate_config_dir(base_config_dir, release: OpenshiftRelease, task):
overrides = {
"default": "override",
"default": "override",
"new_field": "merge"
}
task_dir = base_config_dir / task
Expand Down
Loading