kubernetes-sigs / kustomize

Customization of kubernetes YAML configurations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kustomize replaces null with "null" in case of repetetive component inclusion

vlasov-y opened this issue · comments

What happened?

Kustomize replaced null value with string null. So type change have happened because of component included twice.

It may be related to #5519

What did you expect to happen?

Idempotent behavior of the Component if I include it more than once.

How can we reproduce it (as minimally and precisely as possible)?

Here is a script to create example stack.

mkdir null-example
cd null-example
mkdir app hr-timeout-2m

cat <<EOF >./kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- app
# - another-app
# - third-one
# It is a tenant stack that includes several applications
# Some of them have timeout, some of them - not...
components:
# ...so we include component to set timeout on tenant level...
# ...to be sure that all applications have it is set
- hr-timeout-2m
EOF

cat <<EOF >./app/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- hr.yaml
# This application already has a timeout set
components:
- ../hr-timeout-2m
EOF

cat <<EOF >./app/hr.yaml
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: test
spec:
  values:
    containerPorts:
      http: null
      https: 443
EOF

cat <<EOF >./hr-timeout-2m/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
patches:
- patch: |-
    apiVersion: helm.toolkit.fluxcd.io/v2beta2
    kind: HelmRelease
    metadata:
      name: _
    spec:
      interval: 5m
      timeout: 2m
  target:
    kind: HelmRelease
EOF

Expected output

apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: test
spec:
  interval: 5m
  timeout: 2m
  values:
    containerPorts:
      http: null
      https: 443

Actual output

apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: test
spec:
  interval: 5m
  timeout: 2m
  values:
    containerPorts:
      http: "null"
      https: 443

Kustomize version

5.3.0

Operating system

Linux

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

It may be related to #5519

👍 I believe that should fix this issue, but there's not yet a release including that commit. Running with your example (just checked out current master: 8fef99f):

$ go run ./kustomize/ build null-example/
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: test
spec:
  interval: 5m
  timeout: 2m
  values:
    containerPorts:
      http: null
      https: 443