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

sort output of resource list in velero backup describe --details #1731

Closed
skriss opened this issue Aug 6, 2019 · 10 comments · Fixed by #1741
Closed

sort output of resource list in velero backup describe --details #1731

skriss opened this issue Aug 6, 2019 · 10 comments · Fixed by #1741
Assignees
Labels
Enhancement/User End-User Enhancement to Velero
Milestone

Comments

@skriss
Copy link
Member

skriss commented Aug 6, 2019

It would be nice to sort the resource list in velero backup describe --details -- both the GVK list, and then the resources within each GVK list.

@prydonius
Copy link
Contributor

Do you think the list should be sorted before storing in object storage or just before displaying in the client?

@skriss
Copy link
Member Author

skriss commented Aug 7, 2019

I'd probably sort before storing - means it only has to be done once vs. every time it's read, plus then it's sorted for anyone who looks at the file directly.

@prydonius
Copy link
Contributor

FYI the GVK list is already sorted, which is expected as per json.Marshal documentation

The map keys are sorted and used as JSON object keys
https://golang.org/pkg/encoding/json/#Marshal

So the only thing we need to do is make sure that the resources within each GVK list is sorted.

@skriss
Copy link
Member Author

skriss commented Aug 8, 2019

Hmm, I'm seeing output like this (GVKs not sorted):

Resource List:
  apps/v1/Deployment:
    - nginx-example/nginx-deployment
    - nginx-example-2/nginx-deployment
  v1/ResourceQuota:
    - nginx-example-2/gke-resource-quotas
    - nginx-example/gke-resource-quotas
  v1/ServiceAccount:
    - nginx-example/default
    - nginx-example-2/default
  v1/Secret:
    - nginx-example-2/default-token-stqk2
    - nginx-example/default-token-k7ld2
  apps/v1/ReplicaSet:
    - nginx-example-2/nginx-deployment-fff5f96c9
    - nginx-example-2/nginx-deployment-54f4dbf9d
    - nginx-example/nginx-deployment-b7f757956

@prydonius
Copy link
Contributor

Hmm you're right, it happened to be sorted correctly for me, just checked with a full-namespace backup however and it wasn't sorted. Looking into this

@prydonius
Copy link
Contributor

For some reason I'm not able to reproduce this when trying to encode the same map in the Go playground: https://play.golang.org/p/HdhttP8bOlL

@skriss
Copy link
Member Author

skriss commented Aug 8, 2019

Maybe an issue on the decode? golang/go#27179

@skriss
Copy link
Member Author

skriss commented Aug 8, 2019

Yep, can confirm that it's sorted properly in the file in obj storage, but not in the describe output.

@skriss
Copy link
Member Author

skriss commented Aug 8, 2019

So much for sort once :/

@prydonius
Copy link
Contributor

prydonius commented Aug 8, 2019

Ah of course, thanks for helping track that down! At least we only need to sort the GVK keys, the resource lists within each GVK should have their order preserved. I'll update #1741 to sort the GVKs when printing.

@skriss skriss added this to the v1.1 milestone Aug 9, 2019
@nrb nrb closed this as completed in #1741 Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement/User End-User Enhancement to Velero
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants