Skip to content

Commit 4dd5a53

Browse files
committed
Fix git patches
1 parent dacf3dd commit 4dd5a53

File tree

10 files changed

+152
-36
lines changed

10 files changed

+152
-36
lines changed

hack/patches/020-backstage_plugins_eventmesh_backend.patch

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,3 @@ index 000000000..e23d375d6
8383
+
8484
+ return f.IsEnabled(backstageBackendFeatureFlag)
8585
+}
86-
diff --git a/vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go b/vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go
87-
index b85ec89e4..59bd74dd1 100644
88-
--- a/vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go
89-
+++ b/vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go
90-
@@ -140,6 +140,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ke *v1beta1.KnativeEvent
91-
},
92-
r.transform,
93-
r.handleTLSResources,
94-
+ r.handleBackstageResources,
95-
manifests.Install,
96-
common.CheckDeployments,
97-
common.InstallWebhookConfigs,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go b/vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go
2+
index 1985d7268..f0d86d1f7 100644
3+
--- a/vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go
4+
+++ b/vendor/knative.dev/operator/pkg/reconciler/knativeeventing/knativeeventing.go
5+
@@ -139,6 +139,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ke *v1beta1.KnativeEvent
6+
return nil
7+
},
8+
r.transform,
9+
+ r.handleBackstageResources,
10+
r.handleTLSResources,
11+
manifests.Install,
12+
manifests.SetManifestPaths, // setting path right after applying manifests to populate paths
Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
diff --git a/vendor/knative.dev/operator/pkg/reconciler/knativeserving/knativeserving.go b/vendor/knative.dev/operator/pkg/reconciler/knativeserving/knativeserving.go
2-
index 4b8eca0b0..ccf9f2f67 100644
2+
index 77f091a68..bed9f89c4 100644
33
--- a/vendor/knative.dev/operator/pkg/reconciler/knativeserving/knativeserving.go
44
+++ b/vendor/knative.dev/operator/pkg/reconciler/knativeserving/knativeserving.go
5-
@@ -19,14 +19,15 @@ package knativeserving
5+
@@ -19,14 +19,16 @@ package knativeserving
66
import (
77
"context"
88
"fmt"
9-
+ "os"
10-
9+
+ "os"
10+
1111
- mf "github.com/manifestival/manifestival"
1212
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1313
"k8s.io/client-go/kubernetes"
14-
14+
1515
"knative.dev/pkg/logging"
1616
pkgreconciler "knative.dev/pkg/reconciler"
17-
-
17+
1818
+ mf "github.com/manifestival/manifestival"
1919
+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2020
"knative.dev/operator/pkg/apis/operator/base"
2121
"knative.dev/operator/pkg/apis/operator/v1beta1"
2222
clientset "knative.dev/operator/pkg/client/clientset/versioned"
23-
@@ -90,6 +91,12 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, original *v1beta1.Knative
24-
if manifest == nil {
23+
@@ -91,6 +93,12 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, original *v1beta1.Knative
24+
logger.Warnf("No manifest found; no cluster-scoped resources will be finalized")
2525
return nil
2626
}
2727
+ // we need this to apply the correct namespace to the resources otherwise it defaults to knative-serving
@@ -30,31 +30,31 @@ index 4b8eca0b0..ccf9f2f67 100644
3030
+ logger.Error("Unable to apply kourier namespace transform", err)
3131
+ return nil
3232
+ }
33-
33+
3434
if err := common.Uninstall(manifest); err != nil {
3535
logger.Error("Failed to finalize platform resources", err)
36-
@@ -97,6 +104,20 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, original *v1beta1.Knative
36+
@@ -98,6 +106,20 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, original *v1beta1.Knative
3737
return nil
3838
}
39-
39+
4040
+func overrideKourierNamespace(ks base.KComponent) mf.Transformer {
4141
+ if ns, required := os.LookupEnv("REQUIRED_SERVING_INGRESS_NAMESPACE"); required {
4242
+ nsInjector := mf.InjectNamespace(ns)
43-
+ return func(u *unstructured.Unstructured) error {
44-
+ provider := u.GetLabels()["networking.knative.dev/ingress-provider"]
45-
+ if provider != "kourier" {
46-
+ return nil
43+
+ return func(u *unstructured.Unstructured) error {
44+
+ provider := u.GetLabels()["networking.knative.dev/ingress-provider"]
45+
+ if provider != "kourier" {
46+
+ return nil
47+
+ }
48+
+ return nsInjector(u)
4749
+ }
48-
+ return nsInjector(u)
49-
+ }
5050
+ }
5151
+ return nil
5252
+}
5353
+
5454
// ReconcileKind compares the actual state with the desired, and attempts to
5555
// converge the two.
5656
func (r *Reconciler) ReconcileKind(ctx context.Context, ks *v1beta1.KnativeServing) pkgreconciler.Event {
57-
@@ -117,6 +138,10 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ks *v1beta1.KnativeServi
57+
@@ -118,6 +140,10 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ks *v1beta1.KnativeServi
5858
security.AppendTargetSecurity,
5959
common.AppendAdditionalManifests,
6060
r.appendExtensionManifests,
@@ -64,5 +64,4 @@ index 4b8eca0b0..ccf9f2f67 100644
6464
+ },
6565
r.transform,
6666
manifests.Install,
67-
common.CheckDeployments,
68-
67+
manifests.SetManifestPaths, // setting path right after applying manifests to populate paths

vendor/knative.dev/operator/pkg/apis/operator/v1beta1/knativeeventing_lifecycle.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"os"
2021
"strings"
2122

2223
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -132,7 +133,7 @@ func (es *KnativeEventingStatus) GetVersion() string {
132133

133134
// SetVersion sets the currently installed version of the component.
134135
func (es *KnativeEventingStatus) SetVersion(version string) {
135-
es.Version = version
136+
es.Version = os.Getenv("KNATIVE_EVENTING_VERSION")
136137
}
137138

138139
// GetManifests gets the url links of the manifests.

vendor/knative.dev/operator/pkg/apis/operator/v1beta1/knativeserving_lifecycle.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"os"
2021
"strings"
2122

2223
"knative.dev/operator/pkg/apis/operator"
@@ -132,7 +133,7 @@ func (is *KnativeServingStatus) GetVersion() string {
132133

133134
// SetVersion sets the currently installed version of the component.
134135
func (is *KnativeServingStatus) SetVersion(version string) {
135-
is.Version = version
136+
is.Version = os.Getenv("KNATIVE_SERVING_VERSION")
136137
}
137138

138139
// GetManifests gets the url links of the manifests.

vendor/knative.dev/operator/pkg/client/clientset/versioned/typed/operator/v1beta1/operator_client.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
Copyright 2023 The Knative Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package knativeeventing
18+
19+
import (
20+
"context"
21+
"fmt"
22+
23+
mf "github.com/manifestival/manifestival"
24+
corev1 "k8s.io/api/core/v1"
25+
"k8s.io/apimachinery/pkg/api/meta"
26+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
27+
"knative.dev/eventing/pkg/apis/feature"
28+
29+
"knative.dev/operator/pkg/apis/operator/base"
30+
"knative.dev/operator/pkg/apis/operator/v1beta1"
31+
)
32+
33+
var (
34+
backstageResourcesPred = byLabel("app.kubernetes.io/component", "eventmesh-backend")
35+
)
36+
37+
const (
38+
backstageBackendFeatureFlag = "backstage-backend"
39+
)
40+
41+
func (r *Reconciler) handleBackstageResources(ctx context.Context, manifests *mf.Manifest, comp base.KComponent) error {
42+
instance := comp.(*v1beta1.KnativeEventing)
43+
44+
if isBackstageEnabled(instance) {
45+
return nil
46+
}
47+
48+
// Delete Backstage resources (if present)
49+
toBeDeleted := manifests.Filter(backstageResourcesPred)
50+
if err := toBeDeleted.Delete(mf.IgnoreNotFound(true)); err != nil && !meta.IsNoMatchError(err) {
51+
return fmt.Errorf("failed to delete backstage resources: %v", err)
52+
}
53+
54+
// Filter out Backstage resources from the final list of manifests
55+
*manifests = manifests.Filter(mf.Not(backstageResourcesPred))
56+
57+
return nil
58+
}
59+
60+
func byLabel(key, value string) mf.Predicate {
61+
return func(u *unstructured.Unstructured) bool {
62+
v, ok := u.GetLabels()[key]
63+
return ok && v == value
64+
}
65+
}
66+
67+
func isBackstageEnabled(instance *v1beta1.KnativeEventing) bool {
68+
cmData, ok := getFeaturesConfig(instance)
69+
if !ok {
70+
return false
71+
}
72+
73+
f, err := feature.NewFlagsConfigFromConfigMap(&corev1.ConfigMap{Data: cmData})
74+
if err != nil {
75+
return false
76+
}
77+
78+
return f.IsEnabled(backstageBackendFeatureFlag)
79+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ke *v1beta1.KnativeEvent
139139
return nil
140140
},
141141
r.transform,
142+
r.handleBackstageResources,
142143
r.handleTLSResources,
143144
manifests.Install,
144145
manifests.SetManifestPaths, // setting path right after applying manifests to populate paths

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ package knativeserving
1919
import (
2020
"context"
2121
"fmt"
22+
"os"
2223

23-
mf "github.com/manifestival/manifestival"
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
"k8s.io/client-go/kubernetes"
2626

2727
"knative.dev/pkg/logging"
2828
pkgreconciler "knative.dev/pkg/reconciler"
2929

30+
mf "github.com/manifestival/manifestival"
31+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3032
"knative.dev/operator/pkg/apis/operator/base"
3133
"knative.dev/operator/pkg/apis/operator/v1beta1"
3234
clientset "knative.dev/operator/pkg/client/clientset/versioned"
@@ -91,13 +93,33 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, original *v1beta1.Knative
9193
logger.Warnf("No manifest found; no cluster-scoped resources will be finalized")
9294
return nil
9395
}
96+
// we need this to apply the correct namespace to the resources otherwise it defaults to knative-serving
97+
*manifest, err = manifest.Transform(overrideKourierNamespace(original))
98+
if err != nil {
99+
logger.Error("Unable to apply kourier namespace transform", err)
100+
return nil
101+
}
94102

95103
if err := common.Uninstall(manifest); err != nil {
96104
logger.Error("Failed to finalize platform resources", err)
97105
}
98106
return nil
99107
}
100108

109+
func overrideKourierNamespace(ks base.KComponent) mf.Transformer {
110+
if ns, required := os.LookupEnv("REQUIRED_SERVING_INGRESS_NAMESPACE"); required {
111+
nsInjector := mf.InjectNamespace(ns)
112+
return func(u *unstructured.Unstructured) error {
113+
provider := u.GetLabels()["networking.knative.dev/ingress-provider"]
114+
if provider != "kourier" {
115+
return nil
116+
}
117+
return nsInjector(u)
118+
}
119+
}
120+
return nil
121+
}
122+
101123
// ReconcileKind compares the actual state with the desired, and attempts to
102124
// converge the two.
103125
func (r *Reconciler) ReconcileKind(ctx context.Context, ks *v1beta1.KnativeServing) pkgreconciler.Event {
@@ -118,6 +140,10 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ks *v1beta1.KnativeServi
118140
security.AppendTargetSecurity,
119141
common.AppendAdditionalManifests,
120142
r.appendExtensionManifests,
143+
func(ctx context.Context, manifest *mf.Manifest, component base.KComponent) error {
144+
*manifest = manifest.Filter(mf.Not(mf.All(mf.ByKind("Namespace"), mf.ByName("kourier-system"))))
145+
return nil
146+
},
121147
r.transform,
122148
manifests.Install,
123149
manifests.SetManifestPaths, // setting path right after applying manifests to populate paths

vendor/knative.dev/reconciler-test/pkg/feature/feature.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,15 @@ func DeleteResources(ctx context.Context, t T, refs []corev1.ObjectReference) er
252252
return false, fmt.Errorf("failed to get resource %+v %s/%s: %w", resource, ref.Namespace, ref.Name, err)
253253
}
254254

255+
// Repeat deleting service accounts.
256+
// Workaround for https://issues.redhat.com/browse/OCPBUGS-35731
257+
if resource.Resource == "serviceaccounts" {
258+
err = dc.Resource(resource).Namespace(ref.Namespace).Delete(ctx, ref.Name, metav1.DeleteOptions{})
259+
if err != nil && !apierrors.IsNotFound(err) {
260+
t.Logf("Warning, failed to delete %s/%s of GVR: %+v: %v", ref.Namespace, ref.Name, resource, err)
261+
}
262+
}
263+
255264
lastResource = ref
256265
t.Logf("Resource %+v %s/%s still present", resource, ref.Namespace, ref.Name)
257266
return false, nil

0 commit comments

Comments
 (0)