#6042·flux2

`flux diff ks --recursive`: 删除父 Kustomization 会默默隐藏其子项的级联删除

作者: asouchang创建于 2026年8月25日更新于 2026年8月25日

Describe the bug

flux diff ks --recursive has an asymmetric behavior when a parent Kustomization is removed from source vs. when its children are modified: - Updating a child resource (e.g., a HelmRelease inside a sub-Kustomization) → the recursive diff correctly descends and shows the drift ✅ - Deleting the parent Kustomization file entirely → the diff only reports the parent KS itself as deleted, silently hiding all of its child resources that would also be pruned ❌ This means a user can delete a top-level Kustomization (e.g., clusters/prod/infra.yaml) and flux diff --recursive gives no indication of the hundreds of HelmRelease, ConfigMap, Secret, etc. objects that would be cascade-deleted when that change is applied. The diff output is misleading and dangerous in a production GitOps workflow. ### Steps to reproduce Given a two-level Kustomization hierarchy: clusters/ prod/ ├── flux-system/ # root KS (name: flux-system) ├── apps.yaml # KS → apps/prod/ ├── infra.yaml # KS (name: infra) → infra/prod/ ← we will delete this infra/ prod/ ├── kustomization.yaml ├── loki/helmrelease.yaml ├── grafana/helmrelease.yaml └── ... (many more HelmReleases) Both KS objects have spec.prune: true. Reproduce: 1. Delete clusters/prod/infra.yaml from the local working tree (do NOT push yet). 2. Run: bash flux diff ks flux-system --path ./clusters/prod --recursive --local-sources GitRepository/flux-system/flux-system=. Actual output: ► Kustomization/flux-system/infra deleted ### Expected behavior Expected output: ► Kustomization/flux-system/infra deleted ► Kustomization/flux-system/infra (cascade): ► HelmRelease/flux-system/loki deleted ► HelmRelease/flux-system/grafana deleted ► HelmRelease/flux-system/prometheus deleted ... (all resources in infra's status.inventory) ### Screenshots and recordings No response ### OS / Distro macos 26.6.2 ### Flux version v2.9.4 ### Flux check ► checking prerequisites ✔ Kubernetes 1.36.1-aliyun.1 >=1.33.0-0 ► checking version in cluster ✔ distribution: flux-v2.9.4 ✔ bootstrapped: false ► checking controllers ✔ helm-controller: deployment ready ✔ ghcr.io/fluxcd/helm-controller:v1.6.3@sha256:16ada99456385100698a5d7adf90aba8a2089d987ab541c9566b6d7b0e897038 ✔ image-automation-controller: deployment ready ✔ ghcr.io/fluxcd/image-automation-controller:v1.2.4@sha256:0286cbba95a2606a006e370052cb642f4370cb42ceea8353b5cba922cf47770c ✔ image-reflector-controller: deployment ready ✔ ghcr.io/fluxcd/image-reflector-controller:v1.2.4@sha256:d63550296dc9a6c2b7c9246cb7ef6e52d7469d5b104cd329622301b46971e255 ✔ kustomize-controller: deployment ready ✔ ghcr.io/fluxcd/kustomize-controller:v1.9.4@sha256:2b8bec54ffb6caf421bd2a6c005d27f567d5dd4db7feb55794fb51fcabd69b8f ✔ notification-controller: deployment ready ✔