Skip to content

NO-ISSUE: Fix setArchitectureAndCheckStatus corrupting multi-label annotations - #6347

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
ptalgulk01:fix-set-architecture-annotation
Jul 30, 2026
Merged

NO-ISSUE: Fix setArchitectureAndCheckStatus corrupting multi-label annotations#6347
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
ptalgulk01:fix-set-architecture-annotation

Conversation

@ptalgulk01

@ptalgulk01 ptalgulk01 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Tests
    • Improved machine-set architecture test coverage to update architecture through capacity/autoscaler label annotations.
    • Added safer handling for comma-separated capacity label values to ensure correct annotation formatting.
    • Enhanced architecture normalization by supporting inputs both with and without the standard kubernetes.io/arch= prefix.
    • Improved parsing behavior to fail with a clearer error when the expected architecture label is missing.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@ptalgulk01: This pull request explicitly references no jira issue.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Walkthrough

The change adds JSON-safe autoscaler label patching to MachineSet, improves architecture label parsing, routes architecture updates through the helper, and updates boot image checks to normalize architecture labels before applying them.

Changes

Autoscaler architecture label handling

Layer / File(s) Summary
MachineSet label parsing and patching
test/extended-priv/machineset.go
Parses comma-separated architecture labels, reports missing architecture labels explicitly, and adds JSON-safe autoscaler label patching used by SetArchitecture.
Boot image architecture label integration
test/extended-priv/mco_bootimages.go
Normalizes architecture values to include kubernetes.io/arch= before applying and logging autoscaler labels.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: dkhater-redhat, yuqi-zhang, djoshy

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning The new helper has malformed assertion messages (%s/%s with one arg) and the progressing check reuses the wrong condition name, so failures won’t diagnose well. Fix the helper’s assertion strings to pass matching args and name each condition precisely; keep the existing timeouts and cleanup.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main fix: preventing SetArchitectureAndCheckStatus from corrupting multi-label autoscaler annotations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed Touched files only change helpers; all Ginkgo titles in mco_bootimages.go are static literals, with no dynamic data in It/Describe/Context/When names.
Microshift Test Compatibility ✅ Passed No new Ginkgo tests were added; the diff only changes MachineSet helper logic and an existing test helper, with no new MicroShift-unsupported APIs or missing guards.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo specs were added; the PR only changes machineset annotation helpers and an existing label-annotation test, with no multi-node/HA assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed Only test helpers for MachineSet annotations changed; no deployment, controller, affinity, selector, replica, or PDB scheduling logic was added.
Ote Binary Stdout Contract ✅ Passed No added stdout writes in main/init/suite setup; touched logging goes through logext to GinkgoWriter, not stdout.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Changed test only patches MachineSet annotations and checks MCO status; no IPv4-only parsing, hardcoded IPs, or external connectivity.
No-Weak-Crypto ✅ Passed Touched code only updates MachineSet label parsing/patching; no weak-crypto APIs, custom crypto, or secret/token comparisons were added.
Container-Privileges ✅ Passed Only Go test helpers changed; no manifests or pod specs were added, and no privileged/hostPID/hostNetwork/hostIPC/allowPrivilegeEscalation/SYS_ADMIN settings appear.
No-Sensitive-Data-In-Logs ✅ Passed New logs only emit autoscaler labels and MachineSet names; no passwords, tokens, PII, hostnames, or customer data were introduced.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/extended-priv/machineset.go`:
- Around line 714-717: Update SetArchAnnotation to JSON-encode labels with
encoding/json.Marshal before constructing the patch payload, and insert the
marshaled value rather than the raw string. Preserve the existing annotation
path and Patch call, and return any marshaling error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a41dea45-0c0c-419d-a86d-3bdb1c7c652d

📥 Commits

Reviewing files that changed from the base of the PR and between ceaa575 and 9a7fc21.

📒 Files selected for processing (2)
  • test/extended-priv/machineset.go
  • test/extended-priv/mco_bootimages.go

Comment thread test/extended-priv/machineset.go Outdated
Comment thread test/extended-priv/machineset.go Outdated
// SetArchAnnotation sets the raw capacity labels annotation for this MachineSet.
// Use this instead of SetArchitecture when the value contains multiple comma-separated
// labels (e.g. "kubernetes.io/arch=amd64,topology.ebs.csi.aws.com/zone=eu-central-1a").
func (ms MachineSet) SetArchAnnotation(labels string) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not actually setting the architecture, there are more things that we can set in this label.

Maybe SetAutoscalerLabels would be a better name?

Having SetArchAnnotation and SetArchitecture can be confusing.

SetArchitecture now should call SetArchAnnotation instead of duplicating the annotation name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@isabella-janssen

Copy link
Copy Markdown
Member

/test tls-pqc-readiness

Ignore this test, I'm just trying to show it's stable across PRs before making it required.

@ptalgulk01
ptalgulk01 force-pushed the fix-set-architecture-annotation branch from 9a7fc21 to f14e1e4 Compare July 30, 2026 07:01

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/extended-priv/machineset.go`:
- Around line 709-721: Update GetArchitecture to parse comma-separated
autoscaler label entries and pass only the value of the exact kubernetes.io/arch
label to architecture.FromString. Preserve existing behavior for single-label
annotations and ensure unrelated labels are not included in the architecture
value; alternatively, restrict SetAutoscalerLabels to single-label input if that
is the intended contract.
- Line 331: Update SetArchitecture to normalize its arch input before calling
SetAutoscalerLabels, avoiding unconditional addition of the kubernetes.io/arch=
prefix when the value already contains it. Preserve correctly formatted inputs,
including values with additional comma-separated labels, without producing a
duplicate prefix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b49cffed-8d43-425b-b271-053114a4236f

