Skip to content

Deprecate disableMDevConfiguration in favor of mediatedDevicesConfiguration.enabled#4057

Open
Ronilerr wants to merge 4 commits intokubevirt:mainfrom
Ronilerr:enabledConfig
Open

Deprecate disableMDevConfiguration in favor of mediatedDevicesConfiguration.enabled#4057
Ronilerr wants to merge 4 commits intokubevirt:mainfrom
Ronilerr:enabledConfig

Conversation

@Ronilerr
Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:

  • Deprecates spec.featureGates.disableMDevConfiguration and replaces it with spec.mediatedDevicesConfiguration.enabled.
  • The KubeVirt handler now uses only enabled.
  • The mutator sets mediatedDevicesConfiguration.enabled: false when the deprecated gate is true so existing CRs keep the same behavior.
  • Default feature gates no longer include disableMDevConfiguration.

Reviewer Checklist

Reviewers are supposed to review the PR for every aspect below one by one. To check an item means the PR is either "OK" or "Not Applicable" in terms of that item. All items are supposed to be checked before merging a PR.

  • PR Message
  • Commit Messages
  • How to test
  • Unit Tests
  • Functional Tests
  • User Documentation
  • Developer Documentation
  • Upgrade Scenario
  • Uninstallation Scenario
  • Backward Compatibility
  • Troubleshooting Friendly

Jira Ticket:

https://issues.redhat.com/browse/CNV-79304

Release note:

Deprecate disableMDevConfiguration feature gate in favor of spec.mediatedDevicesConfiguration.enabled

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Feb 26, 2026
@kubevirt-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign avlitman for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The change of the decentralizedLiveMigration default from true to false in multiple CRD/spec default blocks seems unrelated to deprecating disableMDevConfiguration and may be accidental; please confirm whether this behavioral change is intended and, if not, revert it.
  • The deprecation comment for DisableMDevConfiguration (“This field is ignored and use mediatedDevicesConfiguration.Enabled instead , it will be removed…”) is a bit awkward; consider rephrasing to something like Deprecated: this field is ignored; use mediatedDevicesConfiguration.enabled instead. It will be removed in the next API version. for clarity and consistency across Go types and CRDs.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The change of the `decentralizedLiveMigration` default from `true` to `false` in multiple CRD/spec default blocks seems unrelated to deprecating `disableMDevConfiguration` and may be accidental; please confirm whether this behavioral change is intended and, if not, revert it.
- The deprecation comment for `DisableMDevConfiguration` (“This field is ignored and use mediatedDevicesConfiguration.Enabled instead , it will be removed…”) is a bit awkward; consider rephrasing to something like `Deprecated: this field is ignored; use mediatedDevicesConfiguration.enabled instead. It will be removed in the next API version.` for clarity and consistency across Go types and CRDs.

## Individual Comments

### Comment 1
<location path="api/v1beta1/hyperconverged_types.go" line_range="469-470" />
<code_context>
-	// +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"`

</code_context>
<issue_to_address>
**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 (`spec.mediatedDevicesConfiguration.enabled`) and correct casing helps users know exactly what to migrate to.

```suggestion
	// Deprecated: This field is ignored; use spec.mediatedDevicesConfiguration.enabled instead. It will be removed in the next version of the API.
	DisableMDevConfiguration *bool `json:"disableMDevConfiguration,omitempty"`
```
</issue_to_address>

### Comment 2
<location path="pkg/webhooks/mutator/hyperConvergedMutator.go" line_range="100-107" />
<code_context>

 	patches = mutateEvictionStrategy(hc, patches)

