Skip to content

Commit d3f3594

Browse files
authored
Add DevWorkspace Pruner (operator-lib/prune package) (#1402)
Signed-off-by: Oleksii Kurinnyi <[email protected]>
1 parent 799c0c4 commit d3f3594

22 files changed

+1353
-0
lines changed

apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go

+25
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,29 @@ 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+
// RetainTime specifies the minimum time (in seconds) since a DevWorkspace was last started before it is considered stale and eligible for cleanup.
58+
// 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.
59+
// Defaults to 2592000 seconds (30 days) if not specified.
60+
// +kubebuilder:validation:Minimum=0
61+
// +kubebuilder:default:=2592000
62+
// +kubebuilder:validation:Optional
63+
RetainTime *int32 `json:"retainTime,omitempty"`
64+
// DryRun determines whether the cleanup cron job should be run in dry-run mode.
65+
// If set to true, the cron job will not delete any DevWorkspaces, but will log the DevWorkspaces that would have been deleted.
66+
// Defaults to false if not specified.
67+
// +kubebuilder:validation:Optional
68+
DryRun *bool `json:"dryRun,omitempty"`
69+
// Schedule specifies the cron schedule for the cleanup cron job.
70+
// +kubebuilder:default:="0 0 1 * *"
71+
// +kubebuilder:validation:Optional
72+
Schedule string `json:"schedule,omitempty"`
73+
}
74+
5275
type RoutingConfig struct {
5376
// DefaultRoutingClass specifies the routingClass to be used when a DevWorkspace
5477
// specifies an empty `.spec.routingClass`. Supported routingClasses can be defined
@@ -161,6 +184,8 @@ type WorkspaceConfig struct {
161184
PodAnnotations map[string]string `json:"podAnnotations,omitempty"`
162185
// RuntimeClassName defines the spec.runtimeClassName for DevWorkspace pods created by the DevWorkspace Operator.
163186
RuntimeClassName *string `json:"runtimeClassName,omitempty"`
187+
// CleanupCronJobConfig defines configuration options for a cron job that automatically cleans up stale DevWorkspaces.
188+
CleanupCronJob *CleanupCronJobConfig `json:"cleanupCronJob,omitempty"`
164189
}
165190

166191
type WebhookConfig struct {

apis/controller/v1alpha1/zz_generated.deepcopy.go

+35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)