Skip to content

Commit e831e88

Browse files
committed
fix dynamic conversion webhook
Signed-off-by: Tommy Hughes <[email protected]>
1 parent 3f598d5 commit e831e88

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

pkg/controller/operators/olm/apiservices.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ func (a *Operator) getWebhookCABundle(csv *v1alpha1.ClusterServiceVersion, desc
295295
if err != nil {
296296
continue
297297
}
298-
if crd.Spec.Conversion == nil || crd.Spec.Conversion.Webhook == nil || crd.Spec.Conversion.Webhook.ClientConfig == nil && crd.Spec.Conversion.Webhook.ClientConfig.CABundle == nil {
298+
if crd.Spec.Conversion == nil || crd.Spec.Conversion.Webhook == nil || crd.Spec.Conversion.Webhook.ClientConfig == nil || crd.Spec.Conversion.Webhook.ClientConfig.CABundle == nil {
299299
continue
300300
}
301301

@@ -472,7 +472,7 @@ func (a *Operator) areWebhooksAvailable(csv *v1alpha1.ClusterServiceVersion) (bo
472472
return false, err
473473
}
474474

475-
if crd.Spec.Conversion == nil || crd.Spec.Conversion.Strategy != "Webhook" || crd.Spec.Conversion.Webhook == nil || crd.Spec.Conversion.Webhook.ClientConfig == nil && crd.Spec.Conversion.Webhook.ClientConfig.CABundle == nil {
475+
if crd.Spec.Conversion == nil || crd.Spec.Conversion.Strategy != "Webhook" || crd.Spec.Conversion.Webhook == nil || crd.Spec.Conversion.Webhook.ClientConfig == nil || crd.Spec.Conversion.Webhook.ClientConfig.CABundle == nil {
476476
return false, fmt.Errorf("conversionWebhook not ready")
477477
}
478478
webhookCount++

pkg/controller/operators/olm/operator.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -2359,7 +2359,12 @@ func (a *Operator) updateInstallStatus(csv *v1alpha1.ClusterServiceVersion, inst
23592359
return fmt.Errorf(msg)
23602360
}
23612361

2362-
if !webhooksInstalled || webhookErr != nil {
2362+
if webhookErr != nil {
2363+
csv.SetPhaseWithEventIfChanged(v1alpha1.CSVPhaseInstallReady, requeueConditionReason, fmt.Sprintf("Webhook install failed: %s", webhookErr), now, a.recorder)
2364+
return webhookErr
2365+
}
2366+
2367+
if !webhooksInstalled {
23632368
msg := "webhooks not installed"
23642369
csv.SetPhaseWithEventIfChanged(requeuePhase, requeueConditionReason, msg, now, a.recorder)
23652370
if err := a.csvQueueSet.Requeue(csv.GetNamespace(), csv.GetName()); err != nil {

pkg/controller/operators/olm/operator_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3513,7 +3513,7 @@ func TestWebhookCABundleRetrieval(t *testing.T) {
35133513
), "csv1-dep1", []string{"c1.g1"}),
35143514
},
35153515
crds: []runtime.Object{
3516-
crd("c1", "v1", "g1"),
3516+
crdWithConversionWebhook(crd("c1", "v1", "g1"), nil),
35173517
},
35183518
desc: v1alpha1.WebhookDescription{
35193519
GenerateName: "webhook",

0 commit comments

Comments
 (0)