Skip to content

support GEP-31 in place update#38

Open
adziauho wants to merge 1 commit into
cobaltcore-dev:masterfrom
adziauho:support-GEP-31-in-place-update
Open

support GEP-31 in place update#38
adziauho wants to merge 1 commit into
cobaltcore-dev:masterfrom
adziauho:support-GEP-31-in-place-update

Conversation

@adziauho

@adziauho adziauho commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added automatic detection and reporting of in-place update capabilities for machine images based on image features.
  • Chores

    • Updated Go toolchain to version 1.26.2.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Exports a Feature string type and named constants in source.go, replacing hard-coded literals in the validFeatureValues allowlist. In ImageUpdater.Update, computes a supportInPlaceUpdate flag by checking whether the source image's Capabilities["feature"] contains USIFeature, and sets InPlaceUpdates{Supported: true} on newly appended MachineImageVersion entries for both the legacy/tag and clean-version code paths. Two Ginkgo tests verify this behavior. The go toolchain directive is bumped to 1.26.2.

Changes

USIFeature In-Place Update Support

Layer / File(s) Summary
Exported Feature type and constants
cloudprofilesync/source.go
Introduces exported Feature string type and named constants (ChostFeature, PXEFeature, SCIFeature, SCIBaseFeature, CAPIFeature, USIFeature, USIDevFeatrue), replacing inline string literals in the validFeatureValues allowlist map.
InPlaceUpdates flag on MachineImageVersion
cloudprofilesync/imageupdater.go
Computes supportInPlaceUpdate by checking Capabilities["feature"] for USIFeature, then conditionally sets InPlaceUpdates{Supported: true} on newly appended MachineImageVersion entries in both the legacy/tag and clean-version paths.
Tests for InPlaceUpdates.Supported
cloudprofilesync/imageupdater_test.go
Adds two Ginkgo It cases (one under flag OFF, one under flag ON with EnableCapabilities: true) asserting InPlaceUpdates.Supported == true when the source image carries USIFeature in its capabilities.

Go Toolchain Version Bump

Layer / File(s) Summary
go.mod toolchain bump
go.mod
Updates the go directive from 1.26 to 1.26.2.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • cobaltcore-dev/cloud-profile-sync#30: Directly related — introduces the feature_set/capabilities support that populates the Capabilities["feature"] values that this PR reads to derive USIFeature-based InPlaceUpdates.Supported.

Suggested reviewers

  • anton-paulovich
  • defo89
  • valeryia-hurynovich

Poem

🐇 Hop, hop, the rabbit declares,
A feature flag floats through the air!
USIFeature found in the set,
InPlaceUpdates — supported, you bet!
Clean versions and tags, both get the flag,
No more hard-coded string in the bag. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'support GEP-31 in place update' directly relates to the main changes which implement in-place update capability detection based on USIFeature, aligning with the PR's core objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cloudprofilesync/imageupdater.go (1)

91-93: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Existing versions are not reconciled for InPlaceUpdates.

Line 89 computes supportInPlaceUpdate, but existing-version paths only patch architectures. If a version already exists, InPlaceUpdates stays stale (never added/removed), so spec can drift from source capabilities.

Proposed fix pattern
 if idx, exists := existingVersions[sourceImage.Version]; exists {
 	image.Versions[idx].Architectures = sourceImage.Architectures
+	if supportInPlaceUpdate {
+		image.Versions[idx].InPlaceUpdates = &gardenerv1beta1.InPlaceUpdates{Supported: true}
+	} else {
+		image.Versions[idx].InPlaceUpdates = nil
+	}
 } else {
   ...
 }
@@
 if idx, exists := existingVersions[sourceImage.CleanVersion]; exists {
 	existing := &image.Versions[idx]
 	for _, arch := range sourceImage.Architectures {
 		if !slices.Contains(existing.Architectures, arch) {
 			existing.Architectures = append(existing.Architectures, arch)
 		}
 	}
+	if supportInPlaceUpdate {
+		existing.InPlaceUpdates = &gardenerv1beta1.InPlaceUpdates{Supported: true}
+	} else {
+		existing.InPlaceUpdates = nil
+	}
 } else {
   ...
 }

Also applies to: 118-124

🤖 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 `@cloudprofilesync/imageupdater.go` around lines 91 - 93, When an existing
version is found in the existingVersions map within the block where `if idx,
exists := existingVersions[sourceImage.Version]; exists`, only the Architectures
field is being patched but the InPlaceUpdates field is not being reconciled. The
supportInPlaceUpdate variable that was computed should also be used to update
the InPlaceUpdates field of the existing version to prevent it from drifting
from source capabilities. Apply this same reconciliation pattern to both
occurrences of this existing version update logic.
🧹 Nitpick comments (1)
cloudprofilesync/source.go (1)