📥 Commits

Reviewing files that changed from the base of the PR and between 9a7fc21 and f14e1e4.

📒 Files selected for processing (2)
  • test/extended-priv/machineset.go
  • test/extended-priv/mco_bootimages.go

Comment thread test/extended-priv/machineset.go
Comment thread test/extended-priv/machineset.go
@ptalgulk01
ptalgulk01 force-pushed the fix-set-architecture-annotation branch from f14e1e4 to 92a24ce Compare July 30, 2026 09:00

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/extended-priv/mco_bootimages.go`:
- Around line 1055-1057: The autoscaler-label payload is exposed by the
description and logger calls around clonedMS.SetAutoscalerLabels(labels). Stop
interpolating labels into test output, and instead log only a redacted
confirmation or the specific architecture value while preserving the
label-setting operation and success assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b07d3809-6107-40ea-9f5e-4596f8c7c0ea

📥 Commits

Reviewing files that changed from the base of the PR and between f14e1e4 and 92a24ce.

📒 Files selected for processing (2)
  • test/extended-priv/machineset.go
  • test/extended-priv/mco_bootimages.go

Comment on lines +1055 to +1057
exutil.By(fmt.Sprintf("Set a %s architecture in the cloned machineset", labels))
o.Expect(clonedMS.SetAutoscalerLabels(labels)).To(o.Succeed(), "Error setting architecture %s in %s", labels, clonedMS)
logger.Infof("Architecture %s set in %s\n", labels, clonedMS)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Avoid emitting the raw autoscaler-label payload.

labels may contain arbitrary comma-separated labels, including values such as kubernetes.io/hostname=...; both calls currently write the full payload to test output. Log only a redacted confirmation or the architecture value.

Suggested change
-	exutil.By(fmt.Sprintf("Set a %s architecture in the cloned machineset", labels))
+	exutil.By("Set architecture labels in the cloned machineset")
 	o.Expect(clonedMS.SetAutoscalerLabels(labels)).To(o.Succeed(), "Error setting architecture %s in %s", labels, clonedMS)
-	logger.Infof("Architecture %s set in %s\n", labels, clonedMS)
+	logger.Infof("Architecture labels set in the cloned machineset")

As per coding guidelines, “Flag logging that may expose ... internal hostnames ... or customer data.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
exutil.By(fmt.Sprintf("Set a %s architecture in the cloned machineset", labels))
o.Expect(clonedMS.SetAutoscalerLabels(labels)).To(o.Succeed(), "Error setting architecture %s in %s", labels, clonedMS)
logger.Infof("Architecture %s set in %s\n", labels, clonedMS)
exutil.By("Set architecture labels in the cloned machineset")
o.Expect(clonedMS.SetAutoscalerLabels(labels)).To(o.Succeed(), "Error setting architecture %s in %s", labels, clonedMS)
logger.Infof("Architecture labels set in the cloned machineset")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/extended-priv/mco_bootimages.go` around lines 1055 - 1057, The
autoscaler-label payload is exposed by the description and logger calls around
clonedMS.SetAutoscalerLabels(labels). Stop interpolating labels into test
output, and instead log only a redacted confirmation or the specific
architecture value while preserving the label-setting operation and success
assertion.

Source: Coding guidelines

@sergiordlr

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 30, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification

No second-stage tests were triggered for this PR.

This can happen when:

  • The changed files don't match any pipeline_run_if_changed patterns
  • All files match pipeline_skip_if_only_changed patterns
  • No pipeline-controlled jobs are defined for the main branch

Use /test ? to see all available tests.

@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ptalgulk01, sergiordlr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [ptalgulk01,sergiordlr]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ptalgulk01

Copy link
Copy Markdown
Contributor Author

/verified later

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@ptalgulk01: /verified later <@username> requires at least one GitHub @username to be specified (it can be a comma delimited list). It indicates the engineer(s) that will be performing the verification. See https://docs.ci.openshift.org/docs/architecture/jira/#premerge-verification for more information.

Details

In response to this:

/verified later

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@ptalgulk01

Copy link
Copy Markdown
Contributor Author

/verified later @ptalgulk01

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@ptalgulk01: This PR has been marked to be verified later by @ptalgulk01.

Details

In response to this:

/verified later @ptalgulk01

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 30, 2026
@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@ptalgulk01: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot
openshift-merge-bot Bot merged commit 23687b4 into openshift:main Jul 30, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria verified-later

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants