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

[installer] Make ws-manager-bridge configurable #9760

Merged
merged 2 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions install/installer/pkg/components/ws-manager-bridge/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/gitpod-io/gitpod/installer/pkg/common"
wsmanager "github.com/gitpod-io/gitpod/installer/pkg/components/ws-manager"
"github.com/gitpod-io/gitpod/installer/pkg/config/v1"
"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"
)

var Objects = common.CompositeRenderFunc(
Expand All @@ -20,9 +20,17 @@ var Objects = common.CompositeRenderFunc(
)

func WSManagerList(ctx *common.RenderContext) []WorkspaceCluster {
skipSelf := false
_ = ctx.WithExperimental(func(cfg *experimental.Config) error {
if cfg.WebApp != nil && cfg.WebApp.WorkspaceManagerBridge != nil {
skipSelf = cfg.WebApp.WorkspaceManagerBridge.SkipSelf
}
return nil
})

// Registering a local cluster ws-manager only makes sense when we actually deploy one,
// (ie when we are doing a full self hosted installation rather than a SaaS install to gitpod.io).
if ctx.Config.Kind != config.InstallationFull {
if skipSelf {
return []WorkspaceCluster{}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
// Licensed under the MIT License. See License-MIT.txt in the project root for license information.

package wsmanagerbridge

import (
"github.com/gitpod-io/gitpod/installer/pkg/common"
"github.com/gitpod-io/gitpod/installer/pkg/config/v1"
"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"
"github.com/gitpod-io/gitpod/installer/pkg/config/versions"
"github.com/stretchr/testify/require"
"testing"
)

func TestWorkspaceManagerList_WhenSkipSelfIsSet(t *testing.T) {
testCases := []struct {
SkipSelf bool
ExpectWorkspaceClusters bool
}{
{SkipSelf: true, ExpectWorkspaceClusters: false},
{SkipSelf: false, ExpectWorkspaceClusters: true},
}

for _, testCase := range testCases {
ctx := renderContextWithConfig(t, testCase.SkipSelf)

wsclusters := WSManagerList(ctx)
if testCase.ExpectWorkspaceClusters {
require.NotEmptyf(t, wsclusters, "expected to render workspace clusters when skipSelf=%v", testCase.SkipSelf)
} else {
require.Emptyf(t, wsclusters, "expected not to render workspace clusters when skipSelf=%v", testCase.SkipSelf)
}
}
}

func renderContextWithConfig(t *testing.T, skipSelf bool) *common.RenderContext {
ctx, err := common.NewRenderContext(config.Config{
Experimental: &experimental.Config{
WebApp: &experimental.WebAppConfig{
WorkspaceManagerBridge: &experimental.WsManagerBridgeConfig{
SkipSelf: skipSelf,
},
},
},
}, versions.Manifest{
Components: versions.Components{
PublicAPIServer: versions.Versioned{
Version: "commit-test-latest",
},
},
}, "test-namespace")
require.NoError(t, err)

return ctx
}
13 changes: 9 additions & 4 deletions install/installer/pkg/config/v1/experimental/experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ type WorkspaceTemplates struct {
}

type WebAppConfig struct {
PublicAPI *PublicAPIConfig `json:"publicApi,omitempty"`
Server *ServerConfig `json:"server,omitempty"`
ProxyConfig *ProxyConfig `json:"proxy,omitempty"`
UsePodAntiAffinity bool `json:"usePodAntiAffinity"`
PublicAPI *PublicAPIConfig `json:"publicApi,omitempty"`
Server *ServerConfig `json:"server,omitempty"`
ProxyConfig *ProxyConfig `json:"proxy,omitempty"`
WorkspaceManagerBridge *WsManagerBridgeConfig `json:"wsManagerBridge,omitempty"`
UsePodAntiAffinity bool `json:"usePodAntiAffinity"`
}

type WorkspaceDefaults struct {
Expand All @@ -121,6 +122,10 @@ type GithubApp struct {
CertSecretName string `json:"certSecretName"`
}

type WsManagerBridgeConfig struct {
SkipSelf bool `json:"skipSelf"`
}

type ServerConfig struct {
WorkspaceDefaults WorkspaceDefaults `json:"workspaceDefaults"`
OAuthServer OAuthServer `json:"oauthServer"`
Expand Down