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

strategic patch doesn't keep order of duplicated elements in the list #65106

Open
redbaron opened this issue Jun 14, 2018 · 40 comments
Open

strategic patch doesn't keep order of duplicated elements in the list #65106

redbaron opened this issue Jun 14, 2018 · 40 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@redbaron
Copy link
Contributor

/kind bug

What happened:
given list with duplicated keys D1

mergingList:
 - name: D1
   value: URL1
 - name: A
   value: x
 - name: D1
   value: URL2

and a patch updating non-duplicated key A:

$setElementOrder/mergingList:
 - name: D1
 - name: A
 - name: D1
mergingList:
 - name: A
   value: z

it reorders keys:

mergingList: 
 - name: D1
   value: URL1
 - name: D1
   value: URL2
 - name: A
   value: z

What you expected to happen:

Order of duplicated keys stays the same

mergingList: 
 - name: D1
   value: URL1
 - name: A
   value: z
 - name: D1
   value: URL2

How to reproduce it (as minimally and precisely as possible):

I created test-case which fails on release-1.10 and master: redbaron@971c1b2

Anything else we need to know?:

I am trying to find out why kubectl creates incorrect patch on apply. Although I can't reproduce it with a simple test case like in this ticket, it look related to it. On a real resource kubectl apply it reorders keys in generated patch, so it generates something like:

$setElementOrder/mergingList:
 - name: D1
 - name: A
 - name: D1
mergingList:
 - name: D1
   value: URL1
 - name: D1
   value: URL2
 - name: A
   value: z

which makes it an invalid patch as order of keys differs from order of values. This reordering might or might not be result of the same underneath bug.

/sig api-machinery

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Jun 14, 2018
@liggitt
Copy link
Member

liggitt commented Jun 14, 2018

If name is the key, it is invalid to have the item twice in the list

@redbaron
Copy link
Contributor Author

there is a testcase which explicitly allows it https://github.com/redbaron/kubernetes/blob/971c1b20e51dd2090a9fd585bafa18282c2984f5/staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch_test.go#L4155-L4226

in our case duplicates where in a list of environment variables in container definition. I'll check tomorrow, but I think that pod was running with duplicates in env list just fine.

@redbaron
Copy link
Contributor Author

confirmed, there are pods with duplicated env variable names, kubernetes is happy to run them, so I'd guess strategic patch should support this case

@liggitt
Copy link
Member

liggitt commented Jun 15, 2018

there are pods with duplicated env variable names, kubernetes is happy to run them, so I'd guess strategic patch should support this case

They run, but are currently undefined with respect to ordering of the duplicate items on patch.

@redbaron
Copy link
Contributor Author

hence this issue :) If k8s allows pod template to be accepted it should allow pod template to be updated on kubectl apply, for that strategic merge should support duplicated entries.

@liggitt
Copy link
Member

liggitt commented Jun 15, 2018

If k8s allows pod template to be accepted it should allow pod template to be updated

The likely outcome is to tighten validation to not accept those templates. See #64907

@wenjiaswe
Copy link
Contributor

/cc @jennybuckley

@redbaron
Copy link
Contributor Author

redbaron commented Jul 4, 2018

Whats the conclusion? Is it NOTABUG?

@liggitt
Copy link
Member

liggitt commented Jul 4, 2018

It is a bug, but the bug is that duplicate keys are allowed in the first place. Fixing that validation in the least disruptive way possible would likely be the best solution

@redbaron
Copy link
Contributor Author

redbaron commented Jul 9, 2018

strategic patch and resource validation are on a different levels, each should do best to ensure correctness. Validating PODs for keys duplications is a good thing of course, but strategic patch should do it's part too: either detect unsupported case and return error or start supporting it, silently nulling key is the worst option IMHO

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/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 Oct 7, 2018
@redbaron
Copy link
Contributor Author

redbaron commented Oct 7, 2018

/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 Oct 7, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/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 5, 2019
@redbaron
Copy link
Contributor Author

redbaron commented Jan 6, 2019

/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 6, 2019
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/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 6, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 6, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

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.

@redbaron
Copy link
Contributor Author

redbaron commented Jun 5, 2019

/reopen

@k8s-ci-robot
Copy link
Contributor

@strmdvr: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

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.

@redbaron
Copy link
Contributor Author

redbaron commented Dec 9, 2021

/reopen

@k8s-ci-robot k8s-ci-robot reopened this Dec 9, 2021
@k8s-ci-robot
Copy link
Contributor

@redbaron: Reopened this issue.

In response to this:

/reopen

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-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Dec 9, 2021
@fedebongio
Copy link
Contributor

/assign @jiahuif @apelisse @leilajal

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 9, 2021
@apelisse
Copy link
Member

We can keep this open, but I don't think it's anyone's priority to fix this. I'm not optimistic.

Also, if you want to keep it open, we should rename the title, maybe something like:

strategic patch doesn't fail on duplicated elements in the list

My understanding is that we can only have duplicates within the patch, which means that we only have to verify that there aren't duplicates when we generate the patch. I don't know how much we would see this as a backward incompatible change or as a bug fix too.

@redbaron
Copy link
Contributor Author

strategic patch doesn't fail on duplicated elements in the list

If we make if fail on duplicates, wouldn't it stop apply to work for containers with duplicated elements? If so, when users try to remove duplicates they wont be able to do so.

@k8s-triage-robot
Copy link

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

This bot triages issues and PRs 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:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

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

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closing this issue.

In response to this:

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

This bot triages issues and PRs 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:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

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

/close

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.

@redbaron
Copy link
Contributor Author

/reopen

@k8s-ci-robot k8s-ci-robot reopened this Jan 10, 2022
@k8s-ci-robot
Copy link
Contributor

@redbaron: Reopened this issue.

In response to this:

/reopen

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 active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs 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:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

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

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closing this issue.

In response to this:

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

This bot triages issues and PRs 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:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

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

/close

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.

@deepflame
Copy link

/reopen

@k8s-ci-robot
Copy link
Contributor

@deepflame: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

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.

@redbaron
Copy link
Contributor Author

/reopen

Is it possible to freeze it? this reopen dance is pointless, bug is confirmed and just waits for resolution one way or another, closing issue doesn't make problem go away.

@k8s-ci-robot
Copy link
Contributor

@redbaron: Reopened this issue.

In response to this:

/reopen

Is it possible to freeze it? this reopen dance is pointless, bug is confirmed and just waits for resolution one way or another, closing issue doesn't make problem go away.

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-ci-robot k8s-ci-robot reopened this Jul 20, 2023
@regularvm
Copy link

what will be the final outcome here - it will be fixed or duplicated environment variables will not be accepted?

@apelisse
Copy link
Member

I'd say it's fairly unlikely that we'll fix this in strategic-merge-patch, but at least we're addressing this in server-side apply right now.

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. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests