fix(labels): merge cluster_template labels into sparse cluster.labels#1016
fix(labels): merge cluster_template labels into sparse cluster.labels#1016Rico Lin (ricolin) wants to merge 3 commits into
Conversation
…content guard Two independent fixes that surfaced while running the G2 bare-metal smoke test against PR #1015 + PR #1014. See #1015 for the full discussion; the README at notes/logs/ironic/mcapi-bm/README.md captures the end-to-end repro. F1 — `_decode_extra_files_label` accepts plain YAML/JSON in addition to base64 Operators using YAML manifests (Heat, Terraform, kubectl) typically have the platform handle base64 wrapping, so being forced to manually wrap the list a second time was a frequent foot-gun. The decoder now tries base64 first (the documented/recommended path) and falls back to plain YAML/JSON, with a single clear error message when neither parses. F2 — `_normalize_extra_file` rejects pre-encoded content that omits `encoding: base64` Previously, an entry with `content: <base64>` and no `encoding` field was silently re-encoded, landing on disk as a base64 string and breaking any later `bash <script>` step. A narrow heuristic now detects this case (canonical base64 charset, length >= 16, multiple of 4, decodes to valid UTF-8) and raises `InvalidParameterValue` with a hint pointing operators at the `encoding` field. Tests cover plain scripts, short strings, and multi-line content to confirm no false positives. (F3 — `fill_missing_labels_from_template` — was originally bundled here but has been split out into its own PR (#1016) against `main` so it can land independently of this PR's larger scope.) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…content guard Two independent fixes that surfaced while running the G2 bare-metal smoke test against PR #1015 + PR #1014. See #1015 for the full discussion; the README at notes/logs/ironic/mcapi-bm/README.md captures the end-to-end repro. F1 — `_decode_extra_files_label` accepts plain YAML/JSON in addition to base64 Operators using YAML manifests (Heat, Terraform, kubectl) typically have the platform handle base64 wrapping, so being forced to manually wrap the list a second time was a frequent foot-gun. The decoder now tries base64 first (the documented/recommended path) and falls back to plain YAML/JSON, with a single clear error message when neither parses. F2 — `_normalize_extra_file` rejects pre-encoded content that omits `encoding: base64` Previously, an entry with `content: <base64>` and no `encoding` field was silently re-encoded, landing on disk as a base64 string and breaking any later `bash <script>` step. A narrow heuristic now detects this case (canonical base64 charset, length >= 16, multiple of 4, decodes to valid UTF-8) and raises `InvalidParameterValue` with a hint pointing operators at the `encoding` field. Tests cover plain scripts, short strings, and multi-line content to confirm no false positives. (F3 — `fill_missing_labels_from_template` — was originally bundled here but has been split out into its own PR (#1016) against `main` so it can land independently of this PR's larger scope.) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: ricolin <rlin@vexxhost.com>
0569744 to
b7364ee
Compare
Test report (test env redacted)Scope: Env: Atmosphere AIO + 3-node BM emulator, kube image v1.34.7.
This was originally bundled inside #1015's commit |
|
recheck |
|
@codex[agent] review this PR |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback". |
Reviewed and did a local validation pass. |
|
To use Codex here, create a Codex account and connect to github. |
7209d3a to
8df5ba7
Compare
19de8c5 to
67a8535
Compare
Magnum's cluster create --labels path replaces the cluster_template labels instead of merging them into the cluster row. That can leave stored cluster.labels without template-derived keys such as kube_tag, which the Rust ClusterLabels deserializer expects on create and delete paths. Fill missing keys from labels_skipped first, then from cluster_template.labels, without overriding operator-provided cluster labels. Persist the completed labels on create so later status and monitor paths read the same label set from Magnum, and apply the same fallback before delete so existing sparse clusters can still be removed. Also tolerate early CAPI Cluster objects that do not have status.conditions yet while waiting for reconciliation. Signed-off-by: Rico Lin <rlin@vexxhost.com> Assisted-By: Codex <noreply@openai.com>
Cover the label fallback helper, including labels_skipped taking precedence over cluster_template.labels for missing keys. Add driver tests proving create persists the completed label set and both create and delete pass label-complete cluster objects to the Rust driver. Mock the MachineSet list used by nodegroup update tests so the unit suite keeps matching the requests made by current main. Signed-off-by: Rico Lin <rlin@vexxhost.com> Assisted-By: Codex <noreply@openai.com>
The tox unit environment installs its own deps instead of the pyproject dev dependency group. Add lark so the Magnum imports used by the unit tests are available, and pin setuptools below the pkg_resources removal boundary used by current Magnum dependencies. Signed-off-by: Rico Lin <rlin@vexxhost.com> Assisted-By: Codex <noreply@openai.com>
5ac4c31 to
bfdcc2c
Compare
Summary
Magnum
cluster create --labelsreplaces, rather than merges, cluster-template labels. When an operator creates a cluster with sparse custom labels, the stored cluster row can miss labels required by the RustClusterLabelsextractor, such askube_tag.This PR fills those missing template-derived labels before the Rust create/delete paths and persists the completed label dict on create.
Fix
utils.fill_missing_labels_from_template(cluster)to fill missing labels without overriding user-provided cluster labels.cluster.labels_skippedbeforecluster.cluster_template.labels, matching Magnum's stored representation for template-only labels on sparse-label creates.Clusterobjects that do not yet havestatus.conditionsduring early reconciliation.This PR is rebased on current
main, which already includes PR #1064.Repro
kube_tag,fixed_subnet_cidr, andoctavia_provider.openstack coe cluster create --labels audit_log_enabled=truewhile omitting those template labels.KeyError: 'kube_tag', especially in status/health monitor or delete paths.Validation
Previously validated on Atmosphere main and stable AIOs with the equivalent sparse-label/status-condition fixes:
labels_skippedfirst, then template labelsstatus.conditionsproduced an empty status map instead ofKeyErrorNotes
1930573alongside unrelatedextra_cloud_initfixes; split out here so the label fallback can land independently.Signed-off-by: Rico Lin rlin@vexxhost.com