Skip to content

Commit ac79c86

Browse files
authored
[release-1.35][SRVKS-1301] Update knative/operator to fix webhook issues (#3560)
1 parent 6d93313 commit ac79c86

File tree

10 files changed

+80
-18
lines changed

10 files changed

+80
-18
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ require (
2929
k8s.io/client-go v0.31.0
3030
knative.dev/eventing v0.43.3
3131
knative.dev/eventing-kafka-broker v0.37.0
32-
knative.dev/hack v0.0.0-20240814130635-06f7aff93954
32+
knative.dev/hack v0.0.0-20250117112405-6cb0feb3ac46
3333
knative.dev/networking v0.0.0-20240716111826-bab7f2a3e556
34-
knative.dev/operator v0.42.5
34+
knative.dev/operator v0.42.11-0.20250319103414-9c594ced1a3a
3535
knative.dev/pkg v0.0.0-20240716082220-4355f0c73608
36-
knative.dev/serving v0.42.1
36+
knative.dev/serving v0.42.2
3737
sigs.k8s.io/controller-runtime v0.19.0
3838
sigs.k8s.io/yaml v1.4.0
3939
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,8 +2563,8 @@ knative.dev/hack v0.0.0-20240814135050-f9643117f6a1 h1:3l9x2gly9549Mn+HFWlyf+r/m
25632563
knative.dev/hack v0.0.0-20240814135050-f9643117f6a1/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
25642564
knative.dev/networking v0.0.0-20240716111826-bab7f2a3e556 h1:9OTyJkrjiFh/burZiti3WucGv8Qtt91VJTnXfO5dC2g=
25652565
knative.dev/networking v0.0.0-20240716111826-bab7f2a3e556/go.mod h1:1PosUDkXqoHNzYxtLIwa7LFqSsIXBShHOseAb6XBeEU=
2566-
knative.dev/operator v0.42.5 h1:5sSd60uXx2pt/vVpVsqv5+HQKM09ZGmbk4nnCphDRss=
2567-
knative.dev/operator v0.42.5/go.mod h1:fx8kRLwlk8nh1QErnU3frCsv38dmfheZoHK4j1x86ao=
2566+
knative.dev/operator v0.42.11-0.20250319103414-9c594ced1a3a h1:myjSxDg9JHFtuCkpO4xjr7JqGMOI8zeXgDJggQVKONI=
2567+
knative.dev/operator v0.42.11-0.20250319103414-9c594ced1a3a/go.mod h1:UKR8MNUPxW+eYF42eCd6sGs8H/q8HXrUAnVDWtFiwJc=
25682568
knative.dev/pkg v0.0.0-20240716082220-4355f0c73608 h1:BOiRzcnRS9Z5ruxlCiS/K1/Hb5bUN0X4W3xCegdcYQE=
25692569
knative.dev/pkg v0.0.0-20240716082220-4355f0c73608/go.mod h1:M67lDZ4KbltYSon0Ox4/6qjlZNOIXW4Ldequ81yofbw=
25702570
knative.dev/reconciler-test v0.0.0-20240716134925-00d94f40c470 h1:cdAPZPUszOYpgJY2LNRzz6lFZgD++U89y56jECV/6eU=

hack/patches/020-backstage_plugins_eventmesh_backend.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,4 @@ index f0d4c777d..f622a4bce 100644
9494
+ r.handleBackstageResources,
9595
manifests.Install,
9696
common.CheckDeployments,
97-
common.DeleteObsoleteResources(ctx, ke, r.installed),
97+
common.InstallWebhookConfigs,

vendor/knative.dev/operator/pkg/reconciler/common/deployments.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,31 @@ package common
1818

1919
import (
2020
"context"
21+
"errors"
2122

2223
mf "github.com/manifestival/manifestival"
2324
appsv1 "k8s.io/api/apps/v1"
2425
corev1 "k8s.io/api/core/v1"
25-
"k8s.io/apimachinery/pkg/api/errors"
26+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2627
"k8s.io/client-go/kubernetes/scheme"
28+
2729
"knative.dev/operator/pkg/apis/operator/base"
2830
)
2931

32+
type deploymentsNotReadyError struct{}
33+
34+
var _ error = deploymentsNotReadyError{}
35+
36+
// Error implements the Error() interface of error.
37+
func (err deploymentsNotReadyError) Error() string {
38+
return "deployments not ready"
39+
}
40+
41+
// IsDeploymentsNotReadyError returns true if the given error is a deploymentsNotReadyError.
42+
func IsDeploymentsNotReadyError(err error) bool {
43+
return errors.Is(err, deploymentsNotReadyError{})
44+
}
45+
3046
// CheckDeployments checks all deployments in the given manifest and updates the given
3147
// status with the status of the deployments.
3248
func CheckDeployments(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
@@ -36,7 +52,7 @@ func CheckDeployments(ctx context.Context, manifest *mf.Manifest, instance base.
3652
resource, err := manifest.Client.Get(&u)
3753
if err != nil {
3854
status.MarkDeploymentsNotReady([]string{"all"})
39-
if errors.IsNotFound(err) {
55+
if apierrors.IsNotFound(err) {
4056
return nil
4157
}
4258
return err
@@ -52,7 +68,7 @@ func CheckDeployments(ctx context.Context, manifest *mf.Manifest, instance base.
5268

5369
if len(nonReadyDeployments) > 0 {
5470
status.MarkDeploymentsNotReady(nonReadyDeployments)
55-
return nil
71+
return deploymentsNotReadyError{}
5672
}
5773

5874
status.MarkDeploymentsAvailable()

vendor/knative.dev/operator/pkg/reconciler/common/install.go

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,20 @@ import (
2222
"strings"
2323

2424
mf "github.com/manifestival/manifestival"
25-
"knative.dev/pkg/logging"
25+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
26+
"k8s.io/apimachinery/pkg/runtime/schema"
2627

2728
"knative.dev/operator/pkg/apis/operator/base"
2829
"knative.dev/operator/pkg/apis/operator/v1beta1"
30+
"knative.dev/pkg/logging"
2931
)
3032

3133
var (
32-
role mf.Predicate = mf.Any(mf.ByKind("ClusterRole"), mf.ByKind("Role"))
33-
rolebinding mf.Predicate = mf.Any(mf.ByKind("ClusterRoleBinding"), mf.ByKind("RoleBinding"))
34-
webhook mf.Predicate = mf.Any(mf.ByKind("MutatingWebhookConfiguration"), mf.ByKind("ValidatingWebhookConfiguration"))
35-
gatewayNotMatch = "no matches for kind \"Gateway\""
34+
role mf.Predicate = mf.Any(mf.ByKind("ClusterRole"), mf.ByKind("Role"))
35+
rolebinding mf.Predicate = mf.Any(mf.ByKind("ClusterRoleBinding"), mf.ByKind("RoleBinding"))
36+
webhook mf.Predicate = mf.Any(mf.ByKind("MutatingWebhookConfiguration"), mf.ByKind("ValidatingWebhookConfiguration"))
37+
webhookDependentResources mf.Predicate = byGV(schema.GroupKind{Group: "networking.internal.knative.dev", Kind: "Certificate"})
38+
gatewayNotMatch = "no matches for kind \"Gateway\""
3639
)
3740

3841
// 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
5255
status.MarkInstallFailed(err.Error())
5356
return fmt.Errorf("failed to apply (cluster)rolebindings: %w", err)
5457
}
55-
if err := manifest.Filter(mf.Not(mf.Any(role, rolebinding, webhook))).Apply(); err != nil {
58+
if err := manifest.Filter(mf.Not(mf.Any(role, rolebinding, webhook, webhookDependentResources))).Apply(); err != nil {
5659
status.MarkInstallFailed(err.Error())
5760
if ks, ok := instance.(*v1beta1.KnativeServing); ok && strings.Contains(err.Error(), gatewayNotMatch) &&
5861
(ks.Spec.Ingress == nil || ks.Spec.Ingress.Istio.Enabled) {
@@ -63,10 +66,32 @@ func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponen
6366

6467
return fmt.Errorf("failed to apply non rbac manifest: %w", err)
6568
}
69+
return nil
70+
}
71+
72+
// InstallWebhookConfigs applies the Webhook manifest resources and updates the given status accordingly.
73+
func InstallWebhookConfigs(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
74+
status := instance.GetStatus()
6675
if err := manifest.Filter(webhook).Apply(); err != nil {
6776
status.MarkInstallFailed(err.Error())
6877
return fmt.Errorf("failed to apply webhooks: %w", err)
6978
}
79+
return nil
80+
}
81+
82+
// InstallWebhookDependentResources applies the Webhook dependent resources updates the given status accordingly.
83+
func InstallWebhookDependentResources(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
84+
status := instance.GetStatus()
85+
if err := manifest.Filter(webhookDependentResources).Apply(); err != nil {
86+
status.MarkInstallFailed(err.Error())
87+
return fmt.Errorf("failed to apply webhooks: %w", err)
88+
}
89+
return nil
90+
}
91+
92+
// MarkStatusSuccess updates the component status to success.
93+
func MarkStatusSuccess(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
94+
status := instance.GetStatus()
7095
status.MarkInstallSucceeded()
7196
status.SetVersion(TargetVersion(instance))
7297
return nil
@@ -83,3 +108,9 @@ func Uninstall(manifest *mf.Manifest) error {
83108
}
84109
return nil
85110
}
111+
112+
func byGV(gk schema.GroupKind) mf.Predicate {
113+
return func(u *unstructured.Unstructured) bool {
114+
return u.GroupVersionKind().GroupKind() == gk
115+
}
116+
}

vendor/knative.dev/operator/pkg/reconciler/common/stages.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ type Stages []Stage
3838
func (stages Stages) Execute(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
3939
for _, stage := range stages {
4040
if err := stage(ctx, manifest, instance); err != nil {
41+
if IsDeploymentsNotReadyError(err) {
42+
break
43+
}
4144
return err
4245
}
4346
}

vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ke *v1beta1.KnativeEvent
143143
r.handleBackstageResources,
144144
manifests.Install,
145145
common.CheckDeployments,
146+
common.InstallWebhookConfigs,
147+
manifests.SetManifestPaths,
148+
common.MarkStatusSuccess,
146149
common.DeleteObsoleteResources(ctx, ke, r.installed),
147150
}
148151
manifest := r.manifest.Append()

vendor/knative.dev/operator/pkg/reconciler/knativeserving/knativeserving.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ks *v1beta1.KnativeServi
145145
r.transform,
146146
manifests.Install,
147147
common.CheckDeployments,
148+
common.InstallWebhookConfigs,
149+
common.InstallWebhookDependentResources,
150+
manifests.SetManifestPaths,
151+
common.MarkStatusSuccess,
148152
common.DeleteObsoleteResources(ctx, ks, r.installed),
149153
}
150154
manifest := r.manifest.Append()

vendor/knative.dev/operator/pkg/reconciler/manifests/install.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponen
3434
if err != nil {
3535
return err
3636
}
37+
return nil
38+
}
39+
40+
// SetManifestPaths set the manifest paths in the status of the component
41+
func SetManifestPaths(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
3742
status := instance.GetStatus()
3843
path := common.TargetManifestPathArray(instance)
3944
version := common.TargetVersion(instance)

vendor/modules.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ knative.dev/eventing-kafka-broker/third_party/pkg/client/clientset/versioned
14921492
knative.dev/eventing-kafka-broker/third_party/pkg/client/clientset/versioned/scheme
14931493
knative.dev/eventing-kafka-broker/third_party/pkg/client/clientset/versioned/typed/keda/v1alpha1
14941494
knative.dev/eventing-kafka-broker/third_party/pkg/client/injection/client
1495-
# knative.dev/hack v0.0.0-20240814130635-06f7aff93954 => knative.dev/hack v0.0.0-20240814135050-f9643117f6a1
1495+
# knative.dev/hack v0.0.0-20250117112405-6cb0feb3ac46 => knative.dev/hack v0.0.0-20240814135050-f9643117f6a1
14961496
## explicit; go 1.18
14971497
knative.dev/hack
14981498
# knative.dev/networking v0.0.0-20240716111826-bab7f2a3e556 => knative.dev/networking v0.0.0-20240716111826-bab7f2a3e556
@@ -1524,7 +1524,7 @@ knative.dev/networking/pkg/http/proxy
15241524
knative.dev/networking/pkg/http/stats
15251525
knative.dev/networking/pkg/ingress
15261526
knative.dev/networking/pkg/k8s
1527-
# knative.dev/operator v0.42.5
1527+
# knative.dev/operator v0.42.11-0.20250319103414-9c594ced1a3a
15281528
## explicit; go 1.22
15291529
knative.dev/operator/pkg/apis/operator
15301530
knative.dev/operator/pkg/apis/operator/base
@@ -1667,7 +1667,7 @@ knative.dev/reconciler-test/pkg/resources/serviceaccount
16671667
knative.dev/reconciler-test/pkg/state
16681668
knative.dev/reconciler-test/resources/certificate
16691669
knative.dev/reconciler-test/resources/svc
1670-
# knative.dev/serving v0.42.1 => github.com/openshift-knative/serving v0.10.1-0.20240906121033-618992fcbd27
1670+
# knative.dev/serving v0.42.2 => github.com/openshift-knative/serving v0.10.1-0.20240906121033-618992fcbd27
16711671
## explicit; go 1.22
16721672
knative.dev/serving/pkg/apis/autoscaling
16731673
knative.dev/serving/pkg/apis/autoscaling/v1alpha1

0 commit comments

Comments
 (0)