Use slices instead of maps for service ports to control ordering #10344
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This changes the structure from
map[string]ServicePort
to[]ServicePort
and then extends theServicePort
struct with aName
. This ensure that the ordering of ports is stable and that we have full control over the ordering.We need to be able to control the ordering as the order of ports need to match how Kubernetes will order to ports to avoid creating constant "out of sync" applications in ArgoCD (see internal ticket for specific use-case).
This PR doesn't change the ordering yet. Once this is merged and applied in staging I will go over the resulting ArgoCD diff drift and open a new PR that fixes the ordering.
Update: I suspect that Kubernetes might not care about the order at all and that no follow up PR is needed to make ArgoCD happy; that the constant diff is just because we're randomly ordering the ports every time, so sometimes it doesn't match the order it happened to use last time it rendered the manifests, which causes a diff.
Related Issue(s)
Part of https://github.com/gitpod-io/ops/issues/2472
How to test
I used the Gitpod Installer from this branch on a branch in gitpod-io/ops and verified that the ArgoCD diff produced a valid diff (e.g. that I didn't somehow break the manifests generated by the Installer).
Release Notes
Documentation
N/A