From 20e5f7997cdf157c3f2b1a6c5d0143089953c11f Mon Sep 17 00:00:00 2001 From: Maor Friedman Date: Sun, 7 Apr 2024 09:53:57 +0300 Subject: [PATCH 1/2] qc/get/osd-component-versions commit sha instead of branch name --- tools/qontract_cli.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/qontract_cli.py b/tools/qontract_cli.py index 3d8203d8a7..48e0d630f2 100755 --- a/tools/qontract_cli.py +++ b/tools/qontract_cli.py @@ -68,6 +68,9 @@ ) from reconcile.gql_definitions.fragments.aus_organization import AUSOCMOrganization from reconcile.jenkins_job_builder import init_jjb +from reconcile.saas_auto_promotions_manager.integration import ( + QONTRACT_INTEGRATION as SAPM, +) from reconcile.slack_base import slackapi_from_queries from reconcile.status_board import StatusBoardExporterIntegration from reconcile.typed_queries.alerting_services_settings import get_alerting_services @@ -2570,6 +2573,7 @@ def cost_report(ctx): @get.command() @click.pass_context def osd_component_versions(ctx): + sapm_state = init_state(integration=SAPM).get("publisher-data.json") osd_environments = [ e["name"] for e in queries.get_environments() if e["product"]["name"] == "OSDv4" ] @@ -2580,6 +2584,12 @@ def osd_component_versions(ctx): for t in rt.targets: if t.namespace.environment.name not in osd_environments: continue + sapm_key = f'{sf.name}/{rt.name}/{t.name or "default"}/{t.namespace.cluster.name}/{t.namespace.name}' + sapm_data = sapm_state.get(sapm_key) + if sapm_data: + commit_sha = sapm_data["commit_sha"] + else: + commit_sha = t.ref item = { "environment": t.namespace.environment.name, "namespace": t.namespace.name, @@ -2587,7 +2597,7 @@ def osd_component_versions(ctx): "app": sf.app.name, "saas_file": sf.name, "resource_template": rt.name, - "ref": f"[{t.ref}]({rt.url}/blob/{t.ref}{rt.path})", + "ref": f"[{commit_sha}]({rt.url}/blob/{commit_sha}{rt.path})", } data.append(item) From abfa34638e98ef32a726df3f03f0540ec510ece6 Mon Sep 17 00:00:00 2001 From: Maor Friedman Date: Sun, 7 Apr 2024 10:42:09 +0300 Subject: [PATCH 2/2] add deployment state --- tools/qontract_cli.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/qontract_cli.py b/tools/qontract_cli.py index 48e0d630f2..0fb0a65d4a 100755 --- a/tools/qontract_cli.py +++ b/tools/qontract_cli.py @@ -2588,8 +2588,10 @@ def osd_component_versions(ctx): sapm_data = sapm_state.get(sapm_key) if sapm_data: commit_sha = sapm_data["commit_sha"] + deployment_state = sapm_data["deployment_state"] else: commit_sha = t.ref + deployment_state = "unknown" item = { "environment": t.namespace.environment.name, "namespace": t.namespace.name, @@ -2598,6 +2600,7 @@ def osd_component_versions(ctx): "saas_file": sf.name, "resource_template": rt.name, "ref": f"[{commit_sha}]({rt.url}/blob/{commit_sha}{rt.path})", + "deployment_state": deployment_state, } data.append(item) @@ -2609,6 +2612,7 @@ def osd_component_versions(ctx): "saas_file", "resource_template", "ref", + "deployment_state", ] print_output(ctx.obj["options"], data, columns)