Skip to content

Schedule ephemeral volumes in the same zone/region as the machine#1509

Merged
gonzolino merged 2 commits into
ironcore-dev:mainfrom
gonzolino:fix/eph-vol-zone
Jul 13, 2026
Merged

Schedule ephemeral volumes in the same zone/region as the machine#1509
gonzolino merged 2 commits into
ironcore-dev:mainfrom
gonzolino:fix/eph-vol-zone

Conversation

@gonzolino

@gonzolino gonzolino commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

Propagate topology labels from machine to ephemeral volumes

Copy zone and region labels from MachinePoolSelector to VolumePoolSelector when creating ephemeral volumes, without overwriting labels already set on the volume.

This ensures ephemeral volumes are scheduled in the same zone/region as the machine they belong to, except if the user has specifically defined different topology labels.

Fixes #1497

Summary by CodeRabbit

  • New Features

    • Ephemeral volumes now inherit applicable zone and region settings from their machine pool configuration.
    • Existing volume-specific topology settings are preserved and take precedence over inherited values.
  • Bug Fixes

    • Improved ephemeral volume placement to ensure topology preferences are applied consistently.

@github-actions github-actions Bot added size/L bug Something isn't working labels Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@gonzolino, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 18 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 13cc51f3-60ca-46f6-9b0c-613f55f4e47c

📥 Commits

Reviewing files that changed from the base of the PR and between 4b9362b and 88fc206.

📒 Files selected for processing (2)
  • internal/controllers/compute/machine_ephemeralvolume_controller.go
  • internal/controllers/compute/machine_ephemeralvolume_controller_test.go
📝 Walkthrough

Walkthrough

Ephemeral volume creation now copies missing zone and region selectors from Machine.Spec.MachinePoolSelector into Volume.Spec.VolumePoolSelector, while preserving selectors defined by the volume template. Tests cover propagation and precedence.

Changes

Ephemeral volume topology

Layer / File(s) Summary
Topology selector copying
internal/controllers/compute/machine_ephemeralvolume_controller.go
Defines zone and region topology keys, copies missing values into the volume selector, and invokes the helper during ephemeral volume construction.
Topology propagation tests
internal/controllers/compute/machine_ephemeralvolume_controller_test.go
Verifies machine topology labels are propagated and template-defined topology values take precedence.

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

Sequence Diagram(s)

sequenceDiagram
  participant Machine
  participant Controller
  participant EphemeralVolume
  Machine->>Controller: provide MachinePoolSelector
  Controller->>EphemeralVolume: construct volume with template selector
  Controller->>EphemeralVolume: copy missing zone and region labels
  EphemeralVolume-->>Controller: retain template-defined selector values
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: scheduling ephemeral volumes in the same zone/region as the machine.
Description check ✅ Passed The description covers the proposed change and the linked fix, though it does not use the template's exact bullet formatting.
Linked Issues check ✅ Passed The change propagates machine topology labels to ephemeral volumes and preserves existing volume labels, matching issue #1497.
Out of Scope Changes check ✅ Passed The diff is narrowly focused on ephemeral volume topology propagation and related tests, with no clear out-of-scope additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

@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

🧹 Nitpick comments (2)
internal/controllers/compute/machine_ephemeralvolume_controller_test.go (2)

196-242: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Strengthen the precedence test by also verifying non-conflicting region propagation.

The test verifies that a user-specified zone (zone-b) takes precedence over the machine's zone (zone-a), but the machine only has a zone label. Adding a region label to the machine's MachinePoolSelector and asserting it propagates to the volume (while zone is still overridden) would cover the partial-override scenario where some topology labels are user-specified and others are propagated.

♻️ Proposed test enhancement
 			MachinePoolSelector: map[string]string{
-				"topology.ironcore.dev/zone": "zone-a",
+				"topology.ironcore.dev/zone":   "zone-a",
+				"topology.ironcore.dev/region": "region-1",
 			},
 	Eventually(Object(ephemVolume)).Should(SatisfyAll(
 		HaveField("Spec.VolumePoolSelector", HaveKeyWithValue("topology.ironcore.dev/zone", "zone-b")),
+		HaveField("Spec.VolumePoolSelector", HaveKeyWithValue("topology.ironcore.dev/region", "region-1")),
 	))
