Skip to content
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

[release-1.9] Expose DisableMDEVConfiguration feature gate on HCO API #2367

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ sanity: generate generate-doc validate-no-offensive-lang goimport
go mod tidy -v
go mod vendor
./hack/build-manifests.sh
(cd tests && go mod tidy -v && go mod vendor)
git add -N vendor
git difftool -y --trust-exit-code --extcmd=./hack/diff-csv.sh

Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/hyperconverged_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ type HyperConvergedFeatureGates struct {
// +kubebuilder:default=true
// +default=true
NonRoot *bool `json:"nonRoot,omitempty"`

// Disable mediated devices handling on KubeVirt
// +optional
// +kubebuilder:default=false
// +default=false
DisableMDevConfiguration *bool `json:"disableMDevConfiguration,omitempty"`
}

// PermittedHostDevices holds information about devices allowed for passthrough
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.

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

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

15 changes: 15 additions & 0 deletions api/v1beta1/zz_generated.openapi.go

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

4 changes: 4 additions & 0 deletions config/crd/bases/hco.kubevirt.io_hyperconvergeds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,10 @@ spec:
description: deploy resources (kubevirt tekton tasks and example
pipelines) in Tekton tasks operator
type: boolean
disableMDevConfiguration:
default: false
description: Disable mediated devices handling on KubeVirt
type: boolean
enableCommonBootImageImport:
default: true
description: 'Opt-in to automatic delivery/updates of the common
Expand Down
5 changes: 5 additions & 0 deletions controllers/operands/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ var (
const (
kvWithHostPassthroughCPU = "WithHostPassthroughCPU"
kvRoot = "Root"
kvDisableMDevConfig = "DisableMDEVConfiguration"
)

// CPU Plugin default values
Expand Down Expand Up @@ -643,6 +644,10 @@ func getFeatureGateChecks(featureGates *hcov1beta1.HyperConvergedFeatureGates) [
fgs = append(fgs, kvRoot)
}

if featureGates.DisableMDevConfiguration != nil && *featureGates.DisableMDevConfiguration {
fgs = append(fgs, kvDisableMDevConfig)
}

return fgs
}

Expand Down
47 changes: 44 additions & 3 deletions controllers/operands/kubevirt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,45 @@ Version: 1.2.3`)
})
})

It("should add the DisableMDevConfiguration feature gate if DisableMDevConfiguration is true in HyperConverged CR", func() {
hco.Spec.FeatureGates = hcov1beta1.HyperConvergedFeatureGates{
DisableMDevConfiguration: pointer.Bool(true),
}

existingResource, err := NewKubeVirt(hco)
Expect(err).ToNot(HaveOccurred())
By("KV CR should contain the DisableMDevConfiguration feature gate", func() {
Expect(existingResource.Spec.Configuration.DeveloperConfiguration).NotTo(BeNil())
Expect(existingResource.Spec.Configuration.DeveloperConfiguration.FeatureGates).To(ContainElement(kvDisableMDevConfig))
})
})

It("should not add the DisableMDevConfiguration feature gate if DisableMDevConfiguration is not set in HyperConverged CR", func() {
hco.Spec.FeatureGates = hcov1beta1.HyperConvergedFeatureGates{
DisableMDevConfiguration: nil,
}

existingResource, err := NewKubeVirt(hco)
Expect(err).ToNot(HaveOccurred())
By("KV CR should contain the DisableMDevConfiguration feature gate", func() {
Expect(existingResource.Spec.Configuration.DeveloperConfiguration).NotTo(BeNil())
Expect(existingResource.Spec.Configuration.DeveloperConfiguration.FeatureGates).ToNot(ContainElement(kvDisableMDevConfig))
})
})

It("should not add the DisableMDevConfiguration feature gate if DisableMDevConfiguration is false in HyperConverged CR", func() {
hco.Spec.FeatureGates = hcov1beta1.HyperConvergedFeatureGates{
DisableMDevConfiguration: pointer.Bool(false),
}

existingResource, err := NewKubeVirt(hco)
Expect(err).ToNot(HaveOccurred())
By("KV CR should contain the DisableMDevConfiguration feature gate", func() {
Expect(existingResource.Spec.Configuration.DeveloperConfiguration).NotTo(BeNil())
Expect(existingResource.Spec.Configuration.DeveloperConfiguration.FeatureGates).ToNot(ContainElement(kvDisableMDevConfig))
})
})

It("should not add the feature gates if FeatureGates field is empty", func() {
mandatoryKvFeatureGates = getMandatoryKvFeatureGates(false)
hco.Spec.FeatureGates = hcov1beta1.HyperConvergedFeatureGates{}
Expand Down Expand Up @@ -1445,7 +1484,8 @@ Version: 1.2.3`)
Expect(err).ToNot(HaveOccurred())