34-35: ⚡ Quick win

Rename misspelled exported constant before it spreads.

USIDevFeatrue at Line 34 is typoed (should be USIDevFeature). Since it is exported, this will leak a misspelled API name into consumers and tests.

Proposed fix
-	USIDevFeatrue = "_usidev"
+	USIDevFeature = "_usidev"
@@
-	USIDevFeatrue:  {},
+	USIDevFeature:  {},

Also applies to: 45-45

🤖 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 `@cloudprofilesync/source.go` around lines 34 - 35, The exported constant
USIDevFeatrue contains a typo (should be USIDevFeature). Rename this constant to
the correct spelling USIDevFeature. Since this constant is exported and appears
in multiple locations (including line 45 as noted), search for all usages of the
misspelled constant name USIDevFeatrue throughout the codebase and update them
to use the corrected spelling USIDevFeature to ensure consistency across all
references.
🤖 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 `@cloudprofilesync/imageupdater_test.go`:
- Around line 341-358: The test case at the It block for "reflect inplace update
ability to machineimage" needs to be extended to cover the clean-version path.
Modify the mockSource.images SourceImage to include a CleanVersion field set to
a different value than the Version field (e.g., "1.0" while Version is "1.0.0").
After calling updater.Update and verifying the first version entry, add an
additional assertion to check that the clean-version entry also has
InPlaceUpdates.Supported set to true, ensuring the test exercises both the
legacy append path and the new clean-version path in ImageUpdater.Update.

---

Outside diff comments:
In `@cloudprofilesync/imageupdater.go`:
- Around line 91-93: When an existing version is found in the existingVersions
map within the block where `if idx, exists :=
existingVersions[sourceImage.Version]; exists`, only the Architectures field is
being patched but the InPlaceUpdates field is not being reconciled. The
supportInPlaceUpdate variable that was computed should also be used to update
the InPlaceUpdates field of the existing version to prevent it from drifting
from source capabilities. Apply this same reconciliation pattern to both
occurrences of this existing version update logic.

---

Nitpick comments:
In `@cloudprofilesync/source.go`:
- Around line 34-35: The exported constant USIDevFeatrue contains a typo (should
be USIDevFeature). Rename this constant to the correct spelling USIDevFeature.
Since this constant is exported and appears in multiple locations (including
line 45 as noted), search for all usages of the misspelled constant name
USIDevFeatrue throughout the codebase and update them to use the corrected
spelling USIDevFeature to ensure consistency across all references.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: dca6ed2c-0edb-47dc-a74f-5d5c785a04d4

📥 Commits

Reviewing files that changed from the base of the PR and between d69a5c1 and afe7698.

📒 Files selected for processing (4)
  • cloudprofilesync/imageupdater.go
  • cloudprofilesync/imageupdater_test.go
  • cloudprofilesync/source.go
  • go.mod

Comment on lines +341 to +358
It("reflect inplace update ability to machineimage", func(ctx SpecContext) {
mockSource.images = []cloudprofilesync.SourceImage{{
Version: "1.0.0",
Architectures: []string{"amd64"},
Capabilities: map[string]gardencorev1beta1.CapabilityValues{"feature": {cloudprofilesync.USIFeature}}},
}
updater := cloudprofilesync.ImageUpdater{
Log: logr.Discard(),
Source: &mockSource,
ImageName: "test",
EnableCapabilities: true,
}
var cpSpec gardencorev1beta1.CloudProfileSpec
Expect(updater.Update(ctx, &cpSpec)).To(Succeed())
Expect(cpSpec.MachineImages[0].Versions).To(HaveLen(1))
Expect(cpSpec.MachineImages[0].Versions[0].Version).To(Equal("1.0.0"))
Expect(cpSpec.MachineImages[0].Versions[0].InPlaceUpdates.Supported).To(Equal(true))
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Flag-ON test does not cover the clean-version branch.

This case sets EnableCapabilities: true but omits CleanVersion, so it only exercises the legacy append path again. It misses the new clean-version path at ImageUpdater.Update Lines 126-136.

Please add/adjust this test to set CleanVersion different from Version and assert InPlaceUpdates.Supported on the clean-version entry too.

🤖 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 `@cloudprofilesync/imageupdater_test.go` around lines 341 - 358, The test case
at the It block for "reflect inplace update ability to machineimage" needs to be
extended to cover the clean-version path. Modify the mockSource.images
SourceImage to include a CleanVersion field set to a different value than the
Version field (e.g., "1.0" while Version is "1.0.0"). After calling
updater.Update and verifying the first version entry, add an additional
assertion to check that the clean-version entry also has
InPlaceUpdates.Supported set to true, ensuring the test exercises both the
legacy append path and the new clean-version path in ImageUpdater.Update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant