pipe-cd / pipecd

The One CD for All {applications, platforms, operations}
https://pipecd.dev
Apache License 2.0
1.09k stars 153 forks source link

When changing the namespace, the workload remains in the old namespace #5213

Open ffjlabo opened 2 months ago

ffjlabo commented 2 months ago

What happened:

When changing the namespace, the workload remains in the old namespace.

Change_ns_to_test2_by_ffjlabo_·_Pull_Request__227_·_ca-dp_ffjlabo-dev (1)

ca-tech-pipecd-support__Channel__-_CyberAgent_-_1_new_item_-_Slack

before

% kubectl get deployment -n test simple-hoge                                                               
NAME          READY   UP-TO-DATE   AVAILABLE   AGE
simple-hoge   2/2     2            2           12m

after

% kubectl get deployment -n test2 simple-hoge                                                             
NAME          READY   UP-TO-DATE   AVAILABLE   AGE
simple-hoge   2/2     2            2           7m8s

What you expected to happen:

It would be nice to delete the old resource successfully.

How to reproduce it:

Environment:

ffjlabo commented 2 months ago

[Root cause] Resources in the old namespace cannot be deleted because the namespace is not included in the conditions for searching the deletion target resources.

Inside PipeCD, resources are identified by four types: apiVersion, kind, namespace, and name. However, based on the live state and the manifest on git, in the pruning phase, the deletion target seems to be searched for only three things except for the namespace.

https://github.com/pipe-cd/pipecd/blob/c0d5b795de2e89ff6d3c1b7221fb2480c094ce72/pkg/app/piped/executor/kubernetes/sync.go#L131C2-L144C3

khanhtc1202 commented 1 week ago

NOTE:

=> If there is no specific reason, we should keep the spec/behavior of this prune feature the same for both PRIMARY_ROLLOUT and K8S_SYNC stage