+	if hc.Spec.FeatureGates.DisableMDevConfiguration != nil && *hc.Spec.FeatureGates.DisableMDevConfiguration && //nolint:staticcheck // Read deprecated field to migrate CRs.
+		hc.Spec.MediatedDevicesConfiguration != nil && hc.Spec.MediatedDevicesConfiguration.Enabled == nil {
+		patches = append(patches, jsonpatch.JsonPatchOperation{
+			Operation: "add",
+			Path:      "/spec/mediatedDevicesConfiguration/enabled",
+			Value:     false,
+		})
+	}
+
 	if hc.Spec.MediatedDevicesConfiguration != nil {
</code_context>
<issue_to_address>
**question:** Migration logic ignores CRs that only used the deprecated feature gate without a MediatedDevicesConfiguration block.

Because this runs only when `DisableMDevConfiguration == true` and `Spec.MediatedDevicesConfiguration != nil`, CRs that previously relied *only* on the feature gate (no `mediatedDevicesConfiguration` block) will never get `enabled=false` materialized. With `ptr.Deref(mdevsConfig.Enabled, true)`, those clusters will effectively lose the "globally disabled via feature gate" behavior once they add any MDEV config. Please clarify whether this behavior change is intentional; if not, consider also creating `mediatedDevicesConfiguration.enabled=false` for CRs that have the feature gate set but no block yet.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +469 to 470
// 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"`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 (spec.mediatedDevicesConfiguration.enabled) and correct casing helps users know exactly what to migrate to.

Suggested change
// 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"`
// Deprecated: This field is ignored; use spec.mediatedDevicesConfiguration.enabled instead. It will be removed in the next version of the API.
DisableMDevConfiguration *bool `json:"disableMDevConfiguration,omitempty"`

Signed-off-by: ronilerr <rrabinov@redhat.com>
…on.enabled

Signed-off-by: ronilerr <rrabinov@redhat.com>
Signed-off-by: ronilerr <rrabinov@redhat.com>
@hco-bot
Copy link
Copy Markdown
Collaborator

hco-bot commented Feb 26, 2026

hco-e2e-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-aws
hco-e2e-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-gcp
hco-e2e-upgrade-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-operator-sdk-aws

@kubevirt-bot
Copy link
Copy Markdown
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-operator-sdk-aws, ci/prow/hco-e2e-operator-sdk-gcp, ci/prow/hco-e2e-upgrade-operator-sdk-aws

Details

In response to this:

hco-e2e-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-aws
hco-e2e-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-gcp
hco-e2e-upgrade-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-operator-sdk-aws

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hco-bot
Copy link
Copy Markdown
Collaborator

hco-bot commented Feb 26, 2026

hco-e2e-kv-smoke-gcp lane succeeded.
/override ci/prow/hco-e2e-kv-smoke-azure

@kubevirt-bot
Copy link
Copy Markdown
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-kv-smoke-azure

Details

In response to this:

hco-e2e-kv-smoke-gcp lane succeeded.
/override ci/prow/hco-e2e-kv-smoke-azure

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

…diatedDevicesConfiguration.enabled; Controller: migrate existing CRs; add tests

Signed-off-by: ronilerr <rrabinov@redhat.com>
@sonarqubecloud
Copy link
Copy Markdown

@hco-bot
Copy link
Copy Markdown
Collaborator

hco-bot commented Feb 26, 2026

hco-e2e-operator-sdk-sno-aws lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-sno-azure

@kubevirt-bot
Copy link
Copy Markdown
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-operator-sdk-sno-azure

Details

In response to this:

hco-e2e-operator-sdk-sno-aws lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-sno-azure

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Feb 26, 2026

@Ronilerr: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/hco-e2e-operator-sdk-aws 53a5ac7 link true /test hco-e2e-operator-sdk-aws
ci/prow/hco-e2e-kv-smoke-azure 53a5ac7 link true /test hco-e2e-kv-smoke-azure
ci/prow/hco-e2e-upgrade-prev-operator-sdk-azure 53a5ac7 link true /test hco-e2e-upgrade-prev-operator-sdk-azure
ci/prow/hco-e2e-upgrade-operator-sdk-azure 53a5ac7 link true /test hco-e2e-upgrade-operator-sdk-azure
ci/prow/hco-e2e-upgrade-prev-operator-sdk-sno-azure 53a5ac7 link false /test hco-e2e-upgrade-prev-operator-sdk-sno-azure
ci/prow/hco-e2e-operator-sdk-gcp 53a5ac7 link true /test hco-e2e-operator-sdk-gcp
ci/prow/hco-e2e-upgrade-prev-operator-sdk-sno-aws 53a5ac7 link false /test hco-e2e-upgrade-prev-operator-sdk-sno-aws
ci/prow/hco-e2e-operator-sdk-sno-azure 53a5ac7 link false /test hco-e2e-operator-sdk-sno-azure

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@hco-bot
Copy link
Copy Markdown
Collaborator

hco-bot commented Feb 26, 2026

hco-e2e-upgrade-prev-operator-sdk-aws lane succeeded.
/override ci/prow/hco-e2e-upgrade-prev-operator-sdk-azure
hco-e2e-upgrade-operator-sdk-aws lane succeeded.
/override ci/prow/hco-e2e-upgrade-operator-sdk-azure
hco-e2e-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-gcp
hco-e2e-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-aws
hco-e2e-operator-sdk-sno-aws lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-sno-azure

@kubevirt-bot
Copy link
Copy Markdown
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-operator-sdk-aws, ci/prow/hco-e2e-operator-sdk-gcp, ci/prow/hco-e2e-operator-sdk-sno-azure, ci/prow/hco-e2e-upgrade-operator-sdk-azure, ci/prow/hco-e2e-upgrade-prev-operator-sdk-azure

Details

In response to this:

hco-e2e-upgrade-prev-operator-sdk-aws lane succeeded.
/override ci/prow/hco-e2e-upgrade-prev-operator-sdk-azure
hco-e2e-upgrade-operator-sdk-aws lane succeeded.
/override ci/prow/hco-e2e-upgrade-operator-sdk-azure
hco-e2e-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-gcp
hco-e2e-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-aws
hco-e2e-operator-sdk-sno-aws lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-sno-azure

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hco-bot
Copy link
Copy Markdown
Collaborator

hco-bot commented Feb 26, 2026

hco-e2e-kv-smoke-gcp lane succeeded.
/override ci/prow/hco-e2e-kv-smoke-azure

@kubevirt-bot
Copy link
Copy Markdown
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-kv-smoke-azure

Details

In response to this:

hco-e2e-kv-smoke-gcp lane succeeded.
/override ci/prow/hco-e2e-kv-smoke-azure

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Copy Markdown
Collaborator

@nunnatsa nunnatsa left a comment

Choose a reason for hiding this comment

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

Added a few comments, but let's wait with it until we make the API changes.

Comment on lines +386 to +392
// 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")
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This code should be in the mutating webhook.

return nil
}

