From ec1763bb71a03049e15115b1c5acf3028b15044d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Jens=C3=A5s?= Date: Mon, 24 Nov 2025 23:41:55 +0100 Subject: [PATCH] [ci_nmstate] Check if kubeconfig file exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ci_nmstate role was failing during adoption deploy-infra jobs when cifmw_openshift_kubeconfig was defined but the file didn't exist yet. Root cause: ci-framework-jobs' adoption-uni-job-base uses variable_files_dirs to scan all YAML files in the scenario directory, including 05-tests.yaml which sets cifmw_openshift_kubeconfig. This has been the case since adoption jobs were introduced in October 2024. However, during the deploy-infra phase (before deploy-ocp), the OCP cluster and kubeconfig file don't exist yet. The issue was likely exposed by PR #3471 which changed how ansible_user_dir is evaluated, affecting how/when the kubeconfig path gets resolved. Fix: Add "cifmw_openshift_kubeconfig is exists" check to tasks that use the kubeconfig. The existing code already handles the skipped task gracefully via default([]) safeguards, treating all hosts as "unmanaged" when no k8s cluster is available (which is correct for infra creation). Fixes: OSPCIX-1122 Related: https://github.com/openstack-k8s-operators/ci-framework/pull/3471 Assisted-By: Claude Code/claude-4.5-sonnet Signed-off-by: Harald Jensås --- roles/ci_nmstate/tasks/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/roles/ci_nmstate/tasks/main.yml b/roles/ci_nmstate/tasks/main.yml index 79a0aedbd2..b9f980d737 100644 --- a/roles/ci_nmstate/tasks/main.yml +++ b/roles/ci_nmstate/tasks/main.yml @@ -54,7 +54,9 @@ label: "{{ item }}" - name: Get k8s nodes - when: cifmw_openshift_kubeconfig is defined + when: + - cifmw_openshift_kubeconfig is defined + - cifmw_openshift_kubeconfig is exists kubernetes.core.k8s_info: kubeconfig: "{{ cifmw_openshift_kubeconfig }}" api_key: "{{ cifmw_openshift_token | default(omit)}}" @@ -93,6 +95,7 @@ - name: Provision k8s workers with nmstate when: - cifmw_openshift_kubeconfig is defined + - cifmw_openshift_kubeconfig is exists - >- _cifmw_ci_nmstate_configs | dict2items | selectattr('key', 'in', _cifmw_ci_nmstate_k8s_hosts) |