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

patches has odd behaviour when an entry is missing its' merge key #5369

Open
Gikkman opened this issue Oct 10, 2023 · 5 comments
Open

patches has odd behaviour when an entry is missing its' merge key #5369

Gikkman opened this issue Oct 10, 2023 · 5 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@Gikkman
Copy link

Gikkman commented Oct 10, 2023

What happened?

If you have a Deployment defined with more than one container, and one of those containers is missing their name field, applying a patch on one of the other containers, the properly named containers risks disappearing.

This is similar to issue #5150. In this case however, I have one or more containers that do have their merge key present. It still seems like kustomize drops all containers that has a proper merge key, only keeping the containers that lacks one.

The same phenomena can be seen in other places, for example with an env list. If the base deployment has two proper entries, and a patch tries to add a 3rd missing it's merge key (i.e. it only has a value, no name), then list gets empties completely.

What did you expect to happen?

Given the example I provide below, I'd expected either of these (with nr 2 being the more likely):

  1. The container that lacks a name is kept as-is, since it's name is effectively "" (Or maybe null? I don't know the internals well enough), differentiating it from the other containers.
  2. The container without a merge key is dropped.

In either case, I think kustomize should output some kind of warning, or even fail outright since the input manifest is broken, and entries with missing merge keys can have unexpected consequences (such as a env entry with a missing name).

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

echo "---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deployment.yaml

patches:
- path: patch.yaml
" > kustomization.yaml
echo "---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
spec:
  template:
    spec:
      containers:
        - name: container-1
          image: image-1
        - image: image-2
" > deployment.yaml
echo "---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
spec:
  template:
    spec:
      containers:
        - name: container-1
          image: image-1
          imagePullPolicy: Always
" > patch.yaml
kustomize build .

Expected output

kustomize build .
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
spec:
  template:
    spec:
      containers:
      - name: container-1
         image: image-1
         imagePullPolicy: Always
      - image: image-2

Actual output

kustomize build .
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
spec:
  template:
    spec:
      containers:
      - image: image-2

Kustomize version

5.1.1

Operating system

MacOS

@Gikkman Gikkman added the kind/bug Categorizes issue or PR as related to a bug. label Oct 10, 2023
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Oct 10, 2023
@k8s-ci-robot
Copy link
Contributor

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.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 30, 2024
@Gikkman
Copy link
Author

Gikkman commented Jan 31, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 31, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 30, 2024
@Gikkman
Copy link
Author

Gikkman commented May 1, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

3 participants