Skip to content

Commit

Permalink
Deprecate Macvtap
Browse files Browse the repository at this point in the history
Warn that macvtap binding is going to be removed and macvtap binding
plugin can be used instead.

Signed-off-by: Alona Paz <[email protected]>
  • Loading branch information
AlonaKaplan committed Dec 24, 2023
1 parent 5c64336 commit 5ff12ae
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/virt-api/webhooks/fuzz/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func fuzzKubeVirtConfig(seed int64) *virtconfig.ClusterConfig {
virtconfig.HotplugVolumesGate,
virtconfig.HostDiskGate,
virtconfig.VirtIOFSGate,
virtconfig.MacvtapGate,
deprecation.MacvtapGate,
deprecation.PasstGate,
virtconfig.DownwardMetricsFeatureGate,
deprecation.NonRoot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ var _ = Describe("Validating VMICreate Admitter", func() {
},
}

enableFeatureGate(virtconfig.MacvtapGate)
enableFeatureGate(deprecation.MacvtapGate)
causes := ValidateVirtualMachineInstanceSpec(k8sfield.NewPath("fake"), &vm.Spec, config)
Expect(causes).To(HaveLen(1))
Expect(causes[0].Field).To(Equal("fake.domain.devices.interfaces[0].name"))
Expand Down Expand Up @@ -1815,7 +1815,7 @@ var _ = Describe("Validating VMICreate Admitter", func() {
},
}

enableFeatureGate(virtconfig.MacvtapGate)
enableFeatureGate(deprecation.MacvtapGate)
causes := ValidateVirtualMachineInstanceSpec(k8sfield.NewPath("fake"), &vm.Spec, config)
Expect(causes).To(BeEmpty())
})
Expand Down
1 change: 1 addition & 0 deletions pkg/virt-config/deprecation/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go_library(
name = "go_default_library",
srcs = [
"feature-gates.go",
"macvtap.go",
"passt.go",
],
importpath = "kubevirt.io/kubevirt/pkg/virt-config/deprecation",
Expand Down
2 changes: 2 additions & 0 deletions pkg/virt-config/deprecation/feature-gates.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const (
PasstGate = "Passt" // Deprecated
NonRoot = "NonRoot" // Deprecated
PSA = "PSA" // Deprecated
MacvtapGate = "Macvtap" // Deprecated
)

type FeatureGate struct {
Expand All @@ -56,6 +57,7 @@ var featureGates = [...]FeatureGate{
{Name: PSA, State: GA},
{Name: CPUNodeDiscoveryGate, State: GA},
{Name: PasstGate, State: Deprecated, Message: passtDeprecationMessage, VmiSpecUsed: passtApiUsed},
{Name: MacvtapGate, State: Deprecated, Message: macvtapDeprecationMessage, VmiSpecUsed: macvtapApiUsed},
}

func init() {
Expand Down
35 changes: 35 additions & 0 deletions pkg/virt-config/deprecation/macvtap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* This file is part of the KubeVirt project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright The KubeVirt Authors.
*
*/

package deprecation

import (
v1 "kubevirt.io/api/core/v1"
)

const macvtapDeprecationMessage = "Macvtap network binding will be deprecated next release. Please refer to Kubevirt user guide for alternatives."

func macvtapApiUsed(spec *v1.VirtualMachineInstanceSpec) bool {
for _, net := range spec.Domain.Devices.Interfaces {
if net.Macvtap != nil {
return true
}
}
return false
}
3 changes: 1 addition & 2 deletions pkg/virt-config/feature-gates.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const (
HotplugVolumesGate = "HotplugVolumes"
HostDiskGate = "HostDisk"
VirtIOFSGate = "ExperimentalVirtiofsSupport"
MacvtapGate = "Macvtap"

DownwardMetricsFeatureGate = "DownwardMetrics"
Root = "Root"
Expand Down Expand Up @@ -165,7 +164,7 @@ func (config *ClusterConfig) VirtiofsEnabled() bool {
}

func (config *ClusterConfig) MacvtapEnabled() bool {
return config.isFeatureGateEnabled(MacvtapGate)
return config.isFeatureGateEnabled(deprecation.MacvtapGate)
}

func (config *ClusterConfig) PasstEnabled() bool {
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/kubevirtresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func AdjustKubeVirtResource() {
virtconfig.HotplugVolumesGate,
virtconfig.DownwardMetricsFeatureGate,
virtconfig.NUMAFeatureGate,
virtconfig.MacvtapGate,
deprecation.MacvtapGate,
deprecation.PasstGate,
virtconfig.ExpandDisksGate,
virtconfig.WorkloadEncryptionSEV,
Expand Down

0 comments on commit 5ff12ae

Please sign in to comment.