hco.Spec.FeatureGates = hcov1beta1.HyperConvergedFeatureGates{
WithHostPassthroughCPU: pointer.Bool(true),
WithHostPassthroughCPU: pointer.Bool(true),
DisableMDevConfiguration: pointer.Bool(true),
}

cl := commonTestUtils.InitClient([]runtime.Object{hco, existingResource})
Expand Down Expand Up @@ -1475,7 +1515,8 @@ Version: 1.2.3`)
Expect(err).ToNot(HaveOccurred())

hco.Spec.FeatureGates = hcov1beta1.HyperConvergedFeatureGates{
WithHostPassthroughCPU: pointer.Bool(false),
WithHostPassthroughCPU: pointer.Bool(false),
DisableMDevConfiguration: pointer.Bool(false),
}

cl := commonTestUtils.InitClient([]runtime.Object{hco, existingResource})
Expand Down Expand Up @@ -2576,7 +2617,7 @@ Version: 1.2.3`)

hco.Spec.TuningPolicy = hcov1beta1.HyperConvergedAnnotationTuningPolicy
hco.Annotations = make(map[string]string, 1)
//burst is missing
// burst is missing
hco.Annotations["hco.kubevirt.io/tuningPolicy"] = `{"qps": 100}`

kv, err := NewKubeVirt(hco)
Expand Down
4 changes: 4 additions & 0 deletions deploy/crds/hco00.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,10 @@ spec:
description: deploy resources (kubevirt tekton tasks and example
pipelines) in Tekton tasks operator
type: boolean
disableMDevConfiguration:
default: false
description: Disable mediated devices handling on KubeVirt
type: boolean
enableCommonBootImageImport:
default: true
description: 'Opt-in to automatic delivery/updates of the common
Expand Down
1 change: 1 addition & 0 deletions deploy/hco.cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ spec:
featureGates:
deployKubeSecondaryDNS: false
deployTektonTaskResources: false
disableMDevConfiguration: false
enableCommonBootImageImport: true
nonRoot: true
withHostPassthroughCPU: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,10 @@ spec:
description: deploy resources (kubevirt tekton tasks and example
pipelines) in Tekton tasks operator
type: boolean
disableMDevConfiguration:
default: false
description: Disable mediated devices handling on KubeVirt
type: boolean
enableCommonBootImageImport:
default: true
description: 'Opt-in to automatic delivery/updates of the common
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,10 @@ spec:
description: deploy resources (kubevirt tekton tasks and example
pipelines) in Tekton tasks operator
type: boolean
disableMDevConfiguration:
default: false
description: Disable mediated devices handling on KubeVirt
type: boolean
enableCommonBootImageImport:
default: true
description: 'Opt-in to automatic delivery/updates of the common
Expand Down
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ HyperConvergedFeatureGates is a set of optional feature gates to enable or disab
| deployTektonTaskResources | deploy resources (kubevirt tekton tasks and example pipelines) in Tekton tasks operator | *bool | false | false |
| deployKubeSecondaryDNS | Deploy KubeSecondaryDNS by CNAO | *bool | false | false |
| nonRoot | Enables rootless virt-launcher. | *bool | true | false |
| disableMDevConfiguration | Disable mediated devices handling on KubeVirt | *bool | false | false |

