Skip to content

Commit 54b314b

Browse files
authored
[ws-scheduler] Make ghost workspaces more effective by integrating them with scheduler (#2552)
* [ws-manager] Do not delete ghost workspace on start * [ws-scheduler] Enable asynchronous binding of pods * [ws-scheduler] Introduce ghosts - remove a ghost before binding a regular workspace - make ghosts "invisible" to strategy * [scheduler] Wait longer on ghost deletion to prevent OOM errors * [scheduler] Make isRegularWorkspace -> makeGhostsInvisible explicit * [scheduler] cancel ghost.Delete if it takes too long (5s) * [ws-scheduler] Add tests for ghost-sepcific state computation * [scheduler] Make sure ghost are only selected for deletion once * [scheduler] delete ghosts: ctxDeleteTimeout > gracePeriod * [scheduler] Don't bind terminated pods * [scheduler] Make all non-ghost workspaces replace ghosts * [scheduler] review comments
1 parent 0b8e2b1 commit 54b314b

File tree

13 files changed

+426
-132
lines changed

13 files changed

+426
-132
lines changed

chart/templates/ws-scheduler-clusterrole.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ rules:
2424
resources:
2525
- "pods"
2626
verbs:
27+
- "delete"
2728
- "get"
2829
- "list"
2930
- "watch"

components/common-go/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ require (
1818
go.uber.org/atomic v1.4.0 // indirect
1919
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
2020
google.golang.org/grpc v1.34.0
21+
k8s.io/api v0.20.1
2122
k8s.io/apimachinery v0.20.1
2223
k8s.io/client-go v0.0.0
2324
)

components/common-go/go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh
484484
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
485485
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
486486
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
487+
k8s.io/api v0.20.1 h1:ud1c3W3YNzGd6ABJlbFfKXBKXO+1KdGfcgGGNgFR03E=
487488
k8s.io/api v0.20.1/go.mod h1:KqwcCVogGxQY3nBlRpwt+wpAMF/KjaCc7RpywacvqUo=
488489
k8s.io/apimachinery v0.20.1 h1:LAhz8pKbgR8tUwn7boK+b2HZdt7MiTu2mkYtFMUjTRQ=
489490
k8s.io/apimachinery v0.20.1/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU=

components/common-go/kubernetes/kubernetes.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/gitpod-io/gitpod/common-go/log"
2020
"github.com/sirupsen/logrus"
2121

22+
corev1 "k8s.io/api/core/v1"
2223
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2324
"k8s.io/client-go/util/flowcontrol"
2425
)
@@ -99,3 +100,31 @@ func (u *UnlimitedRateLimiter) QPS() float32 {
99100
func (u *UnlimitedRateLimiter) Wait(ctx context.Context) error {
100101
return nil
101102
}
103+
104+
func IsWorkspace(pod *corev1.Pod) bool {
105+
val, ok := pod.ObjectMeta.Labels["component"]
106+
return ok && val == "workspace"
107+
}
108+
109+
func IsHeadlessWorkspace(pod *corev1.Pod) bool {
110+
if !IsWorkspace(pod) {
111+
return false
112+
}
113+
114+
val, ok := pod.ObjectMeta.Labels["headless"]
115+
return ok && val == "true"
116+
}
117+
118+
func IsGhostWorkspace(pod *corev1.Pod) bool {
119+
if !IsWorkspace(pod) {
120+
return false
121+
}
122+
123+
val, ok := pod.ObjectMeta.Labels[TypeLabel]
124+
return ok && val == "ghost"
125+
}
126+
127+
func IsNonGhostWorkspace(pod *corev1.Pod) bool {
128+
return IsWorkspace(pod) &&
129+
!IsGhostWorkspace(pod)
130+
}

components/ee/ws-scheduler/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/ws-scheduler

components/ee/ws-scheduler/cmd/test-cluster-scaleup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func buildCurrentState(clientSet *kubernetes.Clientset) (*scheduler.State, error
231231
}
232232

233233
ramSafetyBuffer := res.MustParse("0Mi")
234-
state := scheduler.ComputeState(potentialNodes, pods, nil, &ramSafetyBuffer)
234+
state := scheduler.ComputeState(potentialNodes, pods, nil, &ramSafetyBuffer, false)
235235
return state, nil
236236
}
237237

0 commit comments

Comments
 (0)