-
Notifications
You must be signed in to change notification settings - Fork 169
Deprecate disableMDevConfiguration in favor of mediatedDevicesConfiguration.enabled #4057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9616918
7664ec0
277d9b8
53a5ac7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,7 +67,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, "deployKubeSecondaryDNS": false, "disableMDevConfiguration": false, "persistentReservation": false, "enableMultiArchBootImageImport": false, "decentralizedLiveMigration": true, "declarativeHotplugVolumes": false, "videoConfig": true, "objectGraph": false, "incrementalBackup": false} | ||||||||||
| // +kubebuilder:default={"downwardMetrics": false, "deployKubeSecondaryDNS": false, "persistentReservation": false, "enableMultiArchBootImageImport": false, "decentralizedLiveMigration": true, "declarativeHotplugVolumes": false, "videoConfig": true, "objectGraph": false, "incrementalBackup": false} | ||||||||||
| // +optional | ||||||||||
| FeatureGates HyperConvergedFeatureGates `json:"featureGates,omitempty"` | ||||||||||
|
|
||||||||||
|
|
@@ -466,10 +466,7 @@ type HyperConvergedFeatureGates struct { | |||||||||
| // Deprecated: // Deprecated: This field is ignored and will be removed on the next version of the API. | ||||||||||
| NonRoot *bool `json:"nonRoot,omitempty"` | ||||||||||
|
|
||||||||||
| // Disable mediated devices handling on KubeVirt | ||||||||||
| // +optional | ||||||||||
| // +kubebuilder:default=false | ||||||||||
| // +default=false | ||||||||||
| // Deprecated: This field is ignored and use mediatedDevicesConfiguration.Enabled instead , it will be removed in the next version of the API. | ||||||||||
| DisableMDevConfiguration *bool `json:"disableMDevConfiguration,omitempty"` | ||||||||||
|
Comment on lines
+469
to
470
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (typo): Clarify and clean up the deprecation message wording. The deprecation message is grammatically awkward (mixed tenses, extra space before the comma) and could confuse users. Prefer something like: "Deprecated: This field is ignored; use spec.mediatedDevicesConfiguration.enabled instead. It will be removed in the next version of the API." Also, explicitly including the full field path (
Suggested change
|
||||||||||
|
|
||||||||||
| // Enable persistent reservation of a LUN through the SCSI Persistent Reserve commands on Kubevirt. | ||||||||||
|
|
@@ -646,6 +643,12 @@ type MediatedDevicesConfiguration struct { | |||||||||
| // +optional | ||||||||||
| // +listType=atomic | ||||||||||
| NodeMediatedDeviceTypes []NodeMediatedDeviceTypesConfig `json:"nodeMediatedDeviceTypes,omitempty"` | ||||||||||
|
|
||||||||||
| // Enable the creation and removal of mediated devices by virt-handler | ||||||||||
| // Replaces the deprecated DisableMDEVConfiguration feature gate | ||||||||||
| // Defaults to true | ||||||||||
| // +optional | ||||||||||
| Enabled *bool `json:"enabled,omitempty"` | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // NodeMediatedDeviceTypesConfig holds information about MDEV types to be defined in a specific node that matches the NodeSelector field. | ||||||||||
|
|
@@ -951,7 +954,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, "deployKubeSecondaryDNS": false, "disableMDevConfiguration": false, "persistentReservation": false, "enableMultiArchBootImageImport": false, "decentralizedLiveMigration": true, "declarativeHotplugVolumes": false, "videoConfig": true, "objectGraph": false, "incrementalBackup": false}, "liveMigrationConfig": {"completionTimeoutPerGiB": 150, "parallelMigrationsPerCluster": 5, "parallelOutboundMigrationsPerNode": 2, "progressTimeout": 150, "allowAutoConverge": false, "allowPostCopy": false}, "resourceRequirements": {"vmiCPUAllocationRatio": 10}, "uninstallStrategy": "BlockUninstallIfWorkloadsExist", "virtualMachineOptions": {"disableFreePageReporting": false, "disableSerialConsoleLog": false}, "enableApplicationAwareQuota": false, "enableCommonBootImageImport": true, "deployVmConsoleProxy": false} | ||||||||||
| // +kubebuilder:default={"certConfig": {"ca": {"duration": "48h0m0s", "renewBefore": "24h0m0s"}, "server": {"duration": "24h0m0s", "renewBefore": "12h0m0s"}},"featureGates": {"downwardMetrics": false, "deployKubeSecondaryDNS": false, "persistentReservation": false, "enableMultiArchBootImageImport": false, "decentralizedLiveMigration": true, "declarativeHotplugVolumes": false, "videoConfig": true, "objectGraph": false, "incrementalBackup": false}, "liveMigrationConfig": {"completionTimeoutPerGiB": 150, "parallelMigrationsPerCluster": 5, "parallelOutboundMigrationsPerNode": 2, "progressTimeout": 150, "allowAutoConverge": false, "allowPostCopy": false}, "resourceRequirements": {"vmiCPUAllocationRatio": 10}, "uninstallStrategy": "BlockUninstallIfWorkloadsExist", "virtualMachineOptions": {"disableFreePageReporting": false, "disableSerialConsoleLog": false}, "enableApplicationAwareQuota": false, "enableCommonBootImageImport": true, "deployVmConsoleProxy": false} | ||||||||||
| // +optional | ||||||||||
| Spec HyperConvergedSpec `json:"spec,omitempty"` | ||||||||||
| Status HyperConvergedStatus `json:"status,omitempty"` | ||||||||||
|
|
||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -612,9 +612,8 @@ func getObsoleteCPUConfig(hcObsoleteCPUConf *hcov1beta1.HyperConvergedObsoleteCP | |
|
|
||
| func toKvMediatedDevicesConfiguration(hc *hcov1beta1.HyperConverged) *kubevirtcorev1.MediatedDevicesConfiguration { | ||
| mdevsConfig := hc.Spec.MediatedDevicesConfiguration | ||
| disabled := ptr.Deref(hc.Spec.FeatureGates.DisableMDevConfiguration, false) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we do need it. we don't ignoring the FG. if only the FG is true, then we need to set the KubeVirt's |
||
|
|
||
| if mdevsConfig == nil && !disabled { | ||
| if mdevsConfig == nil { | ||
| return nil | ||
| } | ||
|
|
||
|
|
@@ -632,7 +631,7 @@ func toKvMediatedDevicesConfiguration(hc *hcov1beta1.HyperConverged) *kubevirtco | |
| kvMdev.NodeMediatedDeviceTypes = toKvNodeMediatedDevicesConfiguration(mdevsConfig.NodeMediatedDeviceTypes) | ||
| } | ||
|
|
||
| if disabled { | ||
| if !ptr.Deref(mdevsConfig.Enabled, true) { | ||
| kvMdev.Enabled = ptr.To(false) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -383,6 +383,13 @@ func (r *ReconcileHyperConverged) doReconcile(req *common.HcoRequest) (reconcile | |
| return reconcile.Result{}, nil | ||
| } | ||
|
|
||
| // Controller-driven upgrade: if deprecated disableMDevConfiguration is true and | ||
| // mediatedDevicesConfiguration.enabled is missing, set enabled=false so the CR | ||
| // is migrated without requiring a user edit. updateHyperConverged will persist it. | ||
| if r.migrateMDevConfigurationIfNeeded(req) { | ||
| req.Logger.Info("Migrated HCO spec: set mediatedDevicesConfiguration.enabled from deprecated disableMDevConfiguration") | ||
| } | ||
|
|
||
|
Comment on lines
+386
to
+392
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code should be in the mutating webhook. |
||
| // Add conditions if there are none | ||
| init := req.Instance.Status.Conditions == nil | ||
| if init { | ||
|
|
@@ -1120,6 +1127,32 @@ func (r *ReconcileHyperConverged) setOperatorUpgradeableStatus(request *common.H | |
| return nil | ||
| } | ||
|
|
||
| // migrateMDevConfigurationIfNeeded performs a controller-driven upgrade: when the deprecated | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| // spec.featureGates.disableMDevConfiguration is true and spec.mediatedDevicesConfiguration.enabled | ||
| // is missing, it sets enabled=false so the CR is migrated without requiring a user edit. | ||
| // Returns true if the spec was modified (caller should set req.Dirty and requeue). | ||
| func (r *ReconcileHyperConverged) migrateMDevConfigurationIfNeeded(req *common.HcoRequest) bool { | ||
| //nolint:staticcheck // Read deprecated field to migrate existing CRs. | ||
| if req.Instance.Spec.FeatureGates.DisableMDevConfiguration == nil || | ||
| !*req.Instance.Spec.FeatureGates.DisableMDevConfiguration { | ||
| return false | ||
| } | ||
| mdc := req.Instance.Spec.MediatedDevicesConfiguration | ||
| if mdc == nil { | ||
| req.Instance.Spec.MediatedDevicesConfiguration = &hcov1beta1.MediatedDevicesConfiguration{ | ||
| Enabled: ptr.To(false), | ||
| } | ||
| req.Dirty = true | ||
| return true | ||
| } | ||
| if mdc.Enabled != nil { | ||
| return false | ||
| } | ||
| mdc.Enabled = ptr.To(false) | ||
| req.Dirty = true | ||
| return true | ||
| } | ||
|
|
||
| func (r *ReconcileHyperConverged) migrateBeforeUpgrade(req *common.HcoRequest) (bool, error) { | ||
| upgradePatched, err := r.applyUpgradePatches(req) | ||
| if err != nil { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -860,6 +860,33 @@ var _ = Describe("HyperconvergedController", func() { | |
| Expect(foundResource.Finalizers).To(Equal([]string{FinalizerName})) | ||
| }) | ||
|
|
||
| It("should migrate mediatedDevicesConfiguration.enabled from deprecated disableMDevConfiguration on reconcile", func() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| expected := getBasicDeployment() | ||
| //nolint:staticcheck // Intentionally set deprecated FG to test controller-driven migration. | ||
| expected.hco.Spec.FeatureGates.DisableMDevConfiguration = ptr.To(true) | ||
| expected.hco.Spec.MediatedDevicesConfiguration = &hcov1beta1.MediatedDevicesConfiguration{ | ||
| MediatedDeviceTypes: []string{"nvidia-222"}, | ||
| Enabled: nil, // missing; controller should set to false | ||
| } | ||
| cl := expected.initClient() | ||
| foundResource, _, _ := doReconcile(cl, expected.hco, nil) | ||
| Expect(foundResource.Spec.MediatedDevicesConfiguration).ToNot(BeNil()) | ||
| Expect(foundResource.Spec.MediatedDevicesConfiguration.Enabled).ToNot(BeNil()) | ||
| Expect(*foundResource.Spec.MediatedDevicesConfiguration.Enabled).To(BeFalse()) | ||
| }) | ||
|
|
||
| It("should create mediatedDevicesConfiguration with enabled=false when FG is true and MDC is nil", func() { | ||
| expected := getBasicDeployment() | ||
| //nolint:staticcheck // Intentionally set deprecated FG to test controller-driven migration. | ||
| expected.hco.Spec.FeatureGates.DisableMDevConfiguration = ptr.To(true) | ||
| expected.hco.Spec.MediatedDevicesConfiguration = nil | ||
| cl := expected.initClient() | ||
| foundResource, _, _ := doReconcile(cl, expected.hco, nil) | ||
| Expect(foundResource.Spec.MediatedDevicesConfiguration).ToNot(BeNil()) | ||
| Expect(foundResource.Spec.MediatedDevicesConfiguration.Enabled).ToNot(BeNil()) | ||
| Expect(*foundResource.Spec.MediatedDevicesConfiguration.Enabled).To(BeFalse()) | ||
| }) | ||
|
|
||
| It("Should not be ready if one of the operands is returns error, on create", func() { | ||
| hco := commontestutils.NewHco() | ||
| cl := commontestutils.InitClient([]client.Object{hcoNamespace, hco}) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're not ignoring it, but it is deprecated.