Skip to content

Commit

Permalink
Merge pull request openshift#1001 from zeeke/417/OCPBUGS-37668
Browse files Browse the repository at this point in the history
OCPBUGS-37668: [release-4.17]: Fix operator quick restart for SNO
  • Loading branch information
openshift-merge-bot[bot] authored Oct 7, 2024
2 parents 6ffbccd + f521b1e commit 40fc75e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/utils/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func updateValidatingWebhook(c *kubernetes.Clientset) {
webhook, err := validatingWebhookClient.Get(context.TODO(), consts.OperatorWebHookName, metav1.GetOptions{})
if err != nil {
shutdownLog.Error(err, "Error getting webhook")
return
}
webhook.Webhooks[0].FailurePolicy = &failurePolicyIgnore
_, err = validatingWebhookClient.Update(context.TODO(), webhook, metav1.UpdateOptions{})
Expand Down
22 changes: 19 additions & 3 deletions test/conformance/tests/test_sriov_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@ var _ = Describe("[sriov] operator", func() {
})
})

It("should gracefully restart quickly", func() {
DescribeTable("should gracefully restart quickly", func(webookEnabled bool) {
DeferCleanup(setSriovOperatorSpecFlag(operatorNetworkInjectorFlag, webookEnabled))
DeferCleanup(setSriovOperatorSpecFlag(operatorWebhookFlag, webookEnabled))

// This test case ensure leader election process runs smoothly when the operator's pod is restarted.
oldLease, err := clients.CoordinationV1Interface.Leases(operatorNamespace).Get(context.Background(), consts.LeaderElectionID, metav1.GetOptions{})
if k8serrors.IsNotFound(err) {
Expand All @@ -268,7 +271,10 @@ var _ = Describe("[sriov] operator", func() {

g.Expect(newLease.Spec.HolderIdentity).ToNot(Equal(oldLease.Spec.HolderIdentity))
}, 30*time.Second, 5*time.Second).Should(Succeed())
})
},
Entry("webhooks enabled", true),
Entry("webhooks disabled", true),
)

Context("SriovNetworkMetricsExporter", func() {
BeforeEach(func() {
Expand Down Expand Up @@ -2029,26 +2035,34 @@ func defaultFilterPolicy(policy sriovv1.SriovNetworkNodePolicy) bool {
return policy.Spec.DeviceType == "netdevice"
}

func setSriovOperatorSpecFlag(flagName string, flagValue bool) {
func setSriovOperatorSpecFlag(flagName string, flagValue bool) func() {
cfg := sriovv1.SriovOperatorConfig{}
err := clients.Get(context.TODO(), runtimeclient.ObjectKey{
Name: "default",
Namespace: operatorNamespace,
}, &cfg)

ret := func() {}

Expect(err).ToNot(HaveOccurred())
if flagName == operatorNetworkInjectorFlag && cfg.Spec.EnableInjector != flagValue {
cfg.Spec.EnableInjector = flagValue
err = clients.Update(context.TODO(), &cfg)
Expect(err).ToNot(HaveOccurred())
Expect(cfg.Spec.EnableInjector).To(Equal(flagValue))
ret = func() {
setSriovOperatorSpecFlag(flagName, !flagValue)
}
}

if flagName == operatorWebhookFlag && cfg.Spec.EnableOperatorWebhook != flagValue {
cfg.Spec.EnableOperatorWebhook = flagValue
clients.Update(context.TODO(), &cfg)
Expect(err).ToNot(HaveOccurred())
Expect(cfg.Spec.EnableOperatorWebhook).To(Equal(flagValue))
ret = func() {
setSriovOperatorSpecFlag(flagName, !flagValue)
}
}

if flagValue {
Expand All @@ -2064,6 +2078,8 @@ func setSriovOperatorSpecFlag(flagName string, flagValue bool) {
}
}, 1*time.Minute, 10*time.Second).WithOffset(1).Should(Succeed())
}

return ret
}

func setOperatorConfigLogLevel(level int) {
Expand Down

0 comments on commit 40fc75e

Please sign in to comment.