diff --git a/api/v2/checluster_types.go b/api/v2/checluster_types.go index fb3bc244b9..3dc9d37e2f 100644 --- a/api/v2/checluster_types.go +++ b/api/v2/checluster_types.go @@ -259,6 +259,10 @@ type CheClusterDevEnvironments struct { // Typical uses cases include injecting organization tools/configs, initializing persistent home, etc. // +optional InitContainers []corev1.Container `json:"initContainers,omitempty"` + + // CLI Activity Tracker configuration for preventing workspace idling during active CLI processes. + // +optional + CliActivityTracker *CliActivityTrackerConfig `json:"cliActivityTracker,omitempty"` } // Che components configuration. @@ -690,6 +694,49 @@ type WorkspaceSecurityConfig struct { ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"` } +// CliActivityTrackerConfig defines CLI Activity Tracker configuration for preventing workspace idling +// during active CLI processes. These settings are propagated as environment variables +// to workspace containers. When omitted, the CLI Activity Tracker calculates defaults +// dynamically based on the workspace idle timeout. +type CliActivityTrackerConfig struct { + // Enables CLI Activity Tracker to monitor running CLI processes and prevent workspace idling. + // When omitted, the CLI Activity Tracker determines the default behavior. + // +optional + Enabled *bool `json:"enabled,omitempty"` + + // How often (in seconds) to scan for active CLI processes. + // When omitted, the CLI Activity Tracker calculates a default + // based on the workspace idle timeout (e.g. 60s for a 1800s idle timeout). + // +optional + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:ExclusiveMinimum=true + SecondsOfCheckPeriod *int32 `json:"secondsOfCheckPeriod,omitempty"` + + // How long (in seconds) to wait for input from interactive processes + // before considering them idle. + // When omitted, the CLI Activity Tracker calculates a default + // based on the workspace idle timeout (e.g. 1500s for a 1800s idle timeout). + // +optional + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:ExclusiveMinimum=true + SecondsOfActivityWindow *int32 `json:"secondsOfActivityWindow,omitempty"` + + // All processes unconditionally prevent idling when younger than this (in seconds). + // When omitted, the CLI Activity Tracker calculates a default + // based on the workspace idle timeout (e.g. 300s for a 1800s idle timeout). + // +optional + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:ExclusiveMinimum=true + SecondsOfGracePeriod *int32 `json:"secondsOfGracePeriod,omitempty"` + + // Safety limit (in seconds). Processes older than this stop preventing idling. + // When omitted, the CLI Activity Tracker uses its built-in default (e.g. 6h). + // +optional + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:ExclusiveMinimum=true + SecondsOfMaxProcessAge *int32 `json:"secondsOfMaxProcessAge,omitempty"` +} + // Authentication settings. type Auth struct { // Public URL of the Identity Provider server. diff --git a/api/v2/zz_generated.deepcopy.go b/api/v2/zz_generated.deepcopy.go index ae43b13551..ad7c8391eb 100644 --- a/api/v2/zz_generated.deepcopy.go +++ b/api/v2/zz_generated.deepcopy.go @@ -402,6 +402,11 @@ func (in *CheClusterDevEnvironments) DeepCopyInto(out *CheClusterDevEnvironments (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.CliActivityTracker != nil { + in, out := &in.CliActivityTracker, &out.CliActivityTracker + *out = new(CliActivityTrackerConfig) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CheClusterDevEnvironments. @@ -610,6 +615,46 @@ func (in *CheServer) DeepCopy() *CheServer { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CliActivityTrackerConfig) DeepCopyInto(out *CliActivityTrackerConfig) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.SecondsOfCheckPeriod != nil { + in, out := &in.SecondsOfCheckPeriod, &out.SecondsOfCheckPeriod + *out = new(int32) + **out = **in + } + if in.SecondsOfActivityWindow != nil { + in, out := &in.SecondsOfActivityWindow, &out.SecondsOfActivityWindow + *out = new(int32) + **out = **in + } + if in.SecondsOfGracePeriod != nil { + in, out := &in.SecondsOfGracePeriod, &out.SecondsOfGracePeriod + *out = new(int32) + **out = **in + } + if in.SecondsOfMaxProcessAge != nil { + in, out := &in.SecondsOfMaxProcessAge, &out.SecondsOfMaxProcessAge + *out = new(int32) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CliActivityTrackerConfig. +func (in *CliActivityTrackerConfig) DeepCopy() *CliActivityTrackerConfig { + if in == nil { + return nil + } + out := new(CliActivityTrackerConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Container) DeepCopyInto(out *Container) { *out = *in diff --git a/build/scripts/docker-run.sh b/build/scripts/docker-run.sh index 6bfbf66e47..2025236d89 100755 --- a/build/scripts/docker-run.sh +++ b/build/scripts/docker-run.sh @@ -38,7 +38,7 @@ init() { build() { printf "%bBuilding image %b${IMAGE_NAME}${NC}..." "${BOLD}" "${BLUE}" if ${CONTAINER_ENGINE} build -t ${IMAGE_NAME} > docker-build-log 2>&1 -<