kubernetes.core icon indicating copy to clipboard operation
kubernetes.core copied to clipboard

Kustomize plugin fails with deprecation warnings

Open eriknelson opened this issue 2 years ago • 1 comments

SUMMARY

Kustomize Version: 5.1.0

I'm attempting to use the kustomize plugin to render a manifest and getting the following error:

---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: metallb-system
resources:
  - github.com/metallb/metallb/config/native?ref=v0.13.10

Error output:

fatal: [localhost]: FAILED! => {
    "msg": "kustomize command failed with: # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.\n# Warning: 'patchesJson6902' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.\n"
}

Stepping through the code, it looks like the deprecation warnings are present in stderr, and the plugin simply looks for the presence of the error without any additional nuance. I confirmed that out in this case actually contains the manifest that I'm looking for.

I think my expectation here would be to delegate to the user whether or not to treat deprecation warnings as errors maybe with a switch, with a stricter default of True, but at least that would give me a path to ignoring these.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Kustomize lookup plugin

ANSIBLE VERSION
ansible [core 2.15.0]
  config file = None
  configured module search path = ['/home/ernelson/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /git/nexus.workloads/.venv/lib/python3.11/site-packages/ansible
  ansible collection location = /home/ernelson/.ansible/collections:/usr/share/ansible/collections
  executable location = /git/nexus.workloads/.venv/bin/ansible
  python version = 3.11.4 (main, Jun  9 2023, 14:24:46) [GCC 13.1.1 20230429] (/git/nexus.workloads/.venv/bin/python)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION

Affected collection version: 2.4.0

I'm also seeing this on main.

CONFIGURATION
CONFIG_FILE() = None
EDITOR(env: EDITOR) = nvim
PAGER(env: PAGER) = less
OS / ENVIRONMENT

Arch Linux

STEPS TO REPRODUCE
  • Create the manifest above in metallb/
  • Run a play with the following task:
- name: Set workload dir
  set_fact:
    workload_dir: "metallb"
- name: Render kustomize
  set_fact:
    manifest: "{{lookup('kubernetes.core.kustomize', dir=workload_dir)}}"
EXPECTED RESULTS

Expecting to have the contents of the manifest in the manifest var.

ACTUAL RESULTS

Error seen in summary

eriknelson avatar Jul 29 '23 23:07 eriknelson

This is something that should ultimately be addressed at the kubectl/kustomize level. I would be hesitant to start parsing the output of kustomize to figure out what's an error and what's a warning. A quick search through the kustomize code shows deprecation messages don't follow a standard format. The work being done in https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/3104-introduce-kuberc would likely offer a way to suppress warnings.

We can keep this open and consider it, but I'm inclined to see whether KEP 3104 offers a better solution. As a workaround you could use errors='ignore' or errors='warn'.

gravesm avatar Aug 01 '23 14:08 gravesm