Skip to content

Commit 2ac3a1e

Browse files
authored
Propagate manifests paths earlier to operator status (#2106)
1 parent e427654 commit 2ac3a1e

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

pkg/reconciler/common/install.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponen
5555
status.MarkInstallFailed(err.Error())
5656
return fmt.Errorf("failed to apply (cluster)rolebindings: %w", err)
5757
}
58+
// Webhook configs are placeholder to be reconciled and configured by webhook controllers, not fully operational yet.
59+
// They are owned by SYSTEM_NAMESPACE and reconciled once webhook deployment is started.
60+
// In some cases a webhook config might be left on the cluster from previous uncompleted install/reinstall attempts.
61+
// Such pre-existing webhook config can block creation of ConfigMap and other resource that are validated, resulting
62+
// in a deadlock installation loop. For this reasons
63+
if err := InstallWebhookConfigs(ctx, manifest, instance); err != nil {
64+
return err
65+
}
5866
if err := manifest.Filter(mf.Not(mf.Any(role, rolebinding, webhook, webhookDependentResources))).Apply(); err != nil {
5967
status.MarkInstallFailed(err.Error())
6068
if ks, ok := instance.(*v1beta1.KnativeServing); ok && strings.Contains(err.Error(), gatewayNotMatch) &&
@@ -71,6 +79,7 @@ func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponen
7179

7280
// InstallWebhookConfigs applies the Webhook manifest resources and updates the given status accordingly.
7381
func InstallWebhookConfigs(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
82+
logging.FromContext(ctx).Debug("Installing webhook configurations")
7483
status := instance.GetStatus()
7584
if err := manifest.Filter(webhook).Apply(); err != nil {
7685
status.MarkInstallFailed(err.Error())

pkg/reconciler/common/install_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ func TestInstall(t *testing.T) {
5656
*clusterRole.DeepCopy(),
5757
*roleBinding.DeepCopy(),
5858
*clusterRoleBinding.DeepCopy(),
59-
*deployment.DeepCopy(),
6059
*mutatingWebhookConfiguration.DeepCopy(),
6160
*validatingWebhookConfiguration.DeepCopy(),
61+
*deployment.DeepCopy(),
6262
}
6363

6464
client := &fakeClient{}
@@ -81,10 +81,6 @@ func TestInstall(t *testing.T) {
8181
t.Fatalf("Install() = %v, want no error", err)
8282
}
8383

84-
if err := InstallWebhookConfigs(context.TODO(), &manifest, instance); err != nil {
85-
t.Fatalf("InstallWebhookConfigs() = %v, want no error", err)
86-
}
87-
8884
if err := MarkStatusSuccess(context.TODO(), &manifest, instance); err != nil {
8985
t.Fatalf("MarkStatusSuccess() = %v, want no error", err)
9086
}

pkg/reconciler/knativeeventing/knativeeventing.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,8 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ke *v1beta1.KnativeEvent
141141
r.transform,
142142
r.handleTLSResources,
143143
manifests.Install,
144+
manifests.SetManifestPaths, // setting path right after applying manifests to populate paths
144145
common.CheckDeployments,
145-
common.InstallWebhookConfigs,
146-
manifests.SetManifestPaths,
147146
common.MarkStatusSuccess,
148147
common.DeleteObsoleteResources(ctx, ke, r.installed),
149148
}

pkg/reconciler/knativeserving/knativeserving.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, original *v1beta1.Knative
8888
}
8989

9090
if manifest == nil {
91+
logger.Warnf("No manifest found; no cluster-scoped resources will be finalized")
9192
return nil
9293
}
9394

@@ -123,10 +124,9 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ks *v1beta1.KnativeServi
123124
r.appendExtensionManifests,
124125
r.transform,
125126
manifests.Install,
127+
manifests.SetManifestPaths, // setting path right after applying manifests to populate paths
126128
common.CheckDeployments,
127-
common.InstallWebhookConfigs,
128129
common.InstallWebhookDependentResources,
129-
manifests.SetManifestPaths,
130130
common.MarkStatusSuccess,
131131
common.DeleteObsoleteResources(ctx, ks, r.installed),
132132
}

0 commit comments

Comments
 (0)