// migrateMDevConfigurationIfNeeded performs a controller-driven upgrade: when the deprecated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same

Expect(foundResource.Finalizers).To(Equal([]string{FinalizerName}))
})

It("should migrate mediatedDevicesConfiguration.enabled from deprecated disableMDevConfiguration on reconcile", func() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same

// +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.
Copy link
Copy Markdown
Collaborator

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.


func toKvMediatedDevicesConfiguration(hc *hcov1beta1.HyperConverged) *kubevirtcorev1.MediatedDevicesConfiguration {
mdevsConfig := hc.Spec.MediatedDevicesConfiguration
disabled := ptr.Deref(hc.Spec.FeatureGates.DisableMDevConfiguration, false)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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 enabled field to false. If both the FG is set and our enabled field is set, we'll go with the field.

Comment on lines +181 to +183
Operation: "replace",
Path: "/spec/mediatedDevicesConfiguration/enabled",
Value: nil,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

use the "remove" op instead.

}

func getMutatePatches(hc *hcov1beta1.HyperConverged) []jsonpatch.JsonPatchOperation {
func getMutatePatches(hc *hcov1beta1.HyperConverged, oldHC *hcov1beta1.HyperConverged, operation admissionv1.Operation) []jsonpatch.JsonPatchOperation {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it will be clearer to have two functions - one for update and one for create, instead of asking for the operation each time.

Comment on lines +150 to +154
patches = append(patches, jsonpatch.JsonPatchOperation{
Operation: "replace",
Path: "/spec/featureGates/disableMDevConfiguration",
Value: !newEnabled,
})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

or drop it instead of changing it?

Path: fmt.Sprintf("/spec/mediatedDevicesConfiguration/nodeMediatedDeviceTypes/%d/mediatedDeviceTypes", i),
Value: hcoNodeMdevTypeConf.MediatedDevicesTypes, //nolint SA1019
Path: "/spec/mediatedDevicesConfiguration",
Value: map[string]interface{}{"enabled": false},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

use any instead of interface{}

Suggested change
Value: map[string]interface{}{"enabled": false},
Value: map[string]any{"enabled": false},

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 5, 2026
@kubevirt-bot
Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

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

Labels

dco-signoff: yes Indicates the PR's author has DCO signed all their commits. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants