Skip to content

Commit

Permalink
macvtap: Block deployment on Openshift (#1590)
Browse files Browse the repository at this point in the history
Signed-off-by: Or Shoval <[email protected]>
  • Loading branch information
oshoval authored Aug 10, 2023
1 parent 041160f commit 799e6ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/network/macvtap.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package network

import (
"fmt"
"os"
"path/filepath"

openshiftoperatorv1 "github.com/openshift/api/operator/v1"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

Expand Down Expand Up @@ -58,3 +60,15 @@ func fillMacvtapDefaults(conf *cnao.NetworkAddonsConfigSpec, previousConf *cnao.
func hasDevicePluginConfigMapNameDefined(conf *cnao.NetworkAddonsConfigSpec) bool {
return conf != nil && conf.MacvtapCni != nil && conf.MacvtapCni.DevicePluginConfig != ""
}

func validateMacvtap(conf *cnao.NetworkAddonsConfigSpec, openshiftNetworkConfig *openshiftoperatorv1.Network) []error {
if conf.MacvtapCni == nil {
return nil
}

if openshiftNetworkConfig != nil {
return []error{fmt.Errorf("`macvtap` has been requested, but is not supported on OpenShift")}
}

return nil
}
1 change: 1 addition & 0 deletions pkg/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func Validate(conf *cnao.NetworkAddonsConfigSpec, openshiftNetworkConfig *osv1.N
errs = append(errs, validateImagePullPolicy(conf)...)
errs = append(errs, validateSelfSignConfiguration(conf)...)
errs = append(errs, validateMultusDynamicNetworks(conf, openshiftNetworkConfig)...)
errs = append(errs, validateMacvtap(conf, openshiftNetworkConfig)...)

if len(errs) > 0 {
return errors.Errorf("invalid configuration:\n%s", errorListToMultiLineString(errs))
Expand Down

0 comments on commit 799e6ed

Please sign in to comment.