diff --git a/components/server/ee/src/prebuilds/prebuild-manager.ts b/components/server/ee/src/prebuilds/prebuild-manager.ts index 8d161ea8546b8d..87647293b04afe 100644 --- a/components/server/ee/src/prebuilds/prebuild-manager.ts +++ b/components/server/ee/src/prebuilds/prebuild-manager.ts @@ -406,9 +406,9 @@ export class PrebuildManager { private async shouldSkipInactiveRepository(ctx: TraceContext, cloneURL: string): Promise { const span = TraceContext.startSpan("shouldSkipInactiveRepository", ctx); - const { inactivityPeriodForRepos } = this.config; - if (!inactivityPeriodForRepos) { - // skipping is disabled if `inactivityPeriodForRepos` is not set + const { inactivityPeriodForReposInDays } = this.config; + if (!inactivityPeriodForReposInDays) { + // skipping is disabled if `inactivityPeriodForReposInDays` is not set span.finish(); return false; } @@ -416,7 +416,8 @@ export class PrebuildManager { return ( (await this.workspaceDB .trace({ span }) - .getWorkspaceCountByCloneURL(cloneURL, inactivityPeriodForRepos /* in days */, "regular")) === 0 + .getWorkspaceCountByCloneURL(cloneURL, inactivityPeriodForReposInDays /* in days */, "regular")) === + 0 ); } catch (error) { log.error("cannot compute activity for repository", { cloneURL }, error); diff --git a/components/server/src/config.ts b/components/server/src/config.ts index d53529688a71d8..706a7e546a1e24 100644 --- a/components/server/src/config.ts +++ b/components/server/src/config.ts @@ -29,7 +29,7 @@ export type Config = Omit< stripeSecrets?: { publishableKey: string; secretKey: string }; stripeConfig?: StripeConfig; builtinAuthProvidersConfigured: boolean; - inactivityPeriodForRepos?: number; + inactivityPeriodForReposInDays?: number; }; export interface WorkspaceDefaults { @@ -203,7 +203,7 @@ export interface ConfigSerialized { * If a numeric value interpreted as days is set, repositories not beeing opened with Gitpod are * considered inactive. */ - inactivityPeriodForRepos?: number; + inactivityPeriodForReposInDays?: number; /** * Supported workspace classes @@ -285,10 +285,10 @@ export namespace ConfigFile { if (licenseFile) { license = fs.readFileSync(filePathTelepresenceAware(licenseFile), "utf-8"); } - let inactivityPeriodForRepos: number | undefined; - if (typeof config.inactivityPeriodForRepos === "number") { - if (config.inactivityPeriodForRepos >= 1) { - inactivityPeriodForRepos = config.inactivityPeriodForRepos; + let inactivityPeriodForReposInDays: number | undefined; + if (typeof config.inactivityPeriodForReposInDays === "number") { + if (config.inactivityPeriodForReposInDays >= 1) { + inactivityPeriodForReposInDays = config.inactivityPeriodForReposInDays; } } @@ -320,7 +320,7 @@ export namespace ConfigFile { ? new Date(config.workspaceGarbageCollection.startDate).getTime() : Date.now(), }, - inactivityPeriodForRepos, + inactivityPeriodForReposInDays, }; } } diff --git a/install/installer/cmd/testdata/render/aws-setup/output.golden b/install/installer/cmd/testdata/render/aws-setup/output.golden index c7efffe5ffdd76..179ea1f9073147 100644 --- a/install/installer/cmd/testdata/render/aws-setup/output.golden +++ b/install/installer/cmd/testdata/render/aws-setup/output.golden @@ -4622,7 +4622,8 @@ data: "isDefault": true, "deprecated": false } - ] + ], + "inactivityPeriodForReposInDays": 0 } kind: ConfigMap metadata: @@ -8725,7 +8726,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: a745ecf007657309c326826c2afb6f0782aa50415678f1c73d45307f02acfa54 + gitpod.io/checksum_config: fd86888d2f9c7f51bb9750b65b15cd977c82ac9b65da17c233d69e77ff81f7b6 creationTimestamp: null labels: app: gitpod diff --git a/install/installer/cmd/testdata/render/azure-setup/output.golden b/install/installer/cmd/testdata/render/azure-setup/output.golden index f834a595276584..4e77af77cd9bf6 100644 --- a/install/installer/cmd/testdata/render/azure-setup/output.golden +++ b/install/installer/cmd/testdata/render/azure-setup/output.golden @@ -4485,7 +4485,8 @@ data: "isDefault": true, "deprecated": false } - ] + ], + "inactivityPeriodForReposInDays": 0 } kind: ConfigMap metadata: @@ -8576,7 +8577,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: a745ecf007657309c326826c2afb6f0782aa50415678f1c73d45307f02acfa54 + gitpod.io/checksum_config: fd86888d2f9c7f51bb9750b65b15cd977c82ac9b65da17c233d69e77ff81f7b6 creationTimestamp: null labels: app: gitpod diff --git a/install/installer/cmd/testdata/render/customization/output.golden b/install/installer/cmd/testdata/render/customization/output.golden index 372097fad61c72..18a10541410091 100644 --- a/install/installer/cmd/testdata/render/customization/output.golden +++ b/install/installer/cmd/testdata/render/customization/output.golden @@ -5432,7 +5432,8 @@ data: "isDefault": true, "deprecated": false } - ] + ], + "inactivityPeriodForReposInDays": 0 } kind: ConfigMap metadata: @@ -10144,7 +10145,7 @@ spec: metadata: annotations: gitpod.io: hello - gitpod.io/checksum_config: a7fdc707c129e43ce4768f9df84743a94f1232de05359df0078db77748e5a0b3 + gitpod.io/checksum_config: adce5b1504123c4829f44704c10821db8bc7db39338458e33611c719c2ea3730 hello: world creationTimestamp: null labels: diff --git a/install/installer/cmd/testdata/render/external-registry/output.golden b/install/installer/cmd/testdata/render/external-registry/output.golden index f3b91f0ad488a3..eef301723e8c63 100644 --- a/install/installer/cmd/testdata/render/external-registry/output.golden +++ b/install/installer/cmd/testdata/render/external-registry/output.golden @@ -4672,7 +4672,8 @@ data: "isDefault": true, "deprecated": false } - ] + ], + "inactivityPeriodForReposInDays": 0 } kind: ConfigMap metadata: @@ -9002,7 +9003,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: a4e77dfdb4f0f6103762722c99d4ba4eaf570a7c3d9fbc3e292a2d48cb17ad24 + gitpod.io/checksum_config: 92d9e5b1395f8b3b192de00b493801b656c63073991c1bfc87a90f5205e63226 creationTimestamp: null labels: app: gitpod diff --git a/install/installer/cmd/testdata/render/gcp-setup/output.golden b/install/installer/cmd/testdata/render/gcp-setup/output.golden index 1028e44fbb0932..41eb086ecd0c3a 100644 --- a/install/installer/cmd/testdata/render/gcp-setup/output.golden +++ b/install/installer/cmd/testdata/render/gcp-setup/output.golden @@ -4446,7 +4446,8 @@ data: "isDefault": true, "deprecated": false } - ] + ], + "inactivityPeriodForReposInDays": 0 } kind: ConfigMap metadata: @@ -8505,7 +8506,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: 6992584742d8c0130c85e9635aefdcfbb7d252a4e968a7a38f7d296f8600acc5 + gitpod.io/checksum_config: 523af97345a32d8d9acb8801c04bad6b148943cd5d58f47cbac85d9466e892f3 creationTimestamp: null labels: app: gitpod diff --git a/install/installer/cmd/testdata/render/http-proxy/output.golden b/install/installer/cmd/testdata/render/http-proxy/output.golden index 48acb5fff88f66..365d4b37617363 100644 --- a/install/installer/cmd/testdata/render/http-proxy/output.golden +++ b/install/installer/cmd/testdata/render/http-proxy/output.golden @@ -4895,7 +4895,8 @@ data: "isDefault": true, "deprecated": false } - ] + ], + "inactivityPeriodForReposInDays": 0 } kind: ConfigMap metadata: @@ -10423,7 +10424,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: a4e77dfdb4f0f6103762722c99d4ba4eaf570a7c3d9fbc3e292a2d48cb17ad24 + gitpod.io/checksum_config: 92d9e5b1395f8b3b192de00b493801b656c63073991c1bfc87a90f5205e63226 creationTimestamp: null labels: app: gitpod diff --git a/install/installer/cmd/testdata/render/insecure-s3-setup/output.golden b/install/installer/cmd/testdata/render/insecure-s3-setup/output.golden index bf620d00585a7b..5219f91d3708e8 100644 --- a/install/installer/cmd/testdata/render/insecure-s3-setup/output.golden +++ b/install/installer/cmd/testdata/render/insecure-s3-setup/output.golden @@ -4806,7 +4806,8 @@ data: "isDefault": true, "deprecated": false } - ] + ], + "inactivityPeriodForReposInDays": 0 } kind: ConfigMap metadata: @@ -9148,7 +9149,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: a4e77dfdb4f0f6103762722c99d4ba4eaf570a7c3d9fbc3e292a2d48cb17ad24 + gitpod.io/checksum_config: 92d9e5b1395f8b3b192de00b493801b656c63073991c1bfc87a90f5205e63226 creationTimestamp: null labels: app: gitpod diff --git a/install/installer/cmd/testdata/render/minimal/output.golden b/install/installer/cmd/testdata/render/minimal/output.golden index 2a265cd5f2749e..4c660a3a3149c7 100644 --- a/install/installer/cmd/testdata/render/minimal/output.golden +++ b/install/installer/cmd/testdata/render/minimal/output.golden @@ -4892,7 +4892,8 @@ data: "isDefault": true, "deprecated": false } - ] + ], + "inactivityPeriodForReposInDays": 0 } kind: ConfigMap metadata: @@ -9377,7 +9378,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: a4e77dfdb4f0f6103762722c99d4ba4eaf570a7c3d9fbc3e292a2d48cb17ad24 + gitpod.io/checksum_config: 92d9e5b1395f8b3b192de00b493801b656c63073991c1bfc87a90f5205e63226 creationTimestamp: null labels: app: gitpod diff --git a/install/installer/cmd/testdata/render/shortname/output.golden b/install/installer/cmd/testdata/render/shortname/output.golden index d48148a69254c5..90970e29707d5d 100644 --- a/install/installer/cmd/testdata/render/shortname/output.golden +++ b/install/installer/cmd/testdata/render/shortname/output.golden @@ -4892,7 +4892,8 @@ data: "isDefault": true, "deprecated": false } - ] + ], + "inactivityPeriodForReposInDays": 0 } kind: ConfigMap metadata: @@ -9377,7 +9378,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: 0593a3a8ac33ff63223473b306970682e9063d55b590448b6329a0a41df72fca + gitpod.io/checksum_config: 188b6e909382eb4d7a3d2b03ae08c562d87cea8e683d13f09a8e8463e4ae0536 creationTimestamp: null labels: app: gitpod diff --git a/install/installer/cmd/testdata/render/statefulset-customization/output.golden b/install/installer/cmd/testdata/render/statefulset-customization/output.golden index 6e4fb1a9604142..1a9ba33dfa4fae 100644 --- a/install/installer/cmd/testdata/render/statefulset-customization/output.golden +++ b/install/installer/cmd/testdata/render/statefulset-customization/output.golden @@ -4904,7 +4904,8 @@ data: "isDefault": true, "deprecated": false } - ] + ], + "inactivityPeriodForReposInDays": 0 } kind: ConfigMap metadata: @@ -9389,7 +9390,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: a4e77dfdb4f0f6103762722c99d4ba4eaf570a7c3d9fbc3e292a2d48cb17ad24 + gitpod.io/checksum_config: 92d9e5b1395f8b3b192de00b493801b656c63073991c1bfc87a90f5205e63226 creationTimestamp: null labels: app: gitpod diff --git a/install/installer/cmd/testdata/render/use-pod-security-policies/output.golden b/install/installer/cmd/testdata/render/use-pod-security-policies/output.golden index 1e650e116f2a54..5f4b12e1a40065 100644 --- a/install/installer/cmd/testdata/render/use-pod-security-policies/output.golden +++ b/install/installer/cmd/testdata/render/use-pod-security-policies/output.golden @@ -5225,7 +5225,8 @@ data: "isDefault": true, "deprecated": false } - ] + ], + "inactivityPeriodForReposInDays": 0 } kind: ConfigMap metadata: @@ -9821,7 +9822,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: a4e77dfdb4f0f6103762722c99d4ba4eaf570a7c3d9fbc3e292a2d48cb17ad24 + gitpod.io/checksum_config: 92d9e5b1395f8b3b192de00b493801b656c63073991c1bfc87a90f5205e63226 creationTimestamp: null labels: app: gitpod diff --git a/install/installer/cmd/testdata/render/workspace-requests-limits/output.golden b/install/installer/cmd/testdata/render/workspace-requests-limits/output.golden index 693f48e5f76204..630dd392f48874 100644 --- a/install/installer/cmd/testdata/render/workspace-requests-limits/output.golden +++ b/install/installer/cmd/testdata/render/workspace-requests-limits/output.golden @@ -4895,7 +4895,8 @@ data: "isDefault": true, "deprecated": false } - ] + ], + "inactivityPeriodForReposInDays": 0 } kind: ConfigMap metadata: @@ -9380,7 +9381,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: a4e77dfdb4f0f6103762722c99d4ba4eaf570a7c3d9fbc3e292a2d48cb17ad24 + gitpod.io/checksum_config: 92d9e5b1395f8b3b192de00b493801b656c63073991c1bfc87a90f5205e63226 creationTimestamp: null labels: app: gitpod diff --git a/install/installer/pkg/components/server/configmap.go b/install/installer/pkg/components/server/configmap.go index 698156d181af8b..b3aac799c2b0b6 100644 --- a/install/installer/pkg/components/server/configmap.go +++ b/install/installer/pkg/components/server/configmap.go @@ -176,6 +176,14 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { return nil }) + inactivityPeriodForReposInDays := 0 + _ = ctx.WithExperimental(func(cfg *experimental.Config) error { + if cfg.WebApp != nil && cfg.WebApp.Server != nil && cfg.WebApp.Server.InactivityPeriodForReposInDays != nil { + inactivityPeriodForReposInDays = *cfg.WebApp.Server.InactivityPeriodForReposInDays + } + return nil + }) + // todo(sje): all these values are configurable scfg := ConfigSerialized{ Version: ctx.VersionManifest.Version, @@ -263,7 +271,8 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { // default limit for all cloneURLs "*": 50, }, - WorkspaceClasses: workspaceClasses, + WorkspaceClasses: workspaceClasses, + InactivityPeriodForReposInDays: inactivityPeriodForReposInDays, } fc, err := common.ToJSONString(scfg) diff --git a/install/installer/pkg/components/server/types.go b/install/installer/pkg/components/server/types.go index 26d8edadd67452..3aad35e57d0d60 100644 --- a/install/installer/pkg/components/server/types.go +++ b/install/installer/pkg/components/server/types.go @@ -52,8 +52,9 @@ type ConfigSerialized struct { CodeSync CodeSync `json:"codeSync"` // PrebuildLimiter defines the number of prebuilds allowed for each cloneURL in a given 1 minute interval // Key of "*" defines the default limit, unless there exists a cloneURL in the map which overrides it. - PrebuildLimiter map[string]int `json:"prebuildLimiter"` - WorkspaceClasses []WorkspaceClass `json:"workspaceClasses"` + PrebuildLimiter map[string]int `json:"prebuildLimiter"` + WorkspaceClasses []WorkspaceClass `json:"workspaceClasses"` + InactivityPeriodForReposInDays int `json:"inactivityPeriodForReposInDays"` } type CodeSyncResources struct { RevLimit int32 `json:"revLimit"` diff --git a/install/installer/pkg/config/v1/experimental/experimental.go b/install/installer/pkg/config/v1/experimental/experimental.go index 1930e845bde405..efaef771daca7c 100644 --- a/install/installer/pkg/config/v1/experimental/experimental.go +++ b/install/installer/pkg/config/v1/experimental/experimental.go @@ -232,6 +232,7 @@ type ServerConfig struct { EnableLocalApp *bool `json:"enableLocalApp"` RunDbDeleter *bool `json:"runDbDeleter"` DisableWorkspaceGarbageCollection bool `json:"disableWorkspaceGarbageCollection"` + InactivityPeriodForReposInDays *int `json:"inactivityPeriodForReposInDays"` // @deprecated use containerRegistry.privateBaseImageAllowList instead DefaultBaseImageRegistryWhiteList []string `json:"defaultBaseImageRegistryWhitelist"`