Skip to content

Commit 8d39d61

Browse files
committed
feat: added DevWorkspace pruner
Signed-off-by: Oleksii Kurinnyi <[email protected]>
1 parent 743da94 commit 8d39d61

24 files changed

+16812
-18885
lines changed

apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,36 @@ type OperatorConfiguration struct {
4949
EnableExperimentalFeatures *bool `json:"enableExperimentalFeatures,omitempty"`
5050
}
5151

52+
type CleanupCronJobConfig struct {
53+
// Enable determines whether the cleanup cron job is enabled.
54+
// Defaults to false if not specified.
55+
// +kubebuilder:validation:Optional
56+
Enable *bool `json:"enable,omitempty"`
57+
// Image specifies the container image to use for the cleanup cron job.
58+
// If not specified, a suitable default image for the Kubernetes/OpenShift environment will be used.
59+
// +kubebuilder:validation:Optional
60+
Image string `json:"image,omitempty"`
61+
// RetainTime specifies the minimum time (in seconds) since a DevWorkspace was last started before it is considered stale and eligible for cleanup.
62+
// For example, a value of 2592000 (30 days) would mean that any DevWorkspace that has not been started in the last 30 days will be deleted.
63+
// Defaults to 2592000 seconds (30 days) if not specified.
64+
// +kubebuilder:validation:Minimum=0
65+
// +kubebuilder:default:=2592000
66+
// +kubebuilder:validation:Optional
67+
RetainTime *int32 `json:"retainTime,omitempty"`
68+
// DryRun determines whether the cleanup cron job should be run in dry-run mode.
69+
// If set to true, the cron job will not delete any DevWorkspaces, but will log the DevWorkspaces that would have been deleted.
70+
// Defaults to false if not specified.
71+
// +kubebuilder:validation:Optional
72+
DryRun *bool `json:"dryRun,omitempty"`
73+
// CronJobScript specifies the name of a ConfigMap containing the script to be executed by the cleanup cron job.
74+
// This ConfigMap must reside in the same namespace as the DevWorkspace Operator.
75+
// The script is responsible for identifying and deleting stale DevWorkspaces (based on the `retainTime`).
76+
// The script must be idempotent. If not specified, defaults to `devworkspace-pruner`.
77+
// +kubebuilder:default:=devworkspace-pruner
78+
// +kubebuilder:validation:Optional
79+
CronJobScript string `json:"cronJobScript,omitempty"`
80+
}
81+
5282
type RoutingConfig struct {
5383
// DefaultRoutingClass specifies the routingClass to be used when a DevWorkspace
5484
// specifies an empty `.spec.routingClass`. Supported routingClasses can be defined
@@ -161,6 +191,8 @@ type WorkspaceConfig struct {
161191
PodAnnotations map[string]string `json:"podAnnotations,omitempty"`
162192
// RuntimeClassName defines the spec.runtimeClassName for DevWorkspace pods created by the DevWorkspace Operator.
163193
RuntimeClassName *string `json:"runtimeClassName,omitempty"`
194+
// CleanupCronJobConfig defines configuration options for a cron job that automatically cleans up stale DevWorkspaces.
195+
CleanupCronJob *CleanupCronJobConfig `json:"cleanupCronJob,omitempty"`
164196
}
165197

166198
type WebhookConfig struct {

apis/controller/v1alpha1/zz_generated.deepcopy.go

Lines changed: 38 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/bundle.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
66
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
77
LABEL operators.operatorframework.io.bundle.package.v1=devworkspace-operator
88
LABEL operators.operatorframework.io.bundle.channels.v1=fast
9-
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.7.1+git
9+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.8.0
1010
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
1111
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v2
1212

0 commit comments

Comments
 (0)