Skip to content

Commit c3062ae

Browse files
authored
Make webhook owner references not a controller (#3255)
We setup namespace as the owner of the webhooks in order to clean up instances where a user deletes the namespace. This has issues with ArgoCD which we've included a workaround. But an upcoming ArgoCD PR will handle owner references properly if it is not a 'controller=true' reference. This PR changes the owner reference to not be a controlling one. We still block owner deletion because that was the original intent of adding the owner reference.
1 parent e53fcbb commit c3062ae

File tree

6 files changed

+6
-0
lines changed

6 files changed

+6
-0
lines changed

webhook/configmaps/configmaps.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ func (ac *reconciler) reconcileValidatingWebhook(ctx context.Context, caCert []b
146146
return fmt.Errorf("failed to fetch namespace: %w", err)
147147
}
148148
nsRef := *metav1.NewControllerRef(ns, corev1.SchemeGroupVersion.WithKind("Namespace"))
149+
nsRef.Controller = ptr.Bool(false)
149150
webhook.OwnerReferences = []metav1.OwnerReference{nsRef}
150151
}
151152

webhook/configmaps/table_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func TestReconcile(t *testing.T) {
6666
},
6767
}
6868
nsRef := *metav1.NewControllerRef(ns, corev1.SchemeGroupVersion.WithKind("Namespace"))
69+
nsRef.Controller = ptr.Bool(false)
6970
expectedOwnerReferences := []metav1.OwnerReference{nsRef}
7071

7172
ruleScope := admissionregistrationv1.NamespacedScope

webhook/resourcesemantics/defaulting/defaulting.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ func (ac *reconciler) reconcileMutatingWebhook(ctx context.Context, caCert []byt
232232
return fmt.Errorf("failed to fetch namespace: %w", err)
233233
}
234234
nsRef := *metav1.NewControllerRef(ns, corev1.SchemeGroupVersion.WithKind("Namespace"))
235+
nsRef.Controller = ptr.Bool(false)
235236
current.OwnerReferences = []metav1.OwnerReference{nsRef}
236237
}
237238

webhook/resourcesemantics/defaulting/table_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func TestReconcile(t *testing.T) {
6767
},
6868
}
6969
nsRef := *metav1.NewControllerRef(ns, corev1.SchemeGroupVersion.WithKind("Namespace"))
70+
nsRef.Controller = ptr.Bool(false)
7071
expectedOwnerReferences := []metav1.OwnerReference{nsRef}
7172

7273
// This is the namespace selector setup

webhook/resourcesemantics/validation/reconcile_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ func (ac *reconciler) reconcileValidatingWebhook(ctx context.Context, caCert []b
201201
return fmt.Errorf("failed to fetch namespace: %w", err)
202202
}
203203
nsRef := *metav1.NewControllerRef(ns, corev1.SchemeGroupVersion.WithKind("Namespace"))
204+
nsRef.Controller = ptr.Bool(false)
204205
current.OwnerReferences = []metav1.OwnerReference{nsRef}
205206
}
206207

webhook/resourcesemantics/validation/reconcile_config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func TestReconcile(t *testing.T) {
6868
},
6969
}
7070
nsRef := *metav1.NewControllerRef(ns, corev1.SchemeGroupVersion.WithKind("Namespace"))
71+
nsRef.Controller = ptr.Bool(false)
7172
expectedOwnerReferences := []metav1.OwnerReference{nsRef}
7273

7374
// This is the namespace selector setup

0 commit comments

Comments
 (0)