Skip to content

Commit

Permalink
avoid putting an ownerref on namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
pepov committed Oct 27, 2020
1 parent 4253c2e commit 6c21059
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/reconciler/native.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,16 @@ func (rec *NativeReconciler) Reconcile(owner runtime.Object) (*reconcile.Result,
}
rec.addRelatedToAnnotation(objectMeta, ownerMeta)
if rec.setControllerRef {
isCrd := false
skipControllerRef := false
switch o.(type) {
case *v1beta1.CustomResourceDefinition:
isCrd = true
skipControllerRef = true
case *v1.CustomResourceDefinition:
isCrd = true
skipControllerRef = true
case *corev1.Namespace:
skipControllerRef = true
}
if !isCrd {
if !skipControllerRef {
// namespaced resource can only own resources in the same namespace
if ownerMeta.GetNamespace() == "" || ownerMeta.GetNamespace() == objectMeta.GetNamespace() {
if err := controllerutil.SetControllerReference(ownerMeta, objectMeta, rec.scheme); err != nil {
Expand Down

0 comments on commit 6c21059

Please sign in to comment.