🤖 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 `@internal/controllers/compute/machine_ephemeralvolume_controller_test.go`
around lines 196 - 242, Strengthen the test in “should not overwrite
user-specified topology labels in ephemeral volume pool selector” by adding a
non-conflicting region label to the machine’s MachinePoolSelector, while
retaining the user-specified zone override in the volume template. Update the
Eventually assertion on Spec.VolumePoolSelector to verify both zone-b remains
unchanged and the machine’s region label is propagated.

149-242: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider using topology label constants instead of hardcoded strings.

The tests use literal strings "topology.ironcore.dev/zone" and "topology.ironcore.dev/region" instead of commonv1alpha1.TopologyLabelZone and commonv1alpha1.TopologyLabelRegion. Using the constants would keep tests in sync if the label keys ever change.

🤖 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 `@internal/controllers/compute/machine_ephemeralvolume_controller_test.go`
around lines 149 - 242, Replace the hardcoded topology label keys in the tests
for ephemeral volume selector propagation with commonv1alpha1.TopologyLabelZone
and commonv1alpha1.TopologyLabelRegion, including the machine selectors, volume
selectors, and HaveKeyWithValue assertions in both test cases.
🤖 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 `@internal/controllers/compute/machine_ephemeralvolume_controller.go`:
- Around line 68-83: Clone ephemeral.VolumeTemplate.Spec.VolumePoolSelector when
constructing the volume, matching the existing maps.Clone handling for
annotations, before passing it to copyTopologyLabels. Ensure the new volume owns
an independent map so copyTopologyLabels cannot mutate the shared template
selector.

---

Nitpick comments:
In `@internal/controllers/compute/machine_ephemeralvolume_controller_test.go`:
- Around line 196-242: Strengthen the test in “should not overwrite
user-specified topology labels in ephemeral volume pool selector” by adding a
non-conflicting region label to the machine’s MachinePoolSelector, while
retaining the user-specified zone override in the volume template. Update the
Eventually assertion on Spec.VolumePoolSelector to verify both zone-b remains
unchanged and the machine’s region label is propagated.
- Around line 149-242: Replace the hardcoded topology label keys in the tests
for ephemeral volume selector propagation with commonv1alpha1.TopologyLabelZone
and commonv1alpha1.TopologyLabelRegion, including the machine selectors, volume
selectors, and HaveKeyWithValue assertions in both test cases.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f01a1bf9-3899-4570-b0eb-906a705776d9

📥 Commits

Reviewing files that changed from the base of the PR and between 28effbb and 4b9362b.

📒 Files selected for processing (2)
  • internal/controllers/compute/machine_ephemeralvolume_controller.go
  • internal/controllers/compute/machine_ephemeralvolume_controller_test.go

Comment thread internal/controllers/compute/machine_ephemeralvolume_controller.go
Copy zone and region labels from `MachinePoolSelector` to
`VolumePoolSelector` when creating ephemeral volumes, without
overwriting labels already set on the volume.

This ensures ephemeral volumes are scheduled in the same zone/region as
the machine they belong to, except if the user has specifically defined
different topology labels.

Signed-off-by: Daniel Gonzalez Nothnagel <daniel.gonzalez.nothnagel@sap.com>
Signed-off-by: Daniel Gonzalez Nothnagel <daniel.gonzalez.nothnagel@sap.com>
@gonzolino gonzolino requested a review from maxmoehl July 10, 2026 14:48
@maxmoehl maxmoehl requested a review from a team July 13, 2026 10:43

@maxmoehl maxmoehl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This ensures ephemeral volumes are scheduled in the same zone/region as the machine they belong to, except if the user has specifically defined different topology labels.

An important caveat is that this does not cover the case where the user did not put any labels into the selector. In that case the volume and machine could still end up in separate zones, no?

Otherwise, this is a worthwhile improvement, thank you!

@lukasfrank lukasfrank left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@gonzolino gonzolino merged commit 3d76e18 into ironcore-dev:main Jul 13, 2026
11 checks passed
@gonzolino

Copy link
Copy Markdown
Contributor Author

An important caveat is that this does not cover the case where the user did not put any labels into the selector. In that case the volume and machine could still end up in separate zones, no?

Yes good point, this fix will only apply for situations were topology labels are given. I am not sure how to solve it for cases were we don't have them 🤔

@gonzolino gonzolino deleted the fix/eph-vol-zone branch July 13, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ephemeral Volumes end up in a different zone than the Machine

3 participants