From 92421694b08768a8c5d08c6817e4b5541b65f214 Mon Sep 17 00:00:00 2001 From: Roberto Alfieri Date: Fri, 24 Apr 2026 15:10:48 +0200 Subject: [PATCH] [multiple] Add per-node BMH label for deterministic node assignment When `preProvisioned: false`, the OSDPO's `OpenStackBaremetalSet` assigns BareMetalHost CRs to NodeSet nodes non-deterministically (OSPRH-10282). This causes hostname shuffling: a node provisioned from BMH `compute-0` may receive the hostname of `compute-2`, breaking services that depend on hostname correctness (e.g. Ceph `orch apply` fails with "hostname does not match expected hostname"). Fix by establishing a 1-to-1 mapping between BMH CRs and NodeSet nodes using per-node `bmhLabelSelector`: - `deploy_bmh` template: add a `nodeName` label to every BMH CR, set to the node's name (e.g. `nodeName: compute-0`). - `ci_gen_kustomize_values` common edpm-nodeset-values template: when `cifmw_edpm_deploy_pre_provisioned` is `false`, emit a per-node `bmhLabelSelector: {nodeName: }` so each NodeSet node selects its specific BMH by label. Pre-provisioned deployments are unaffected (the `bmhLabelSelector` is only emitted when `cifmw_edpm_deploy_pre_provisioned` is false, which defaults to true). Depends-On: https://github.com/openstack-k8s-operators/ci-framework/pull/3884 Depends-On: https://github.com/openstack-k8s-operators/architecture/pull/746 Related-to: ANVIL-108 Co-authored-by: Claude Signed-off-by: Roberto Alfieri --- .../templates/common/edpm-nodeset-values/values.yaml.j2 | 4 ++++ roles/deploy_bmh/template/bmh.yml.j2 | 1 + 2 files changed, 5 insertions(+) diff --git a/roles/ci_gen_kustomize_values/templates/common/edpm-nodeset-values/values.yaml.j2 b/roles/ci_gen_kustomize_values/templates/common/edpm-nodeset-values/values.yaml.j2 index b0110b530..e4b83344d 100644 --- a/roles/ci_gen_kustomize_values/templates/common/edpm-nodeset-values/values.yaml.j2 +++ b/roles/ci_gen_kustomize_values/templates/common/edpm-nodeset-values/values.yaml.j2 @@ -46,6 +46,10 @@ data: nodes: {% for instance in instances_names %} edpm-{{ instance }}: +{% if not (cifmw_edpm_deploy_pre_provisioned | default(true) | bool) %} + bmhLabelSelector: + nodeName: {{ instance }} +{% endif %} ansible: ansibleHost: {{ cifmw_networking_env_definition.instances[instance].networks.ctlplane[_ipv.ip_vX] }} hostName: {{ instance }} diff --git a/roles/deploy_bmh/template/bmh.yml.j2 b/roles/deploy_bmh/template/bmh.yml.j2 index 38fc047fa..c0d7c4483 100644 --- a/roles/deploy_bmh/template/bmh.yml.j2 +++ b/roles/deploy_bmh/template/bmh.yml.j2 @@ -11,6 +11,7 @@ metadata: labels: app: {{ node_data['label'] | default("openstack") }} workload: {{ node_name.split('-')[0] }} + nodeName: {{ node_name }} {% if 'extra_labels' in node_data %} {% for label,key in node_data['extra_labels'].items() %} {{ label }}: {{ key }}