-
Notifications
You must be signed in to change notification settings - Fork 220
Closed
Description
Environment
- Flux v2.4.0 (kustomize-controller v1.4.0)
- Kubernetes v1.29.3 (seemingly irrelevant)
Description
If multiple $patch: delete strategic merge patches are provided in a single spec.patches.patch in a kustomize.toolkit.fluxcd.io/v1.Kustomization resource, kustomize-controller fails to reconcile with the following status:
flux-system kustomization.kustomize.toolkit.fluxcd.io/debug 3m20s False kustomize build failed: recovered from kustomize build panic: runtime error: invalid memory address or nil pointer dereference
kustomize-controller log reports the following:
{"level":"error","ts":"2024-12-09T18:41:35.677Z","msg":"Reconciliation failed after 108.007784ms, next try in 1h0m0s","controller":"kustomization","controllerGroup":"kustomize.toolkit.fluxcd.io","controllerKind":"Kustomization","Kustomization":{"name":"debug","namespace":"flux-system"},"namespace":"flux-system","name":"debug","reconcileID":"5eef40e9-8bf0-4a65-a178-eae10b04f877","revision":"main@sha1:4258282a038ab9506e1b37b3a44cc5ab4d38075e","error":"kustomize build failed: recovered from kustomize build panic: runtime error: invalid memory address or nil pointer dereference"}The Kustomization resource needs to look like that:
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: whatever
spec:
patches:
- patch: |-
$patch: delete
apiVersion: v1
kind: Whatever
metadata:
name: whatever1
---
$patch: delete
apiVersion: v1
kind: Whatever
metadata:
name: whatever2Reproduction steps
- Create a fresh Kubernetes cluster and install Flux v2.4.0 in whatever way convenient.
- Create a Kustomization with the following files:
% cat > kustomization.yaml
resources:
- configmaps.yml
% cat > configmaps.yml
apiVersion: v1
kind: Namespace
metadata:
name: debug
---
apiVersion: v1
kind: ConfigMap
metadata:
name: debug1
namespace: debug
---
apiVersion: v1
kind: ConfigMap
metadata:
name: debug2
namespace: debug
---
apiVersion: v1
kind: ConfigMap
metadata:
name: debug3
namespace: debug
- Setup Flux to reconcile this Kustomization while deleting two of the ConfigMaps:
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: debug
namespace: flux-system
spec:
interval: 1h
sourceRef:
kind: GitRepository
name: flux-system
path: ./debug
prune: true
patches:
- patch: |-
$patch: delete
apiVersion: v1
kind: ConfigMap
metadata:
name: debug1
namespace: debug
---
$patch: delete
apiVersion: v1
kind: ConfigMap
metadata:
name: debug2
namespace: debug- Wait for Flux to reconcile and observe the status above.
Additional details
Apparently closely related to kubernetes-sigs/kustomize#5552? The current Flux-specific workaround is simply to split every removal patch into its separate - patch:.
siveriaman
Metadata
Metadata
Assignees
Labels
No labels