Skip to content

Commit

Permalink
[ws-daemon] Store only annotations instead of pod
Browse files Browse the repository at this point in the history
  • Loading branch information
Furisto authored and roboquat committed Aug 5, 2022
1 parent 0bc5458 commit 225344b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
5 changes: 2 additions & 3 deletions components/ws-daemon/pkg/cpulimit/cpulimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/gitpod-io/gitpod/common-go/log"
"github.com/sirupsen/logrus"
"golang.org/x/xerrors"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
)

Expand All @@ -23,7 +22,7 @@ type Workspace struct {
NrThrottled uint64
Usage CPUTime
QoS int
Pod *corev1.Pod
Annotations map[string]string
}

type WorkspaceHistory struct {
Expand Down Expand Up @@ -253,7 +252,7 @@ type annotationLimiter struct {
}

func (a annotationLimiter) Limit(wsh *WorkspaceHistory) (Bandwidth, error) {
value, ok := wsh.LastUpdate.Pod.Annotations[a.Annotation]
value, ok := wsh.LastUpdate.Annotations[a.Annotation]
if !ok {
return 0, xerrors.Errorf("no annotation named %s found on workspace %s", a.Annotation, wsh.ID)
}
Expand Down
19 changes: 9 additions & 10 deletions components/ws-daemon/pkg/cpulimit/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/gitpod-io/gitpod/common-go/log"
"github.com/gitpod-io/gitpod/common-go/util"
"github.com/gitpod-io/gitpod/ws-daemon/pkg/dispatch"
corev1 "k8s.io/api/core/v1"
)

// Config configures the containerd resource governer dispatch
Expand Down Expand Up @@ -101,10 +100,10 @@ type DispatchListener struct {
}

type workspace struct {
CFS CFSController
OWI logrus.Fields
HardLimit ResourceLimiter
Pod *corev1.Pod
CFS CFSController
OWI logrus.Fields
HardLimit ResourceLimiter
Annotations map[string]string

lastThrottled uint64
}
Expand Down Expand Up @@ -143,7 +142,7 @@ func (d *DispatchListener) source(context.Context) ([]Workspace, error) {
ID: id,
NrThrottled: throttled,
Usage: usage,
Pod: w.Pod,
Annotations: w.Annotations,
})
}
return res, nil
Expand Down Expand Up @@ -191,9 +190,9 @@ func (d *DispatchListener) WorkspaceAdded(ctx context.Context, ws *dispatch.Work
}

d.workspaces[ws.InstanceID] = &workspace{
CFS: controller,
OWI: ws.OWI(),
Pod: ws.Pod,
CFS: controller,
OWI: ws.OWI(),
Annotations: ws.Pod.Annotations,
}
go func() {
<-ctx.Done()
Expand All @@ -219,7 +218,7 @@ func (d *DispatchListener) WorkspaceUpdated(ctx context.Context, ws *dispatch.Wo
return xerrors.Errorf("received update for a workspace we haven't seen before: %s", ws.InstanceID)
}

wsinfo.Pod = ws.Pod
wsinfo.Annotations = ws.Pod.Annotations
return nil
}

Expand Down

0 comments on commit 225344b

Please sign in to comment.