Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cloudprofilesync/imageupdater.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func (iu *ImageUpdater) Update(ctx context.Context, cpSpec *gardenerv1beta1.Clou
}

for _, sourceImage := range sourceImages {
supportInPlaceUpdate := slices.Contains(sourceImage.Capabilities["feature"], USIFeature)
// Always write the full tag version (legacy path, safe for running Shoots).
if idx, exists := existingVersions[sourceImage.Version]; exists {
image.Versions[idx].Architectures = sourceImage.Architectures
Expand All @@ -103,6 +104,11 @@ func (iu *ImageUpdater) Update(ctx context.Context, cpSpec *gardenerv1beta1.Clou
},
Architectures: sourceImage.Architectures,
})
if supportInPlaceUpdate {
image.Versions[len(image.Versions)-1].InPlaceUpdates = &gardenerv1beta1.InPlaceUpdates{
Supported: supportInPlaceUpdate,
}
}
existingVersions[sourceImage.Version] = len(image.Versions) - 1
}
}
Expand All @@ -123,6 +129,11 @@ func (iu *ImageUpdater) Update(ctx context.Context, cpSpec *gardenerv1beta1.Clou
},
Architectures: slices.Clone(sourceImage.Architectures),
})
if supportInPlaceUpdate {
image.Versions[len(image.Versions)-1].InPlaceUpdates = &gardenerv1beta1.InPlaceUpdates{
Supported: supportInPlaceUpdate,
}
}
Comment thread
adziauho marked this conversation as resolved.
existingVersions[sourceImage.CleanVersion] = len(image.Versions) - 1
}
}
Expand Down
38 changes: 38 additions & 0 deletions cloudprofilesync/imageupdater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,25 @@
Expect(json.Unmarshal(cpSpec.ProviderConfig.Raw, &fromProvider)).To(Succeed())
Expect(fromProvider).To(Equal(mockSource.images))
})

It("reflect inplace update ability to machineimage", func(ctx SpecContext) {
Comment thread
adziauho marked this conversation as resolved.
Outdated
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",
}
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))

Check failure on line 243 in cloudprofilesync/imageupdater_test.go

View workflow job for this annotation

GitHub Actions / Checks

ginkgo-linter: wrong boolean assertion. Consider using `Expect(cpSpec.MachineImages[0].Versions[0].InPlaceUpdates.Supported).To(BeTrue())` instead (ginkgolinter)
})

})

Describe("flag ON (dual-write clean version)", func() {
Expand Down Expand Up @@ -318,5 +337,24 @@
Expect(cpSpec.MachineImages[0].Versions).To(HaveLen(1))
Expect(cpSpec.MachineImages[0].Versions[0].Version).To(Equal("1877.0.0"))
})

It("reflect inplace update ability to machineimage", func(ctx SpecContext) {
Comment thread
adziauho marked this conversation as resolved.
Outdated
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))

Check failure on line 357 in cloudprofilesync/imageupdater_test.go

View workflow job for this annotation

GitHub Actions / Checks

ginkgo-linter: wrong boolean assertion. Consider using `Expect(cpSpec.MachineImages[0].Versions[0].InPlaceUpdates.Supported).To(BeTrue())` instead (ginkgolinter)
})
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
})
})
30 changes: 23 additions & 7 deletions cloudprofilesync/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,31 @@
"oras.land/oras-go/v2/registry/remote/retry"
)

type Feature string

Comment thread
adziauho marked this conversation as resolved.
Outdated
const (
//ChostFeature represent having containerd

Check failure on line 24 in cloudprofilesync/source.go

View workflow job for this annotation

GitHub Actions / Checks

commentFormatting: put a space between `//` and comment text (gocritic)
ChostFeature = "chost"
//PXEFeature represent pxe boot build

Check failure on line 26 in cloudprofilesync/source.go

View workflow job for this annotation

GitHub Actions / Checks

commentFormatting: put a space between `//` and comment text (gocritic)
PXEFeature = "_pxe"
SCIFeature = "sci"
SCIBaseFeature = "scibase"
//CAPIFeature includes server, khost, and PXE; excludes SELinux and firewall

Check failure on line 30 in cloudprofilesync/source.go

View workflow job for this annotation

GitHub Actions / Checks

commentFormatting: put a space between `//` and comment text (gocritic)
CAPIFeature = "capi"
// USIFeature shows UEFI build
USIFeature = "_usi"
USIDevFeatrue = "_usidev"
)

// validFeatureValues is the allowlist of feature values extracted from the feature_set annotation.
var validFeatureValues = map[string]struct{}{
"chost": {},
"_pxe": {},
"sci": {},
"capi": {},
"scibase": {},
"_usi": {},
"_usidev": {},
ChostFeature: {},
PXEFeature: {},
SCIFeature: {},
SCIBaseFeature: {},
CAPIFeature: {},
USIFeature: {},
USIDevFeatrue: {},
}

func filterFeatureSet(featureSet string) []string {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cobaltcore-dev/cloud-profile-sync

go 1.26
go 1.26.2

require (
github.com/blang/semver/v4 v4.0.0
Expand Down
Loading