[Back to TOC](#table-of-contents)

Expand Down
5 changes: 3 additions & 2 deletions hack/check_defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ echo "Read the CR's spec before starting the test"
${KUBECTL_BINARY} get hco -n "${INSTALLED_NAMESPACE}" kubevirt-hyperconverged -o json | jq '.spec'

CERTCONFIGDEFAULTS='{"ca":{"duration":"48h0m0s","renewBefore":"24h0m0s"},"server":{"duration":"24h0m0s","renewBefore":"12h0m0s"}}'
FGDEFAULTS='{"deployKubeSecondaryDNS":false,"deployTektonTaskResources":false,"enableCommonBootImageImport":true,"nonRoot":true,"withHostPassthroughCPU":false}'
FGDEFAULTS='{"deployKubeSecondaryDNS":false,"deployTektonTaskResources":false,"disableMDevConfiguration":false,"enableCommonBootImageImport":true,"nonRoot":true,"withHostPassthroughCPU":false}'
LMDEFAULTS='{"allowAutoConverge":false,"allowPostCopy":false,"completionTimeoutPerGiB":800,"parallelMigrationsPerCluster":5,"parallelOutboundMigrationsPerNode":2,"progressTimeout":150}'
PERMITTED_HOST_DEVICES_DEFAULT1='{"pciDeviceSelector":"10DE:1DB6","resourceName":"nvidia.com/GV100GL_Tesla_V100"}'
PERMITTED_HOST_DEVICES_DEFAULT2='{"pciDeviceSelector":"10DE:1EB8","resourceName":"nvidia.com/TU104GL_Tesla_T4"}'
Expand All @@ -41,6 +41,7 @@ CERTCONFIGPATHS=(
)

FGPATHS=(
"/spec/featureGates/disableMDevConfiguration"
"/spec/featureGates/enableCommonBootImageImport"
"/spec/featureGates/withHostPassthroughCPU"
"/spec/featureGates"
Expand Down Expand Up @@ -99,7 +100,7 @@ for JPATH in "${FGPATHS[@]}"; do
sleep 2
done

echo "Check that featureGates defaults are behaving as expected"
echo "Check that liveMigrationConfig defaults are behaving as expected"

./hack/retry.sh 10 3 "${KUBECTL_BINARY} patch hco -n \"${INSTALLED_NAMESPACE}\" --type=json kubevirt-hyperconverged -p '[{ \"op\": \"replace\", \"path\": /spec, \"value\": {} }]'"
for JPATH in "${LMPATHS[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion tests/func-tests/node_placement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var _ = Describe("[rfe_id:4356][crit:medium][vendor:cnv-qe@redhat.com][level:sys
expectedWorkloadsPods := map[string]bool{
"bridge-marker": false,
"cni-plugins": false,
//"kube-multus": false,
// "kube-multus": false,
"ovs-cni-marker": false,
"virt-handler": false,
"secondary-dns": false,
Expand Down
1 change: 1 addition & 0 deletions tests/func-tests/virtual_machines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func verifyVMIRunning(client kubecli.KubevirtClient, vmiName string) *kubevirtco
var err error
vmi, err = client.VirtualMachineInstance(kvtutil.NamespaceTestDefault).Get(context.Background(), vmiName, &k8smetav1.GetOptions{})
g.Expect(err).ToNot(HaveOccurred())
fmt.Fprintf(GinkgoWriter, "VMI's status.phase: %s", vmi.Status.Phase)
return vmi.Status.Phase == kubevirtcorev1.Running
}, timeout, pollingInterval).Should(BeTrue(), "failed to get the vmi Running")

Expand Down
1 change: 1 addition & 0 deletions tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8Nz
github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/go-systemd/v22 v22.4.0 h1:y9YHcjnjynCd/DVbg5j9L/33jQM3MxJlbj/zWskzfGU=
Expand Down

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.

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