Skip to content

Use slices instead of maps for service ports to control ordering #10344

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

Merged
merged 1 commit into from
May 30, 2022

Conversation

mads-hartmann
Copy link
Contributor

@mads-hartmann mads-hartmann commented May 30, 2022

Description

This changes the structure from map[string]ServicePort to []ServicePort and then extends the ServicePort struct with a Name. 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

NONE

Documentation

N/A

@mads-hartmann mads-hartmann marked this pull request as ready for review May 30, 2022 10:22
@mads-hartmann mads-hartmann requested review from a team May 30, 2022 10:22
@github-actions github-actions bot added team: IDE team: delivery Issue belongs to the self-hosted team team: webapp Issue belongs to the WebApp team team: workspace Issue belongs to the Workspace team labels May 30, 2022
Copy link
Contributor

@mustard-mh mustard-mh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed map has random seq, LGTM

Copy link
Member

@easyCZ easyCZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -40,17 +40,18 @@ func DefaultServiceAccount(component string) RenderFunc {
}

type ServicePort struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This struct is now very close to the underlying corev1.ServicePort. We could consider using that instead as the extra struct isn't adding much anymore.

Copy link
Contributor

@nandajavarma nandajavarma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎊

@roboquat roboquat merged commit 7b68fb4 into main May 30, 2022
@roboquat roboquat deleted the mads/fixed-ordering-of-ports branch May 30, 2022 14:44
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed: IDE IDE change is running in production labels May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: IDE IDE change is running in production deployed: webapp Meta team change is running in production release-note-none size/L team: delivery Issue belongs to the self-hosted team team: IDE team: webapp Issue belongs to the WebApp team team: workspace Issue belongs to the Workspace team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants