forked from openshift-knative/serverless-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path023-wait-for-webhook-services.patch
137 lines (129 loc) · 6.15 KB
/
023-wait-for-webhook-services.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
diff --git a/vendor/knative.dev/operator/pkg/reconciler/common/deployments.go b/vendor/knative.dev/operator/pkg/reconciler/common/deployments.go
index c0c5afcea..b115f1407 100644
--- a/vendor/knative.dev/operator/pkg/reconciler/common/deployments.go
+++ b/vendor/knative.dev/operator/pkg/reconciler/common/deployments.go
@@ -18,6 +18,7 @@ package common
import (
"context"
+ "time"
mf "github.com/manifestival/manifestival"
appsv1 "k8s.io/api/apps/v1"
@@ -25,6 +26,7 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/kubernetes/scheme"
"knative.dev/operator/pkg/apis/operator/base"
+ "knative.dev/pkg/controller"
)
// CheckDeployments checks all deployments in the given manifest and updates the given
@@ -52,7 +54,7 @@ func CheckDeployments(ctx context.Context, manifest *mf.Manifest, instance base.
if len(nonReadyDeployments) > 0 {
status.MarkDeploymentsNotReady(nonReadyDeployments)
- return nil
+ return controller.NewRequeueAfter(5*time.Second)
}
status.MarkDeploymentsAvailable()
diff --git a/vendor/knative.dev/operator/pkg/reconciler/common/install.go b/vendor/knative.dev/operator/pkg/reconciler/common/install.go
index 4b3b3adaf..0f0925b85 100644
--- a/vendor/knative.dev/operator/pkg/reconciler/common/install.go
+++ b/vendor/knative.dev/operator/pkg/reconciler/common/install.go
@@ -20,6 +20,8 @@ import (
"context"
"fmt"
"strings"
+
+ "k8s.io/apimachinery/pkg/runtime/schema"
mf "github.com/manifestival/manifestival"
"knative.dev/pkg/logging"
@@ -31,8 +33,9 @@ import (
var (
role mf.Predicate = mf.Any(mf.ByKind("ClusterRole"), mf.ByKind("Role"))
rolebinding mf.Predicate = mf.Any(mf.ByKind("ClusterRoleBinding"), mf.ByKind("RoleBinding"))
- webhook mf.Predicate = mf.Any(mf.ByKind("MutatingWebhookConfiguration"), mf.ByKind("ValidatingWebhookConfiguration"))
- gatewayNotMatch = "no matches for kind \"Gateway\""
+ webhook mf.Predicate = mf.Any(mf.ByKind("MutatingWebhookConfiguration"), mf.ByKind("ValidatingWebhookConfiguration"))
+ webhookDependantResources mf.Predicate = mf.ByGVK(schema.GroupVersionKind{"networking.internal.knative.dev", "v1alpha1", "Certificate"})
+ gatewayNotMatch = "no matches for kind \"Gateway\""
)
// Install applies the manifest resources for the given version and updates the given
@@ -52,7 +55,7 @@ func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponen
status.MarkInstallFailed(err.Error())
return fmt.Errorf("failed to apply (cluster)rolebindings: %w", err)
}
- if err := manifest.Filter(mf.Not(mf.Any(role, rolebinding, webhook))).Apply(); err != nil {
+ if err := manifest.Filter(mf.Not(mf.Any(role, rolebinding, webhook, webhookDependantResources))).Apply(); err != nil {
status.MarkInstallFailed(err.Error())
if ks, ok := instance.(*v1beta1.KnativeServing); ok && strings.Contains(err.Error(), gatewayNotMatch) &&
(ks.Spec.Ingress == nil || ks.Spec.Ingress.Istio.Enabled) {
@@ -63,10 +66,29 @@ func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponen
return fmt.Errorf("failed to apply non rbac manifest: %w", err)
}
+ return nil
+}
+
+func InstallWebhookConfigs(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
+ status := instance.GetStatus()
if err := manifest.Filter(webhook).Apply(); err != nil {
status.MarkInstallFailed(err.Error())
return fmt.Errorf("failed to apply webhooks: %w", err)
}
+ return nil
+}
+
+func InstallWebhookDepResources(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
+ status := instance.GetStatus()
+ if err := manifest.Filter(webhookDependantResources).Apply(); err != nil {
+ status.MarkInstallFailed(err.Error())
+ return fmt.Errorf("failed to apply webhooks: %w", err)
+ }
+ return nil
+}
+
+func MarkStatusSuccess(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
+ status := instance.GetStatus()
status.MarkInstallSucceeded()
status.SetVersion(TargetVersion(instance))
return nil
diff --git a/vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go b/vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go
index 7d652cb0d..6c1c10ed7 100644
--- a/vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go
+++ b/vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go
@@ -143,6 +143,9 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ke *v1beta1.KnativeEvent
r.handleBackstageResources,
manifests.Install,
common.CheckDeployments,
+ common.InstallWebhookConfigs,
+ manifests.SetManifestPaths,
+ common.MarkStatusSuccess,
common.DeleteObsoleteResources(ctx, ke, r.installed),
}
manifest := r.manifest.Append()
diff --git a/vendor/knative.dev/operator/pkg/reconciler/knativeserving/knativeserving.go b/vendor/knative.dev/operator/pkg/reconciler/knativeserving/knativeserving.go
index ccf9f2f67..df16adfb5 100644
--- a/vendor/knative.dev/operator/pkg/reconciler/knativeserving/knativeserving.go
+++ b/vendor/knative.dev/operator/pkg/reconciler/knativeserving/knativeserving.go
@@ -145,6 +145,10 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ks *v1beta1.KnativeServi
r.transform,
manifests.Install,
common.CheckDeployments,
+ common.InstallWebhookConfigs,
+ common.InstallWebhookDepResources,
+ manifests.SetManifestPaths,
+ common.MarkStatusSuccess,
common.DeleteObsoleteResources(ctx, ks, r.installed),
}
manifest := r.manifest.Append()
diff --git a/vendor/knative.dev/operator/pkg/reconciler/manifests/install.go b/vendor/knative.dev/operator/pkg/reconciler/manifests/install.go
index dc5bf0d77..275763d5b 100644
--- a/vendor/knative.dev/operator/pkg/reconciler/manifests/install.go
+++ b/vendor/knative.dev/operator/pkg/reconciler/manifests/install.go
@@ -34,6 +34,10 @@ func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponen
if err != nil {
return err
}
+ return nil
+}
+
+func SetManifestPaths(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
status := instance.GetStatus()
path := common.TargetManifestPathArray(instance)
version := common.TargetVersion(instance)