Skip to content

Commit

Permalink
Move the enableCommonBootImageImport field
Browse files Browse the repository at this point in the history
Deprecated the `spec.featureGates.enableCommonBootImageImport`
field. Added the `spec.enableCommonBootImageImport` field instead.

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
  • Loading branch information
nunnatsa committed Dec 3, 2024
1 parent 0bd61aa commit 6a642ba
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 102 deletions.
16 changes: 12 additions & 4 deletions api/v1beta1/hyperconverged_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type HyperConvergedSpec struct {

// featureGates is a map of feature gate flags. Setting a flag to `true` will enable
// the feature. Setting `false` or removing the feature gate, disables the feature.
// +kubebuilder:default={"downwardMetrics": false, "enableCommonBootImageImport": true, "deployVmConsoleProxy": false, "deployKubeSecondaryDNS": false, "deployKubevirtIpamController": false, "disableMDevConfiguration": false, "persistentReservation": false, "autoResourceLimits": false, "enableApplicationAwareQuota": false, "primaryUserDefinedNetworkBinding": false}
// +kubebuilder:default={"downwardMetrics": false, "deployVmConsoleProxy": false, "deployKubeSecondaryDNS": false, "deployKubevirtIpamController": false, "disableMDevConfiguration": false, "persistentReservation": false, "autoResourceLimits": false, "enableApplicationAwareQuota": false, "primaryUserDefinedNetworkBinding": false}
// +optional
FeatureGates HyperConvergedFeatureGates `json:"featureGates,omitempty"`

Expand Down Expand Up @@ -243,6 +243,15 @@ type HyperConvergedSpec struct {
// +default={"memoryOvercommitPercentage": 100}
// +optional
HigherWorkloadDensity *HigherWorkloadDensityConfiguration `json:"higherWorkloadDensity,omitempty"`

// Opt-in to automatic delivery/updates of the common data import cron templates.
// There are two sources for the data import cron templates: hard coded list of common templates, and custom
// templates that can be added to the dataImportCronTemplates field. This feature gates only control the common
// templates. It is possible to use custom templates by adding them to the dataImportCronTemplates field.
// +optional
// +kubebuilder:default=true
// +default=true
EnableCommonBootImageImport *bool `json:"enableCommonBootImageImport,omitempty"`
}

// CertRotateConfigCA contains the tunables for TLS certificates.
Expand Down Expand Up @@ -414,8 +423,7 @@ type HyperConvergedFeatureGates struct {
// templates that can be added to the dataImportCronTemplates field. This feature gates only control the common
// templates. It is possible to use custom templates by adding them to the dataImportCronTemplates field.
// +optional
// +kubebuilder:default=true
// +default=true
// Deprecated: use spec.enableCommonBootImageImport instead
EnableCommonBootImageImport *bool `json:"enableCommonBootImageImport,omitempty"`

// deploy VM console proxy resources in SSP operator
Expand Down Expand Up @@ -842,7 +850,7 @@ type HyperConverged struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// +kubebuilder:default={"certConfig": {"ca": {"duration": "48h0m0s", "renewBefore": "24h0m0s"}, "server": {"duration": "24h0m0s", "renewBefore": "12h0m0s"}},"featureGates": {"downwardMetrics": false, "enableCommonBootImageImport": true, "deployVmConsoleProxy": false, "deployKubeSecondaryDNS": false, "deployKubevirtIpamController": false, "disableMDevConfiguration": false, "persistentReservation": false, "autoResourceLimits": false, "enableApplicationAwareQuota": false, "primaryUserDefinedNetworkBinding": false}, "liveMigrationConfig": {"completionTimeoutPerGiB": 800, "parallelMigrationsPerCluster": 5, "parallelOutboundMigrationsPerNode": 2, "progressTimeout": 150, "allowAutoConverge": false, "allowPostCopy": false}, "resourceRequirements": {"vmiCPUAllocationRatio": 10}, "uninstallStrategy": "BlockUninstallIfWorkloadsExist", "virtualMachineOptions": {"disableFreePageReporting": false, "disableSerialConsoleLog": true}}
// +kubebuilder:default={"certConfig": {"ca": {"duration": "48h0m0s", "renewBefore": "24h0m0s"}, "server": {"duration": "24h0m0s", "renewBefore": "12h0m0s"}},"featureGates": {"downwardMetrics": false, "deployVmConsoleProxy": false, "deployKubeSecondaryDNS": false, "deployKubevirtIpamController": false, "disableMDevConfiguration": false, "persistentReservation": false, "autoResourceLimits": false, "enableApplicationAwareQuota": false, "primaryUserDefinedNetworkBinding": false}, "liveMigrationConfig": {"completionTimeoutPerGiB": 800, "parallelMigrationsPerCluster": 5, "parallelOutboundMigrationsPerNode": 2, "progressTimeout": 150, "allowAutoConverge": false, "allowPostCopy": false}, "resourceRequirements": {"vmiCPUAllocationRatio": 10}, "uninstallStrategy": "BlockUninstallIfWorkloadsExist", "virtualMachineOptions": {"disableFreePageReporting": false, "disableSerialConsoleLog": true}, "enableCommonBootImageImport": true}
// +optional
Spec HyperConvergedSpec `json:"spec,omitempty"`
Status HyperConvergedStatus `json:"status,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions api/v1beta1/zz_generated.defaults.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions api/v1beta1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 31 additions & 1 deletion assets/upgradePatches.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,37 @@
{
"op": "replace",
"path": "/spec/virtualMachineOptions/disableFreePageReporting",
"value": false
"value": false
}
],
"jsonPatchApplyOptions": {
"allowMissingPathOnRemove": true
}
},
{
"semverRange": "<1.15.0",
"jsonPatch": [
{
"op": "test",
"path": "/spec/featureGates/enableCommonBootImageImport",
"value": false
},
{
"op": "replace",
"path": "/spec/enableCommonBootImageImport",
"value": false
}
],
"jsonPatchApplyOptions": {
"allowMissingPathOnRemove": true
}
},
{
"semverRange": "<1.15.0",
"jsonPatch": [
{
"op": "remove",
"path": "/spec/featureGates/enableCommonBootImageImport"
}
],
"jsonPatchApplyOptions": {
Expand Down
13 changes: 10 additions & 3 deletions config/crd/bases/hco.kubevirt.io_hyperconvergeds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ spec:
server:
duration: 24h0m0s
renewBefore: 12h0m0s
enableCommonBootImageImport: true
featureGates:
autoResourceLimits: false
deployKubeSecondaryDNS: false
Expand All @@ -64,7 +65,6 @@ spec:
disableMDevConfiguration: false
downwardMetrics: false
enableApplicationAwareQuota: false
enableCommonBootImageImport: true
persistentReservation: false
primaryUserDefinedNetworkBinding: false
liveMigrationConfig:
Expand Down Expand Up @@ -1018,6 +1018,14 @@ spec:
Default RuntimeClass can be changed when kubevirt is running, existing VMIs are not impacted till
the next restart/live-migration when they are eventually going to consume the new default RuntimeClass.
type: string
enableCommonBootImageImport:
default: true
description: |-
Opt-in to automatic delivery/updates of the common data import cron templates.
There are two sources for the data import cron templates: hard coded list of common templates, and custom
templates that can be added to the dataImportCronTemplates field. This feature gates only control the common
templates. It is possible to use custom templates by adding them to the dataImportCronTemplates field.
type: boolean
evictionStrategy:
description: |-
EvictionStrategy defines at the cluster level if the VirtualMachineInstance should be
Expand All @@ -1044,7 +1052,6 @@ spec:
disableMDevConfiguration: false
downwardMetrics: false
enableApplicationAwareQuota: false
enableCommonBootImageImport: true
persistentReservation: false
primaryUserDefinedNetworkBinding: false
description: |-
Expand Down Expand Up @@ -1097,12 +1104,12 @@ spec:
Application Aware Quota feature
type: boolean
enableCommonBootImageImport:
default: true
description: |-
Opt-in to automatic delivery/updates of the common data import cron templates.
There are two sources for the data import cron templates: hard coded list of common templates, and custom
templates that can be added to the dataImportCronTemplates field. This feature gates only control the common
templates. It is possible to use custom templates by adding them to the dataImportCronTemplates field.
Deprecated: use spec.enableCommonBootImageImport instead
type: boolean
persistentReservation:
default: false
Expand Down
6 changes: 3 additions & 3 deletions controllers/operands/imageStream.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

hcov1beta1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1beta1"
"github.com/kubevirt/hyperconverged-cluster-operator/controllers/common"
"github.com/kubevirt/hyperconverged-cluster-operator/pkg/boolean"
"github.com/kubevirt/hyperconverged-cluster-operator/pkg/util"
)

Expand All @@ -40,9 +41,8 @@ type imageStreamOperand struct {
}

func (iso imageStreamOperand) ensure(req *common.HcoRequest) *EnsureResult {
if req.Instance.Spec.FeatureGates.EnableCommonBootImageImport != nil && *req.Instance.Spec.FeatureGates.EnableCommonBootImageImport {
// if the FG is set, make sure the imageStream is in place and up-to-date

// if the EnableCommonBootImageImport field is set, make sure the imageStream is in place and up-to-date
if boolean.IsTrue(req.Instance.Spec.EnableCommonBootImageImport) {
if result := iso.checkCustomNamespace(req); result != nil {
return result
}
Expand Down
38 changes: 19 additions & 19 deletions controllers/operands/imageStream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var _ = Describe("imageStream tests", func() {

Context("test imageStreamHandler", func() {
It("should not create the ImageStream resource if the FG is not set", func() {
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(false)
hco.Spec.EnableCommonBootImageImport = ptr.To(false)

getImageStreamFileLocation = func() string {
return testFilesLocation
Expand All @@ -69,7 +69,7 @@ var _ = Describe("imageStream tests", func() {
})

It("should delete the ImageStream resource if the FG is not set", func() {
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(false)
hco.Spec.EnableCommonBootImageImport = ptr.To(false)

getImageStreamFileLocation = func() string {
return testFilesLocation
Expand Down Expand Up @@ -137,7 +137,7 @@ var _ = Describe("imageStream tests", func() {

hcoNamespace := commontestutils.NewHcoNamespace()
hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)
eventEmitter := commontestutils.NewEventEmitterMock()
ci := commontestutils.ClusterInfoMock{}
cli := commontestutils.InitClient([]client.Object{hcoNamespace, hco, ci.GetCSV()})
Expand All @@ -163,7 +163,7 @@ var _ = Describe("imageStream tests", func() {

By("Run again, this time when the FG is false")
eventEmitter.Reset()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(false)
hco.Spec.EnableCommonBootImageImport = ptr.To(false)
req = commontestutils.NewReq(hco)
Expect(handler.Ensure(req)).To(Succeed())

Expand Down Expand Up @@ -229,7 +229,7 @@ var _ = Describe("imageStream tests", func() {
}

hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)
cli := commontestutils.InitClient([]client.Object{hco})
handlers, err := getImageStreamHandlers(logger, cli, schemeForTest, hco)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -280,7 +280,7 @@ var _ = Describe("imageStream tests", func() {
Expect(imageStreamNames).To(ContainElement("test-image-stream"))

hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)
By("apply the ImageStream CRs", func() {
req := commontestutils.NewReq(hco)
res := handlers[0].ensure(req)
Expand Down Expand Up @@ -344,7 +344,7 @@ var _ = Describe("imageStream tests", func() {
Expect(imageStreamNames).To(ContainElement("test-image-stream"))

hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)

By("apply the ImageStream CRs", func() {
req := commontestutils.NewReq(hco)
Expand Down Expand Up @@ -417,7 +417,7 @@ var _ = Describe("imageStream tests", func() {
Expect(imageStreamNames).To(ContainElement("test-image-stream"))

hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)

By("apply the ImageStream CRs", func() {
req := commontestutils.NewReq(hco)
Expand Down Expand Up @@ -486,7 +486,7 @@ var _ = Describe("imageStream tests", func() {
Expect(imageStreamNames).To(ContainElement("test-image-stream"))

hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)

By("apply the ImageStream CRs", func() {
req := commontestutils.NewReq(hco)
Expand Down Expand Up @@ -555,7 +555,7 @@ var _ = Describe("imageStream tests", func() {
Expect(imageStreamNames).To(ContainElement("test-image-stream"))

hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)

By("apply the ImageStream CRs", func() {
req := commontestutils.NewReq(hco)
Expand Down Expand Up @@ -625,7 +625,7 @@ var _ = Describe("imageStream tests", func() {
Expect(imageStreamNames).To(ContainElement("test-image-stream"))

hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)

By("apply the ImageStream CRs", func() {
req := commontestutils.NewReq(hco)
Expand Down Expand Up @@ -702,7 +702,7 @@ var _ = Describe("imageStream tests", func() {
Expect(imageStreamNames).To(ContainElement("test-image-stream"))

hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)

By("apply the ImageStream CRs", func() {
req := commontestutils.NewReq(hco)
Expand Down Expand Up @@ -753,7 +753,7 @@ var _ = Describe("imageStream tests", func() {
}

hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.CommonBootImageNamespace = ptr.To(customNS)

cli := commontestutils.InitClient([]client.Object{hco})
Expand Down Expand Up @@ -781,7 +781,7 @@ var _ = Describe("imageStream tests", func() {

By("create imagestream in the default namespace")
hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)
cli := commontestutils.InitClient([]client.Object{hco})
handlers, err := getImageStreamHandlers(logger, cli, schemeForTest, hco)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -804,7 +804,7 @@ var _ = Describe("imageStream tests", func() {

By("replace the image stream with a new one in the custom namespace")
hco = commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.CommonBootImageNamespace = ptr.To(customNS)
Expect(objectreferencesv1.SetObjectReference(&hco.Status.RelatedObjects, *ref)).To(Succeed())

Expand Down Expand Up @@ -835,7 +835,7 @@ var _ = Describe("imageStream tests", func() {

By("create imagestream in a custom namespace")
hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.CommonBootImageNamespace = ptr.To(customNS)

cli := commontestutils.InitClient([]client.Object{hco})
Expand All @@ -860,7 +860,7 @@ var _ = Describe("imageStream tests", func() {

By("replace the image stream with a new one in the default namespace")
hco = commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)
Expect(objectreferencesv1.SetObjectReference(&hco.Status.RelatedObjects, *ref)).To(Succeed())

req = commontestutils.NewReq(hco)
Expand Down Expand Up @@ -890,7 +890,7 @@ var _ = Describe("imageStream tests", func() {

By("create imagestream in a custom namespace")
hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.CommonBootImageNamespace = ptr.To(customNS)

cli := commontestutils.InitClient([]client.Object{hco})
Expand All @@ -915,7 +915,7 @@ var _ = Describe("imageStream tests", func() {

By("replace the image stream with a new one in another custom namespace")
hco = commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.EnableCommonBootImageImport = ptr.To(true)
hco.Spec.CommonBootImageNamespace = ptr.To(customNS + "1")
Expect(objectreferencesv1.SetObjectReference(&hco.Status.RelatedObjects, *ref)).To(Succeed())

Expand Down
Loading

0 comments on commit 6a642ba

Please sign in to comment.