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

Issue-4292: ConfigMaps items are generated with random order #4767

Closed
wants to merge 1 commit into from
Closed

Issue-4292: ConfigMaps items are generated with random order #4767

wants to merge 1 commit into from

Conversation

adilfulara
Copy link

@adilfulara adilfulara commented Aug 21, 2022

  • Preserve order of keys read from KvPairSources

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 21, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: adilfulara / name: Adil Fulara (061a480)

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 21, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @adilfulara!

It looks like this is your first PR to kubernetes-sigs/kustomize 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kustomize has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @adilfulara. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 21, 2022
@adilfulara
Copy link
Author

/easycla

@adilfulara
Copy link
Author

closes #4292

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 21, 2022
@adilfulara
Copy link
Author

apologies @natasha41575 for jumping the gun and assigning the PR to your before review. I have deleted the comment.

@koba1t
Copy link
Member

koba1t commented Aug 25, 2022

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 25, 2022
api/internal/generators/utils.go Outdated Show resolved Hide resolved
api/internal/generators/utils.go Outdated Show resolved Hide resolved
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: adilfulara
Once this PR has been reviewed and has the lgtm label, please ask for approval from natasha41575 by writing /assign @natasha41575 in a comment. For more information see:The Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

@adilfulara: This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 28, 2022
- Maintain input order of entries read from the KvPairSources

Signed-off-by: Adil Fulara <adil.fulara@gmail.com>
@adilfulara
Copy link
Author

@natasha41575 have made the changes suggested. LMK your thoughts.

@mowtschan
Copy link

@adilfulara thanks for the fix. Unfortunately that doesn't work as expected, the final output is still with random order:

$ mkdir /tmp/kustomize
$ cd /tmp/kustomize/
$ git clone https://github.com/adilfulara/kustomize.git
Cloning into 'kustomize'...
remote: Enumerating objects: 77623, done.
remote: Total 77623 (delta 0), reused 0 (delta 0), pack-reused 77623
Receiving objects: 100% (77623/77623), 90.77 MiB | 11.73 MiB/s, done.
Resolving deltas: 100% (45839/45839), done.
$ cd kustomize/
$ git checkout issue-4292
branch 'issue-4292' set up to track 'origin/issue-4292'.
Switched to a new branch 'issue-4292'
$ cd kustomize
$ go build .
$ cat >> kustomization.yaml<< EOF
configMapGenerator:
  - name: test
    literals:
      - EE10D2E63AF9F498=foo
      - FDC41072BFC0BC7F=foo
      - 32E0817AE855A845=foo
      - 0C6B462C403217C4=foo
      - 024233B4DFB484FC=foo
      - 6E7E3021F1821943=foo
      - DFD86A289C3857EF=foo
EOF
$ ls -la
total 45480
drwxr-xr-x   9 user  group       288 Sep  2 10:14 .
drwxr-xr-x  38 user  group      1216 Sep  2 10:13 ..
lrwxr-xr-x   1 user  group        22 Sep  2 10:13 Makefile -> ../Makefile-modules.mk
drwxr-xr-x   9 user  group       288 Sep  2 10:13 commands
-rw-r--r--   1 user  group      2152 Sep  2 10:13 go.mod
-rw-r--r--   1 user  group     23139 Sep  2 10:13 go.sum
-rw-r--r--   1 user  group       252 Sep  2 10:14 kustomization.yaml
-rwxr-xr-x   1 user  group  23246722 Sep  2 10:14 kustomize
-rw-r--r--   1 user  group       292 Sep  2 10:13 main.go
$ ./kustomize build .
apiVersion: v1
data:
  0C6B462C403217C4: foo
  6E7E3021F1821943: foo
  32E0817AE855A845: foo
  024233B4DFB484FC: foo
  DFD86A289C3857EF: foo
  EE10D2E63AF9F498: foo
  FDC41072BFC0BC7F: foo
kind: ConfigMap
metadata:
  name: test-7mt6kd57dt
$ ./kustomize build .
apiVersion: v1
data:
  024233B4DFB484FC: foo
  0C6B462C403217C4: foo
  6E7E3021F1821943: foo
  32E0817AE855A845: foo
  DFD86A289C3857EF: foo
  EE10D2E63AF9F498: foo
  FDC41072BFC0BC7F: foo
kind: ConfigMap
metadata:
  name: test-7mt6kd57dt

@adilfulara
Copy link
Author

adilfulara commented Sep 3, 2022

@adilfulara thanks for the fix. Unfortunately that doesn't work as expected, the final output is still with random order:

$ mkdir /tmp/kustomize
$ cd /tmp/kustomize/
$ git clone https://github.com/adilfulara/kustomize.git
Cloning into 'kustomize'...
remote: Enumerating objects: 77623, done.
remote: Total 77623 (delta 0), reused 0 (delta 0), pack-reused 77623
Receiving objects: 100% (77623/77623), 90.77 MiB | 11.73 MiB/s, done.
Resolving deltas: 100% (45839/45839), done.
$ cd kustomize/
$ git checkout issue-4292
branch 'issue-4292' set up to track 'origin/issue-4292'.
Switched to a new branch 'issue-4292'
$ cd kustomize
$ go build .
$ cat >> kustomization.yaml<< EOF
configMapGenerator:
  - name: test
    literals:
      - EE10D2E63AF9F498=foo
      - FDC41072BFC0BC7F=foo
      - 32E0817AE855A845=foo
      - 0C6B462C403217C4=foo
      - 024233B4DFB484FC=foo
      - 6E7E3021F1821943=foo
      - DFD86A289C3857EF=foo
EOF
$ ls -la
total 45480
drwxr-xr-x   9 user  group       288 Sep  2 10:14 .
drwxr-xr-x  38 user  group      1216 Sep  2 10:13 ..
lrwxr-xr-x   1 user  group        22 Sep  2 10:13 Makefile -> ../Makefile-modules.mk
drwxr-xr-x   9 user  group       288 Sep  2 10:13 commands
-rw-r--r--   1 user  group      2152 Sep  2 10:13 go.mod
-rw-r--r--   1 user  group     23139 Sep  2 10:13 go.sum
-rw-r--r--   1 user  group       252 Sep  2 10:14 kustomization.yaml
-rwxr-xr-x   1 user  group  23246722 Sep  2 10:14 kustomize
-rw-r--r--   1 user  group       292 Sep  2 10:13 main.go
$ ./kustomize build .
apiVersion: v1
data:
  0C6B462C403217C4: foo
  6E7E3021F1821943: foo
  32E0817AE855A845: foo
  024233B4DFB484FC: foo
  DFD86A289C3857EF: foo
  EE10D2E63AF9F498: foo
  FDC41072BFC0BC7F: foo
kind: ConfigMap
metadata:
  name: test-7mt6kd57dt
$ ./kustomize build .
apiVersion: v1
data:
  024233B4DFB484FC: foo
  0C6B462C403217C4: foo
  6E7E3021F1821943: foo
  32E0817AE855A845: foo
  DFD86A289C3857EF: foo
  EE10D2E63AF9F498: foo
  FDC41072BFC0BC7F: foo
kind: ConfigMap
metadata:
  name: test-7mt6kd57dt

looks related to golang/go#27179

The order is preserved until, the Resource is converted to YAML. As an intermediate step for YAML conversion, JSON is used and thats where the order is lost. So Resource byte buff -> JSON -> YAML. See here

Open to suggestion on a approach before getting into an area which affects other portions of the binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants