This repository was archived by the owner on Apr 17, 2025. It is now read-only.
generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 116
This repository was archived by the owner on Apr 17, 2025. It is now read-only.
Resource deletion can occur with AllowPropagate #399
Copy link
Copy link
Open
Labels
lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Description
We have noticed resources of kinds that are configured as AllowPropagate being deleted during our infrastructure provisioning process (even if the resources are not configured to propagate with HNC) if they share the name of a resource of the same kind in the parent namespace.
We were able to reproduce the issue reliably with a build of HNC from the master branch with this small patch that inserts a sleep to make sure the race condition can be reliably hit.
diff --git a/internal/objects/reconciler.go b/internal/objects/reconciler.go
index 81c0d785..9b44ac38 100644
--- a/internal/objects/reconciler.go
+++ b/internal/objects/reconciler.go
@@ -19,6 +19,7 @@ import (
"context"
"fmt"
"reflect"
+ "strings"
"sync"
"time"
@@ -585,8 +586,10 @@ func (r *Reconciler) operate(ctx context.Context, log logr.Logger, act syncActio
}
func (r *Reconciler) deleteObject(ctx context.Context, log logr.Logger, inst *unstructured.Unstructured) error {
-
stats.WriteObject(r.GVK)
+ log.V(1).Info("SLEEPING")
+ time.Sleep(100 * time.Second)
+ log.V(1).Info("DONE SLEEPING")
err := r.Delete(ctx, inst)
if errors.IsNotFound(err) {
log.V(1).Info("The obsolete copy doesn't exist, no more action needed")
diff --git a/internal/webhooks/webhooks.go b/internal/webhooks/webhooks.go
index 32d703d0..951aee27 100644
Steps to Reproduce:
- Create an
HNCConfiguration
configuringconfigmaps
tomode: AllowPropagate
. - Create a parent namespace (
parentns
) and child namespace (childns
). - Create a Configmap
testmap
inparentns
(with no labels that would configure it to propagate with HNC) - Apply a
HierarchyConfiguration
tochildns
settingparentns
as the parent ofchildns
- At this point you should see the
SLEEPING
log line output from the patch above. - Now create a configmap
testmap
inchildns
(with no labels that would configure it to propagate with HNC) - At this point you should see we have two Configmaps
$ k -n parentns get configmap; k -n childns get configmap
NAME DATA AGE
testmap 1 40s
NAME DATA AGE
testmap 1 23s
- Wait for the
DONE SLEEPING
log line. - You should now see one of the configmaps was deleted
$ k -n parentns get configmap; k -n childns get configmap
NAME DATA AGE
testmap 1 40s
NAME DATA AGE
markmsmith and dragorosson-tanium
Metadata
Metadata
Assignees
Labels
lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.Denotes an issue or PR that has aged beyond stale and will be auto-closed.