Skip to content

Commit b54f5d1

Browse files
FORK: use a forked version of knative/pkg
Signed-off-by: Mathew Wicks <[email protected]>
1 parent ecd5369 commit b54f5d1

File tree

7 files changed

+53
-13
lines changed

7 files changed

+53
-13
lines changed

go.mod

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ module knative.dev/net-certmanager
22

33
go 1.18
44

5+
// note, we have forked `knative/pkg` to apply some changes:
6+
// - https://github.com/deployKF/knative-pkg/tree/fork-1.13
7+
//
8+
// to get the pseudo-version of the fork, run:
9+
// - go get github.com/deployKF/[email protected]
10+
//
11+
// remember to run `./hack/update-deps.sh` when updating the version
12+
replace knative.dev/pkg => github.com/deployKF/knative-pkg v0.0.0-20241017230044-3db6060cea05
13+
514
require (
615
github.com/cert-manager/cert-manager v1.13.3
716
github.com/ghodss/yaml v1.0.0
@@ -12,7 +21,7 @@ require (
1221
k8s.io/client-go v0.28.5
1322
knative.dev/hack v0.0.0-20240123162936-f3f03ac0ab1a
1423
knative.dev/networking v0.0.0-20240116081125-ce0738abf051
15-
knative.dev/pkg v0.0.0-20240116073220-b488e7be5902
24+
knative.dev/pkg v0.0.0
1625
)
1726

1827
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
7171
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7272
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
7373
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
74+
github.com/deployKF/knative-pkg v0.0.0-20241017230044-3db6060cea05 h1:lKPkJxVmxhvhnfZRdCBL+MuX7Ca/vP3XNHG/A1kG5N4=
75+
github.com/deployKF/knative-pkg v0.0.0-20241017230044-3db6060cea05/go.mod h1:NYk8mMYoLkO7CQWnNkti4YGGnvLxN6MIDbUvtgeo0C0=
7476
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
7577
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
7678
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@@ -688,8 +690,6 @@ knative.dev/hack v0.0.0-20240123162936-f3f03ac0ab1a h1:+4Mdk0Lt3LGAVEI6vYyhfjBlV
688690
knative.dev/hack v0.0.0-20240123162936-f3f03ac0ab1a/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
689691
knative.dev/networking v0.0.0-20240116081125-ce0738abf051 h1:bTRVfwmfu4/7U1YBcgBl1VANAwmal6zkoAI9p7PQwDY=
690692
knative.dev/networking v0.0.0-20240116081125-ce0738abf051/go.mod h1:rdzGL1OVP6VItEiJUN/FTCrDnIzkA6ykhSvaK+0Ne6o=
691-
knative.dev/pkg v0.0.0-20240116073220-b488e7be5902 h1:H6+JJN23fhwYWCHY1339sY6uhIyoUwDy1a8dN233fdk=
692-
knative.dev/pkg v0.0.0-20240116073220-b488e7be5902/go.mod h1:NYk8mMYoLkO7CQWnNkti4YGGnvLxN6MIDbUvtgeo0C0=
693693
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
694694
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
695695
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

vendor/knative.dev/pkg/webhook/configmaps/configmaps.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ type reconciler struct {
5858
vwhlister admissionlisters.ValidatingWebhookConfigurationLister
5959
secretlister corelisters.SecretLister
6060

61-
secretName string
61+
secretName string
62+
disableNamespaceOwnership bool
6263
}
6364

6465
var _ controller.Reconciler = (*reconciler)(nil)
@@ -136,13 +137,15 @@ func (ac *reconciler) reconcileValidatingWebhook(ctx context.Context, caCert []b
136137

137138
webhook := configuredWebhook.DeepCopy()
138139

139-
// Set the owner to namespace.
140-
ns, err := ac.client.CoreV1().Namespaces().Get(ctx, system.Namespace(), metav1.GetOptions{})
141-
if err != nil {
142-
return fmt.Errorf("failed to fetch namespace: %w", err)
140+
if !ac.disableNamespaceOwnership {
141+
// Set the owner to namespace.
142+
ns, err := ac.client.CoreV1().Namespaces().Get(ctx, system.Namespace(), metav1.GetOptions{})
143+
if err != nil {
144+
return fmt.Errorf("failed to fetch namespace: %w", err)
145+
}
146+
nsRef := *metav1.NewControllerRef(ns, corev1.SchemeGroupVersion.WithKind("Namespace"))
147+
webhook.OwnerReferences = []metav1.OwnerReference{nsRef}
143148
}
144-
nsRef := *metav1.NewControllerRef(ns, corev1.SchemeGroupVersion.WithKind("Namespace"))
145-
webhook.OwnerReferences = []metav1.OwnerReference{nsRef}
146149

147150
for i, wh := range webhook.Webhooks {
148151
if wh.Name != webhook.Name {

vendor/knative.dev/pkg/webhook/configmaps/controller.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ func NewAdmissionController(
4747
secretInformer := secretinformer.Get(ctx)
4848
options := webhook.GetOptions(ctx)
4949

50+
// if this environment variable is set, it overrides the value in the Options
51+
disableNamespaceOwnership := webhook.DisableNamespaceOwnershipFromEnv()
52+
if disableNamespaceOwnership != nil {
53+
options.DisableNamespaceOwnership = *disableNamespaceOwnership
54+
}
55+
5056
key := types.NamespacedName{Name: name}
5157

5258
wh := &reconciler{
@@ -61,8 +67,9 @@ func NewAdmissionController(
6167
key: key,
6268
path: path,
6369

64-
constructors: make(map[string]reflect.Value),
65-
secretName: options.SecretName,
70+
constructors: make(map[string]reflect.Value),
71+
secretName: options.SecretName,
72+
disableNamespaceOwnership: options.DisableNamespaceOwnership,
6673

6774
client: client,
6875
vwhlister: vwhInformer.Lister(),

vendor/knative.dev/pkg/webhook/env.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const (
3232
secretNameEnvKey = "WEBHOOK_SECRET_NAME" //nolint:gosec // This is not a hardcoded credential
3333

3434
tlsMinVersionEnvKey = "WEBHOOK_TLS_MIN_VERSION"
35+
36+
disableNamespaceOwnershipEnvKey = "WEBHOOK_DISABLE_NAMESPACE_OWNERSHIP"
3537
)
3638

3739
// PortFromEnv returns the webhook port set by portEnvKey, or default port if env var is not set.
@@ -82,3 +84,15 @@ func TLSMinVersionFromEnv(defaultTLSMinVersion uint16) uint16 {
8284
panic(fmt.Sprintf("the environment variable %q has to be either '1.2' or '1.3'", tlsMinVersionEnvKey))
8385
}
8486
}
87+
88+
func DisableNamespaceOwnershipFromEnv() *bool {
89+
disableNamespaceOwnership := os.Getenv(disableNamespaceOwnershipEnvKey)
90+
if disableNamespaceOwnership == "" {
91+
return nil
92+
}
93+
disableNamespaceOwnershipBool, err := strconv.ParseBool(disableNamespaceOwnership)
94+
if err != nil {
95+
panic(fmt.Sprintf("failed to convert the environment variable %q : %v", disableNamespaceOwnershipEnvKey, err))
96+
}
97+
return &disableNamespaceOwnershipBool
98+
}

vendor/knative.dev/pkg/webhook/webhook.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ type Options struct {
7878
// before shutting down.
7979
GracePeriod time.Duration
8080

81+
// DisableNamespaceOwnership configures if the SYSTEM_NAMESPACE is added as an owner reference to the
82+
// webhook configuration resources. Overridden by the WEBHOOK_DISABLE_NAMESPACE_OWNERSHIP environment variable.
83+
// Disabling can be useful to avoid breaking systems that expect ownership to indicate a true controller
84+
// relationship: https://github.com/knative/serving/issues/15483
85+
DisableNamespaceOwnership bool
86+
8187
// ControllerOptions encapsulates options for creating a new controller,
8288
// including throttling and stats behavior.
8389
ControllerOptions *controller.ControllerOptions

vendor/modules.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ knative.dev/networking/test/test_images/runtime/handlers
947947
knative.dev/networking/test/test_images/timeout
948948
knative.dev/networking/test/test_images/wsserver
949949
knative.dev/networking/test/types
950-
# knative.dev/pkg v0.0.0-20240116073220-b488e7be5902
950+
# knative.dev/pkg v0.0.0 => github.com/deployKF/knative-pkg v0.0.0-20241017230044-3db6060cea05
951951
## explicit; go 1.18
952952
knative.dev/pkg/apis
953953
knative.dev/pkg/apis/duck
@@ -1030,3 +1030,4 @@ sigs.k8s.io/structured-merge-diff/v4/value
10301030
## explicit; go 1.12
10311031
sigs.k8s.io/yaml
10321032
sigs.k8s.io/yaml/goyaml.v2
1033+
# knative.dev/pkg => github.com/deployKF/knative-pkg v0.0.0-20241017230044-3db6060cea05

0 commit comments

Comments
 (0)