Skip to content

Commit ad73589

Browse files
committed
Avoid multus-admission webhook race with ovn-kubernetes
Add CEL expression to ignore default/openshift-ovn-kubernetes NAD to prevent circular dependency where ovn-k fails to start because multus webhook blocks NAD creation, while webhook uses cluster-networked pdos which require ovn-k to be running. Signed-off-by: Patryk Diak <[email protected]>
1 parent 4df46f9 commit ad73589

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

bindata/network/multus-admission-controller/003-webhook.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ webhooks:
3131
# On updates, only validate if the Spec changes
3232
- name: CreateDeleteOrUpdatedSpec
3333
expression: oldObject == null || object == null || has(object.spec) != has(oldObject.spec) || (has(object.spec) && object.spec != oldObject.spec)
34+
{{if .OVN_PRE_CONF_UDN_ADDR_ENABLE}}
35+
# Ignore default/openshift-ovn-kubernetes NAD to avoid a race between ovn-kubernetes and the multus webhook on install
36+
- name: IgnoreDefaultOVNKubernetesNAD
37+
expression: object == null || object.metadata.namespace != "openshift-ovn-kubernetes" || object.metadata.name != "default"
38+
{{- end }}
3439
sideEffects: NoneOnDryRun
3540
admissionReviewVersions:
3641
- v1

pkg/network/multus_admission_controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
uns "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2626
"k8s.io/klog/v2"
27+
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
28+
apifeatures "github.com/openshift/api/features"
2729
)
2830

2931
const bytesInMiB = 1024 * 1024
@@ -54,7 +56,7 @@ func getOpenshiftNamespaces(client cnoclient.Client) (string, error) {
5456
}
5557

5658
// renderMultusAdmissonControllerConfig returns the manifests of Multus Admisson Controller
57-
func renderMultusAdmissonControllerConfig(manifestDir string, externalControlPlane bool, bootstrapResult *bootstrap.BootstrapResult, client cnoclient.Client, hsc *hypershift.HyperShiftConfig, clientName string) ([]*uns.Unstructured, error) {
59+
func renderMultusAdmissonControllerConfig(manifestDir string, externalControlPlane bool, bootstrapResult *bootstrap.BootstrapResult, client cnoclient.Client, hsc *hypershift.HyperShiftConfig, clientName string, featureGates featuregates.FeatureGate) ([]*uns.Unstructured, error) {
5860
objs := []*uns.Unstructured{}
5961
var err error
6062

@@ -83,6 +85,8 @@ func renderMultusAdmissonControllerConfig(manifestDir string, externalControlPla
8385
data.Data["ResourceRequestCPU"] = nil
8486
data.Data["ResourceRequestMemory"] = nil
8587
data.Data["PriorityClass"] = nil
88+
data.Data["OVN_PRE_CONF_UDN_ADDR_ENABLE"] = featureGates.Enabled(apifeatures.FeatureGatePreconfiguredUDNAddresses)
89+
8690
if hsc.Enabled {
8791
data.Data["AdmissionControllerNamespace"] = hsc.Namespace
8892
data.Data["KubernetesServiceHost"] = bootstrapResult.Infra.APIServers[bootstrap.APIServerDefaultLocal].Host

pkg/network/multus_admission_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ func TestRenderMultusAdmissionController(t *testing.T) {
6262
bootstrap := fakeBootstrapResult()
6363

6464
// disable MultusAdmissionController
65-
objs, err := renderMultusAdmissionController(config, manifestDir, false, bootstrap, fakeClient)
65+
objs, err := renderMultusAdmissionController(config, manifestDir, false, bootstrap, fakeClient, nil)
6666
g.Expect(err).NotTo(HaveOccurred())
6767
g.Expect(objs).NotTo(ContainElement(HaveKubernetesID("Deployment", "openshift-multus", "multus-admission-controller")))
6868

6969
// enable MultusAdmissionController
7070
enabled := false
7171
config.DisableMultiNetwork = &enabled
72-
objs, err = renderMultusAdmissionController(config, manifestDir, false, bootstrap, fakeClient)
72+
objs, err = renderMultusAdmissionController(config, manifestDir, false, bootstrap, fakeClient, nil)
7373
g.Expect(err).NotTo(HaveOccurred())
7474
g.Expect(objs).To(ContainElement(HaveKubernetesID("Deployment", "openshift-multus", "multus-admission-controller")))
7575

@@ -143,7 +143,7 @@ func TestRenderMultusAdmissonControllerConfigForHyperShift(t *testing.T) {
143143
hsc.ReleaseImage = "MyImage"
144144
hsc.ControlPlaneImage = "MyCPOImage"
145145

146-
objs, err := renderMultusAdmissonControllerConfig(manifestDir, false, bootstrap, fakeClient, hsc, "")
146+
objs, err := renderMultusAdmissonControllerConfig(manifestDir, false, bootstrap, fakeClient, hsc, "", nil)
147147
g.Expect(err).NotTo(HaveOccurred())
148148

149149
// Check rendered object

pkg/network/render.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func Render(operConf *operv1.NetworkSpec, clusterConf *configv1.NetworkSpec, man
6565

6666
// render MultusAdmissionController
6767
o, err = renderMultusAdmissionController(operConf, manifestDir,
68-
bootstrapResult.Infra.ControlPlaneTopology == configv1.ExternalTopologyMode, bootstrapResult, client)
68+
bootstrapResult.Infra.ControlPlaneTopology == configv1.ExternalTopologyMode, bootstrapResult, client, featureGates)
6969
if err != nil {
7070
return nil, progressing, err
7171
}
@@ -805,7 +805,7 @@ func getMultusAdmissionControllerReplicas(bootstrapResult *bootstrap.BootstrapRe
805805
}
806806

807807
// renderMultusAdmissionController generates the manifests of Multus Admission Controller
808-
func renderMultusAdmissionController(conf *operv1.NetworkSpec, manifestDir string, externalControlPlane bool, bootstrapResult *bootstrap.BootstrapResult, client cnoclient.Client) ([]*uns.Unstructured, error) {
808+
func renderMultusAdmissionController(conf *operv1.NetworkSpec, manifestDir string, externalControlPlane bool, bootstrapResult *bootstrap.BootstrapResult, client cnoclient.Client, featureGates featuregates.FeatureGate) ([]*uns.Unstructured, error) {
809809
if *conf.DisableMultiNetwork {
810810
return nil, nil
811811
}
@@ -815,7 +815,7 @@ func renderMultusAdmissionController(conf *operv1.NetworkSpec, manifestDir strin
815815

816816
hsc := hypershift.NewHyperShiftConfig()
817817
objs, err := renderMultusAdmissonControllerConfig(manifestDir, externalControlPlane,
818-
bootstrapResult, client, hsc, names.ManagementClusterName)
818+
bootstrapResult, client, hsc, names.ManagementClusterName, featureGates)
819819
if err != nil {
820820
return nil, err
821821
}

0 commit comments

Comments
 (0)