Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/ws-daemon/pkg/daemon/config.go
2501 views
1
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package daemon
6
7
import (
8
"context"
9
10
"github.com/gitpod-io/gitpod/ws-daemon/pkg/cgroup"
11
"github.com/gitpod-io/gitpod/ws-daemon/pkg/container"
12
"github.com/gitpod-io/gitpod/ws-daemon/pkg/content"
13
"github.com/gitpod-io/gitpod/ws-daemon/pkg/cpulimit"
14
"github.com/gitpod-io/gitpod/ws-daemon/pkg/diskguard"
15
"github.com/gitpod-io/gitpod/ws-daemon/pkg/iws"
16
"github.com/gitpod-io/gitpod/ws-daemon/pkg/netlimit"
17
"k8s.io/apimachinery/pkg/api/resource"
18
)
19
20
// Config configures the workspace node daemon
21
type Config struct {
22
Runtime RuntimeConfig `json:"runtime"`
23
24
Content content.Config `json:"content"`
25
Uidmapper iws.UidmapperConfig `json:"uidmapper"`
26
CPULimit cpulimit.Config `json:"cpulimit"`
27
IOLimit IOLimitConfig `json:"ioLimit"`
28
ProcLimit int64 `json:"procLimit"`
29
NetLimit netlimit.Config `json:"netlimit"`
30
OOMScores cgroup.OOMScoreAdjConfig `json:"oomScores"`
31
DiskSpaceGuard diskguard.Config `json:"disk"`
32
WorkspaceController WorkspaceControllerConfig `json:"workspaceController"`
33
34
RegistryFacadeHost string `json:"registryFacadeHost,omitempty"`
35
}
36
37
type WorkspaceControllerConfig struct {
38
MaxConcurrentReconciles int `json:"maxConcurrentReconciles,omitempty"`
39
}
40
41
type RuntimeConfig struct {
42
Container *container.Config `json:"containerRuntime"`
43
Kubeconfig string `json:"kubeconfig"`
44
KubernetesNamespace string `json:"namespace"`
45
SecretsNamespace string `json:"secretsNamespace"`
46
47
WorkspaceCIDR string `json:"workspaceCIDR,omitempty"`
48
}
49
50
type IOLimitConfig struct {
51
WriteBWPerSecond resource.Quantity `json:"writeBandwidthPerSecond"`
52
ReadBWPerSecond resource.Quantity `json:"readBandwidthPerSecond"`
53
WriteIOPS int64 `json:"writeIOPS"`
54
ReadIOPS int64 `json:"readIOPS"`
55
}
56
57
type ConfigReloader interface {
58
ReloadConfig(context.Context, *Config) error
59
}
60
61
type ConfigReloaderFunc func(context.Context, *Config) error
62
63
func (f ConfigReloaderFunc) ReloadConfig(ctx context.Context, cfg *Config) error {
64
return f(ctx, cfg)
65
}
66
67
type CompositeConfigReloader []ConfigReloader
68
69
func (cs CompositeConfigReloader) ReloadConfig(ctx context.Context, cfg *Config) error {
70
for _, c := range cs {
71
err := c.ReloadConfig(ctx, cfg)
72
if err != nil {
73
return err
74
}
75
if err := ctx.Err(); err != nil {
76
return err
77
}
78
}
79
return nil
80
}
81
82