Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kustomize build failed: filter cannot create or delete objects #308

Closed
autarchprinceps opened this issue Mar 31, 2021 · 5 comments · Fixed by #343
Closed

kustomize build failed: filter cannot create or delete objects #308

autarchprinceps opened this issue Mar 31, 2021 · 5 comments · Fixed by #343
Labels
bug Something isn't working

Comments

@autarchprinceps
Copy link

Describe the bug

Using a strategic merge yaml patch in kustomize build with delete option $patch: delete now causes a kustomize build failed: filter cannot create or delete objects exception in flux. Locally this still works with kustomize build, and it did work in older versions of flux onmodified.

To Reproduce

Create a base folder with some kubernetes resources, reference it in a kustomization.yaml, alongside a strategic merge patch containing one resource to be omitted:

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../../../products/base/prometheus/custom-resources
patchesStrategicMerge:
- patch.yaml

patch.yaml

---
$patch: delete  
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: kube2iam.rules
  namespace: monitoring

And point to the folder containing the kustomization.yaml in a Kustomization Resource looking something like this:

apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization
metadata:
  name: prometheus-custom-resources
  namespace: flux-system
spec:
  interval: 10m0s
  path: ./patches/preprod/prometheus/custom-resources
  dependsOn:
  - name: prometheus-release
  - name: traefik-release
  prune: true
  sourceRef:
    kind: GitRepository
    name: flux-system
  validation: client

Expected behavior

kustomize build doesn't contain the element, even though it is present in the bases.

Additional context

  • Kubernetes version: 1.18
  • Git provider: GitHub
  • kustomization controller image version (broken): 0.6 - 0.10
  • kustomization controller image version (definitively still working): 0.5.3
@stefanprodan stefanprodan transferred this issue from fluxcd/flux2 Mar 31, 2021
@stefanprodan
Copy link
Member

I think this is caused by https://github.com/fluxcd/kustomize-controller/blob/main/controllers/kustomization_generator.go#L335-L356 as we have disabled AllowResourceIdChanges.

@stefanprodan
Copy link
Member

stefanprodan commented Apr 1, 2021

Tested this with AllowResourceIdChanges = true and it still breaks, seem that this is a bug in sigs.k8s.io/kustomize/api v0.7.4 and we can't upgrade to latest due to kyaml panics and other breaking changes (fluxcd/flux2#918).

@stefanprodan stefanprodan added the bug Something isn't working label Apr 1, 2021
@autarchprinceps
Copy link
Author

Allow Resoure ID Changes? We definitively also use Kustomization features like namespace override and nameSuffix and the likes. I didn't see an issue there yet, though we also still have 0.5.3 kustomization controller in that cluster as well.

@windnod
Copy link

windnod commented May 7, 2021

same problem on kustomization controller version 0.12.0

@stefanprodan
Copy link
Member

Please give this a try and comment on the PR if it fixes the bug: #343

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants