Skip to content

[installer, ws-manager]: Use installation shortname in URL templates #10152

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 6 commits into from
May 27, 2022

Conversation

andrew-farries
Copy link
Contributor

Description

ℹ️ ℹ️ ℹ️ ℹ️

This is a second attempt at #10127, which was reverted (#10143) as it broke preview environments. See this comment in #9875. The last commit on the branch is a workaround for the preview environment issue.

ℹ️ ℹ️ ℹ️ ℹ️

As described in #9875, failing image builds currently fail to produce any useful output. A possible cause, as described in this comment, is that the format of the ws-manager WorkspaceURLTemplate strings is wrong.

When we deployed with the old helm chart, these values were set in the relevant configmap like this:

"urlTemplate": "https://{{"{{ .Prefix }}"}}.ws{{- if $.Values.installation.shortname -}}-{{ $.Values.installation.shortname }}{{- end -}}.{{ $.Values.hostname }}",
"portUrlTemplate": "https://{{"{{ .WorkspacePort }}"}}-{{"{{ .Prefix }}"}}.ws{{- if $.Values.installation.shortname -}}-{{ $.Values.installation.shortname }}{{- end -}}.{{ $.Values.hostname }}",

ie, they included a suffix after the ws.

This PR tailors the installer output to produce these URLs in the same way the old helm chart did. Installation short name suffixes like eu-02 are set here:

https://github.com/gitpod-io/ops/blob/main/deploy/production/meta-eu02/app/installer-config.yaml#L6

so the URLs will now look like https://{{ .Prefix }}.ws-eu02.example.com.

Related Issue(s)

Fixes #9875

How to test

I've tested this change in staging by editing the ws-manager configmap in staging to contain the correct URLs, restarting ws-manager and running an image build. I was able to see image build logs as expected:

image

Release Notes

[installer] Use installation shortname when constructing ws-manager URL templates

Documentation

None

@andrew-farries andrew-farries requested review from geropl and a team May 20, 2022 12:39
@andrew-farries
Copy link
Contributor Author

/hold

@github-actions github-actions bot added the team: workspace Issue belongs to the Workspace team label May 20, 2022
@sagor999
Copy link
Contributor

@meysholdt how do you deploy gitpod in preview env?
Andrew placed a workaround to make sure this change doesn't break preview, but I feel like we should instead fix the way we are deploying in preview (remove default as shortname)

@sagor999
Copy link
Contributor

@gitpod-io/platform for comment above. can you provide insight before we will merge this.

@mads-hartmann mads-hartmann self-assigned this May 24, 2022
@mads-hartmann
Copy link
Contributor

@andrew-farries @sagor999 The Werft job uses the Gitpod Installer to generate a config for the installer and then modifies it quite heavily for preview environments. The implementation is here.

The metadata.shortname is set to default by the installer when generating the config. I verified by running the Installer from my workspace off main.

gitpod /workspace/gitpod/install/installer (main) $ go run main.go  init | grep -6 metadata
  inCluster: true
database:
  inCluster: true
disableDefinitelyGp: true
domain: ""
kind: Full
metadata:
  region: local
  shortname: default
objectStorage:
  inCluster: true
observability:
  logLevel: info

So the change you want to make (if you just want to remove metadata.shortname from the config used for preview environments) is something like this

diff --git a/.werft/jobs/build/installer/installer.ts b/.werft/jobs/build/installer/installer.ts
index 52edde6f6..ea2a83671 100644
--- a/.werft/jobs/build/installer/installer.ts
+++ b/.werft/jobs/build/installer/installer.ts
@@ -58,6 +58,7 @@ export class Installer {
         this.options.werft.log(slice, "Adding extra configuration");
         try {
             this.getDevCustomValues(slice)
+            this.configureMetadata(slice)
             this.configureContainerRegistry(slice)
             this.configureDomain(slice)
             this.configureWorkspaces(slice)
@@ -92,6 +93,10 @@ export class Installer {
         exec(`yq m -i ${this.options.installerConfigPath} ${WORKSPACE_SIZE_CONFIG_PATH}`, { slice: slice });
     }
 
+    private configureMetadata(slice: string): void {
+        exec(`yq d -i ${this.options.installerConfigPath} metadata.shortname `, { slice: slice });
+    }
+
     private configureContainerRegistry(slice: string): void {
         exec(`yq w -i ${this.options.installerConfigPath} certificate.name ${this.options.proxySecretName}`, { slice: slice });
         exec(`yq w -i ${this.options.installerConfigPath} containerRegistry.inCluster false`, { slice: slice });

@andrew-farries
Copy link
Contributor Author

Thanks @mads-hartmann. I'm more concerned about the consequences of removing the installation shortname rather than the mechanics of how to do it, given the comment here from @geropl:

cfg.Metadata.InstallationShortname = "default" // TODO(gpl): we're tied to "default" here because that's what we put into static bridges in the past

But I guess we can leave it as the default in the installer and remove it specifically for preview environments.

@mads-hartmann
Copy link
Contributor

mads-hartmann commented May 24, 2022

But I guess we can leave it as the default in the installer and remove it specifically for preview environments.

Yeah I think that's the best option, and that is what the TypeScript diff above should do ☺️ I don't know what consequences of not having the shortname is for preview environments though.

@andrew-farries andrew-farries force-pushed the af/installer-append-shortname-to-url-templates branch 3 times, most recently from 52a10c2 to f4fa140 Compare May 24, 2022 11:05
@andrew-farries andrew-farries requested a review from a team May 24, 2022 11:05
@github-actions github-actions bot added the team: delivery Issue belongs to the self-hosted team label May 24, 2022
@andrew-farries andrew-farries force-pushed the af/installer-append-shortname-to-url-templates branch 4 times, most recently from a3fb0aa to 1800f7b Compare May 24, 2022 13:14
@andrew-farries
Copy link
Contributor Author

I've removed the installation.shortname when deploying to a preview environment. Previews still appear to work.

@sagor999
Copy link
Contributor

sagor999 commented May 24, 2022

/werft run with-clean-slate-deployment=true

👍 started the job as gitpod-build-af-installer-append-shortname-to-url-template.17
(with .werft/ from main)

@sagor999
Copy link
Contributor

@andrew-farries can you rebase your PR? There is a breaking change without which build fails now :(

@andrew-farries andrew-farries force-pushed the af/installer-append-shortname-to-url-templates branch from 1800f7b to e9b4b40 Compare May 25, 2022 08:38
@andrew-farries
Copy link
Contributor Author

andrew-farries commented May 25, 2022

/werft run with-clean-slate-deployment=true

👍 started the job as gitpod-build-af-installer-append-shortname-to-url-template.19
(with .werft/ from main)

@andrew-farries
Copy link
Contributor Author

Tests failing due to this: #10243.

Will rebase again when that's resolved.

@kylos101
Copy link
Contributor

@sagor999 could you test the installer asset produced by this build in an ephemeral cluster? I'm worried this could impact our post processing for ws-proxy.

@kylos101
Copy link
Contributor

@sagor999 could you test the installer asset produced by this build in an ephemeral cluster? I'm worried this could impact our post processing for ws-proxy.

@Furisto wanted to give you a heads up on this, as it could impact our ability to deploy workspace clusters.

@andrew-farries andrew-farries force-pushed the af/installer-append-shortname-to-url-templates branch from e9b4b40 to d0a8c58 Compare May 25, 2022 10:18
@sagor999
Copy link
Contributor

@kylos101 tested ephemeral cluster creation using installer from this branch. All worked fine. Was able to start workspace in that cluster.

Domain: "example.com",
InstallationShortname: "eu02",
ExpectedWorkspaceUrlTemplate: "https://{{ .Prefix }}.ws-eu02.example.com",
ExpectedWorkspacePortURLTemplate: "https://{{ .WorkspacePort }}-{{ .Prefix }}.ws-eu02.example.com",
Copy link
Member

Choose a reason for hiding this comment

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

👍

Domain: "example.com",
InstallationShortname: "",
ExpectedWorkspaceUrlTemplate: "https://{{ .Prefix }}.ws.example.com",
ExpectedWorkspacePortURLTemplate: "https://{{ .WorkspacePort }}-{{ .Prefix }}.ws.example.com",
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

Choose a reason for hiding this comment

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

@andrew-farries We need a test case "with 'default' as installation shortname" to cover all existing self-hosted installations out there I think. That will lead us to the comment above I think.

@geropl
Copy link
Member

geropl commented May 27, 2022

I'm more concerned about the consequences of removing the installation shortname rather than the mechanics of how to do it, given the comment here from @geropl:

@andrew-farries I added that line when making installationShortname editable (again) and kept the "default" instead of moving to "" (empty string), because I did not want to run into migration trouble with existing self-hosted installations.

The problem is that whatever we put into installationShortname is what new workspaceInstances get set as "region". And for the lifetime of a workspace, we need to make sure there is a ws-manager registered for exactly that "region"/"cluster".

But I guess we can leave it as the default in the installer and remove it specifically for preview environments.

💯 This is what I would have done as well.

@@ -113,6 +113,11 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
return nil, err
}

installationShortNameSuffix := ""
if ctx.Config.Metadata.InstallationShortname != "" {
Copy link
Member

Choose a reason for hiding this comment

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

@andrew-farries IMO we need to check for `!= "" && != "default", no? (cmp test cases below)

Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

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

@roboquat roboquat added size/L and removed size/M labels May 27, 2022
@geropl geropl force-pushed the af/installer-append-shortname-to-url-templates branch from 14e2287 to 3bd7592 Compare May 27, 2022 14:19
Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

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

Fixes (my own) complaint with this commit.

@geropl
Copy link
Member

geropl commented May 27, 2022

/unhold

@roboquat roboquat merged commit 6c5ef9a into main May 27, 2022
@roboquat roboquat deleted the af/installer-append-shortname-to-url-templates branch May 27, 2022 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note size/L team: delivery Issue belongs to the self-hosted team team: workspace Issue belongs to the Workspace team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: headless task failed, on imagebuild
7 participants