Skip to content

Commit d2e49a4

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

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

pkg/controller/operators/olm/apiservices.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -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

+31
Original file line numberDiff line numberDiff line change
@@ -3526,6 +3526,37 @@ func TestWebhookCABundleRetrieval(t *testing.T) {
35263526
err: missingCAError,
35273527
},
35283528
},
3529+
{
3530+
name: "ConversionWebhookNotReady",
3531+
initial: initial{
3532+
csvs: []runtime.Object{
3533+
csvWithConversionWebhook(csv("csv1",
3534+
namespace,
3535+
"0.0.0",
3536+
"",
3537+
installStrategy("csv1-dep1",
3538+
nil,
3539+
[]v1alpha1.StrategyDeploymentPermissions{},
3540+
),
3541+
[]*apiextensionsv1.CustomResourceDefinition{crd("c1", "v1", "g1")},
3542+
[]*apiextensionsv1.CustomResourceDefinition{},
3543+
v1alpha1.CSVPhaseInstalling,
3544+
), "csv1-dep1", []string{"c1.g1"}),
3545+
},
3546+
crds: []runtime.Object{
3547+
crdWithConversionWebhook(crd("c1", "v1", "g1"), nil),
3548+
},
3549+
desc: v1alpha1.WebhookDescription{
3550+
GenerateName: "webhook",
3551+
Type: v1alpha1.ConversionWebhook,
3552+
ConversionCRDs: []string{"c1.g1"},
3553+
},
3554+
},
3555+
expected: expected{
3556+
caBundle: nil,
3557+
err: fmt.Errorf("conversionWebhook not ready"),
3558+
},
3559+
},
35293560
{
35303561
name: "RetrieveFromValidatingAdmissionWebhook",
35313562
initial: initial{

0 commit comments

Comments
 (0)