Skip to content

ws-manager-mk2 - or what if we built it today? #9596

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 26 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3735910
Initial ws-manager-mk2 commit
csweichel Apr 24, 2022
aa06acc
[ws-manager-mk2] Add validating webhook
csweichel Apr 24, 2022
db36191
Debug commit: about to start the controller
csweichel Apr 24, 2022
65786b7
[ws-manager-mk2] Add gRPC service
csweichel Apr 24, 2022
0db9403
Integrate content init and disposal
csweichel Apr 26, 2022
25d5565
Move ws-manager-mk2 CRD to API package
csweichel Apr 27, 2022
fe79917
[ws-proxy] Support workspace CRD
csweichel Apr 27, 2022
6a05550
[ws-daemon] Make ws-manager-mk2 compatible
csweichel Apr 27, 2022
72339fc
[ws-manager-mk2] Support workspace stops
csweichel Apr 27, 2022
1da927c
[ws-manager-mk2] Improve status extraction
csweichel Apr 28, 2022
4371e2e
[ws-manager-mk2] Add workspace class support
csweichel May 2, 2022
8ce3993
[ws-manager-mk2] Integrate into installer
csweichel May 3, 2022
47ea0da
[ws-manager-mk2] Add fixture tests
csweichel May 20, 2022
eb8857a
[ws-manager-mk2] Fix the build
csweichel Sep 23, 2022
d5ba070
[ws-manager-mk2] Rework CRD to better match k8s best practice
csweichel Sep 26, 2022
2350e20
[ws-manager-mk2] Introduce first controller test
csweichel Sep 29, 2022
34a56e4
[ws-manager-mk2] Fix build after rebase
csweichel Oct 31, 2022
efd3fda
[ws-manager-mk2] Remove ws-daemon connection
csweichel Nov 22, 2022
f6e12aa
[ws-daemon] Start workspace controller based content init
csweichel Nov 22, 2022
3a3df65
Fix build
Furisto Jan 9, 2023
dedd254
[installer] Add tls for image builder
Furisto Jan 9, 2023
0954bcc
[installer] Update golden files
Furisto Jan 9, 2023
e39d0d5
[ws-daemon] Do not hide errors
Furisto Jan 16, 2023
77515c0
[installer] Fix content init
Furisto Jan 16, 2023
fa3e80b
[werft] Patch registry port in mk2 configmap
Furisto Jan 16, 2023
225c018
[installer] Use new node label and update golden files
Furisto Jan 23, 2023
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
3 changes: 2 additions & 1 deletion .werft/jobs/build/deploy-to-preview-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface DeploymentConfig {
}

export async function deployToPreviewEnvironment(werft: Werft, jobConfig: JobConfig) {
const { version, cleanSlateDeployment, withObservability, installEELicense, workspaceFeatureFlags } = jobConfig;
const { version, cleanSlateDeployment, withObservability, installEELicense, workspaceFeatureFlags, useWsManagerMk2 } = jobConfig;

const { destname, namespace } = jobConfig.previewEnvironment;

Expand Down Expand Up @@ -106,6 +106,7 @@ export async function deployToPreviewEnvironment(werft: Werft, jobConfig: JobCon
workspaceFeatureFlags: workspaceFeatureFlags,
withSlowDatabase: jobConfig.withSlowDatabase,
withDedicatedEmulation: jobConfig.withDedicatedEmulation,
useWsManagerMk2: useWsManagerMk2,
});
try {
werft.log(installerSlices.INSTALL, "deploying using installer");
Expand Down
2 changes: 2 additions & 0 deletions .werft/jobs/build/installer/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type InstallerOptions = {
workspaceFeatureFlags: string[];
withSlowDatabase: boolean;
withDedicatedEmulation: boolean;
useWsManagerMk2: boolean;
};

export class Installer {
Expand All @@ -33,6 +34,7 @@ export class Installer {
GITPOD_WITH_SLOW_DATABASE: this.options.withSlowDatabase,
GITPOD_WITH_EE_LICENSE: this.options.withEELicense,
GITPOD_WITH_DEDICATED_EMU: this.options.withDedicatedEmulation,
GITPOD_WSMANAGER_MK2: this.options.useWsManagerMk2,
};
const variables = Object.entries(environment)
.map(([key, value]) => `${key}="${value}"`)
Expand Down
27 changes: 27 additions & 0 deletions .werft/jobs/build/installer/post-process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,33 @@ while [ "$documentIndex" -le "$DOCS" ]; do
yq m -x -i k8s.yaml -d "$documentIndex" /tmp/"$NAME"overrides.yaml
fi

# overrides for ws-manager-mk2
if [[ "ws-manager-mk2" == "$NAME" ]] && [[ "$KIND" == "ConfigMap" ]]; then
WORK="overrides for $NAME $KIND"
echo "$WORK"
# Change the port we use to connect to registry-facade
# is expected to be reg.<branch-name-with-dashes>.staging.gitpod-dev.com:$REG_DAEMON_PORT
# Change the port we use to connect to ws-daemon
REGISTRY_FACADE_HOST="reg.$DEV_BRANCH.staging.gitpod-dev.com:$REG_DAEMON_PORT"
if [[ -v WITH_VM ]]; then
REGISTRY_FACADE_HOST="reg.$DEV_BRANCH.preview.gitpod-dev.com:$REG_DAEMON_PORT"
fi

# get a copy of the config we're working with
yq r k8s.yaml -d "$documentIndex" > /tmp/"$NAME"-"$KIND"-overrides.yaml

# replace registry port
yq r /tmp/"$NAME"-"$KIND"-overrides.yaml 'data.[config.json]' \
| jq ".manager.registryFacadeHost = \"$REGISTRY_FACADE_HOST\"" > /tmp/"$NAME"-"$KIND"-overrides.json

# create override file
touch /tmp/"$NAME"-"$KIND"-data-overrides.yaml
yq w -i /tmp/"$NAME"-"$KIND"-data-overrides.yaml "data.[config.json]" -- "$(< /tmp/"$NAME"-"$KIND"-overrides.json)"

# merge the updated config map with k8s.yaml
yq m -x -i k8s.yaml -d "$documentIndex" /tmp/"$NAME"-"$KIND"-data-overrides.yaml
fi

# overrides for ws-proxy
if [[ "ws-proxy" == "$NAME" ]] && [[ "$KIND" == "ConfigMap" ]]; then
WORK="overrides for $NAME $KIND"
Expand Down
3 changes: 3 additions & 0 deletions .werft/jobs/build/job-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface JobConfig {
recreatePreview: boolean;
recreateVm: boolean;
withGitHubActions: boolean;
useWsManagerMk2: boolean;
}

export interface PreviewEnvironmentConfig {
Expand Down Expand Up @@ -126,6 +127,7 @@ export function jobConfig(werft: Werft, context: any): JobConfig {
}
const certIssuer = buildConfig["cert-issuer"];

const useWsManagerMk2 = "with-wsman-mk2" in buildConfig;
const repository: Repository = {
owner: context.Repository.owner,
repo: context.Repository.repo,
Expand Down Expand Up @@ -186,6 +188,7 @@ export function jobConfig(werft: Werft, context: any): JobConfig {
withSlowDatabase,
withGitHubActions,
withDedicatedEmulation,
useWsManagerMk2,
};

werft.logOutput(sliceId, JSON.stringify(jobConfig, null, 2));
Expand Down
1 change: 1 addition & 0 deletions components/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ packages:
- components/ws-daemon/seccomp-profile-installer:docker
- components/ws-manager-bridge:docker
- components/ws-manager:docker
- components/ws-manager-mk2:docker
- components/ws-proxy:docker
- components/ide-proxy:docker
- components/ide-metrics:docker
Expand Down
26 changes: 26 additions & 0 deletions components/common-go/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,29 @@ func GetWorkspaceType(pod *corev1.Pod) string {
}
return val
}

// AddUniqueCondition adds a condition if it doesn't exist already
func AddUniqueCondition(conds []metav1.Condition, cond metav1.Condition) []metav1.Condition {
if cond.Reason == "" {
cond.Reason = "unknown"
}

for i, c := range conds {
if c.Type == cond.Type {
conds[i] = cond
return conds
}
}

return append(conds, cond)
}

// GetCondition returns a condition from a list. If not present, it returns nil.
func GetCondition(conds []metav1.Condition, tpe string) *metav1.Condition {
for _, c := range conds {
if c.Type == tpe {
return &c
}
}
return nil
}
2 changes: 1 addition & 1 deletion components/image-builder-mk3/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
Expand Down
5 changes: 2 additions & 3 deletions components/image-builder-mk3/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/image-builder-mk3/pkg/resolve/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (pr *PrecachingRefResolver) StartCaching(ctx context.Context, interval time
for {
for _, c := range pr.Candidates {
var opts []DockerRefResolverOption
if pr.Auth != nil {
if pr.Auth != ((auth.RegistryAuthenticator)(nil)) {
ref, err := reference.ParseNormalizedNamed(c)
if err != nil {
log.WithError(err).WithField("ref", c).Warn("unable to precache reference: cannot parse")
Expand Down
3 changes: 3 additions & 0 deletions components/ws-daemon/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ packages:
- components/content-service-api/go:lib
- components/content-service:lib
- components/ws-daemon-api/go:lib
- components/ws-manager-api/go:lib
env:
- CGO_ENABLED=0
- GOOS=linux
Expand All @@ -31,6 +32,7 @@ packages:
- components/content-service-api/go:lib
- components/content-service:lib
- components/ws-daemon-api/go:lib
- components/ws-manager-api/go:lib
env:
- CGO_ENABLED=0
- GOOS=linux
Expand All @@ -48,6 +50,7 @@ packages:
- components/content-service-api/go:lib
- components/content-service:lib
- components/ws-daemon-api/go:lib
- components/ws-manager-api/go:lib
env:
- CGO_ENABLED=0
- GOOS=linux
Expand Down
4 changes: 4 additions & 0 deletions components/ws-daemon/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ import (
"golang.org/x/xerrors"
"google.golang.org/grpc/credentials/insecure"

"github.com/bombsimon/logrusr/v2"
"github.com/heptiolabs/healthcheck"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/health/grpc_health_v1"
ctrl "sigs.k8s.io/controller-runtime"

"github.com/gitpod-io/gitpod/common-go/baseserver"
common_grpc "github.com/gitpod-io/gitpod/common-go/grpc"
Expand All @@ -45,6 +47,8 @@ var runCmd = &cobra.Command{

createLVMDevices()

ctrl.SetLogger(logrusr.New(log.Log))

health := healthcheck.NewHandler()
srv, err := baseserver.New(grpcServerName,
baseserver.WithGRPC(&cfg.Service),
Expand Down
31 changes: 20 additions & 11 deletions components/ws-daemon/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.19
require (
github.com/alecthomas/jsonschema v0.0.0-20190504002508-159cbd5dba26
github.com/alecthomas/repr v0.0.0-20200325044227-4184120f674c
github.com/bombsimon/logrusr/v2 v2.0.1
github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8
github.com/containerd/cgroups v1.0.4
github.com/containerd/containerd v1.6.15
Expand All @@ -14,6 +15,7 @@ require (
github.com/gitpod-io/gitpod/content-service v0.0.0-00010101000000-000000000000
github.com/gitpod-io/gitpod/content-service/api v0.0.0-00010101000000-000000000000
github.com/gitpod-io/gitpod/ws-daemon/api v0.0.0-00010101000000-000000000000
github.com/gitpod-io/gitpod/ws-manager/api v0.0.0-00010101000000-000000000000
github.com/google/go-cmp v0.5.8
github.com/google/nftables v0.0.0-20220906152720-cbeb0fb1eccf
github.com/google/uuid v1.3.0
Expand All @@ -38,6 +40,7 @@ require (
k8s.io/api v0.24.4
k8s.io/apimachinery v0.24.4
k8s.io/client-go v0.24.4
sigs.k8s.io/controller-runtime v0.11.2
)

require (
Expand Down Expand Up @@ -82,17 +85,18 @@ require (
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/fatih/camelcase v1.0.0 // indirect
github.com/fatih/gomodifytags v1.14.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-logr/logr v1.2.2 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/go-ozzo/ozzo-validation v3.5.0+incompatible // indirect
github.com/go-ozzo/ozzo-validation v3.6.0+incompatible // indirect
github.com/godbus/dbus/v5 v5.0.6 // indirect
github.com/gogo/googleapis v1.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand Down Expand Up @@ -153,7 +157,8 @@ require (
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.10-0.20220218145154-897bd77cd717 // indirect
golang.org/x/tools v0.1.10 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/api v0.97.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220920201722-2b89144ce006 // indirect
Expand All @@ -162,12 +167,14 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.2.2 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
k8s.io/apiextensions-apiserver v0.25.0 // indirect
k8s.io/component-base v0.25.0 // indirect
k8s.io/klog/v2 v2.70.1 // indirect
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/gitpod-io/gitpod/common-go => ../common-go // leeway
Expand All @@ -178,6 +185,8 @@ replace github.com/gitpod-io/gitpod/content-service/api => ../content-service-ap

replace github.com/gitpod-io/gitpod/ws-daemon/api => ../ws-daemon-api/go // leeway

replace github.com/gitpod-io/gitpod/ws-manager/api => ../ws-manager-api/go // leeway

replace k8s.io/api => k8s.io/api v0.24.4 // leeway indirect from components/common-go:lib

replace k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.24.4 // leeway indirect from components/common-go:lib
Expand Down
Loading