-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Issue-4292: ConfigMaps items are generated with random order #4785
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mowtschan The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @mowtschan! |
Hi @mowtschan. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
return yaml.JSONToYAML(json) | ||
|
||
m := gyaml.MapSlice{} | ||
if err := gyaml.Unmarshal(json, &m); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What led you to make the change here? This part of the code affects far more than the configmap generator, and I'm surprised we haven't already lost the ordering by the time we get here, i.e. by passing through an unordered data structure here, as Natasha pointed out.
Related to that, I think we need to see a test somewhere more end-to-end to prove that the problem will actually be solved for end users. Notably, the test currently in this PR doesn't pass through the likely problematic code Natasha pointed out, whereas the real generation code path does. I was thinking plugin/builtin/configmapgenerator/ConfigMapGenerator_test.go
but even that would leave off some code paths that could lose the order, so api/krusty/configmaps_test.go
is probably the best choice. Since the order change is non-deterministic, the test should also include many iterations to prove it is stable across invocations.
Supposing for a moment that this is the place the order gets lost, I would like to try not to use "gopkg.in/yaml.v2"
directly if possible. There are many yaml libraries for Go, each with tradeoffs. Where we can, and in newer code, we use our own kyaml, which wraps gopkg.in/yaml.v3
, a 1.2 implementation. We also use sigs.k8s.io/yaml
--which wraps https://github.com/ghodss/yaml
, which in turn wraps gopkg.in/yaml.v2
and is a 1.1 implementation--in older code and in places where we ingest or emit end-user-facing configuration. The latter is for compatibility with kubectl, which uses that lib, and I think it is likely that's why that lib in particular is being used in this specific case. I see it has a func JSONObjectToYAMLObject(j map[string]interface{}) yaml.MapSlice
so please look into that if this is indeed where the change needs to be made.
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
Unfortunately I don't think this PR fixes the linked issue, and I'm going to close it since it has not been updated in three months. If you want to resume this work, please take a look at this comment for pointers on where the change needs to be made and how to test it. /close |
@KnVerey: Closed this PR. In response to this:
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. |
Hi everybody,
in this PR I fixed the Issue #4292. The configMap keys will keep the default order (now they are sorted alphabetically)
Looking forward to your feedback!
Cheers,
Sascha