diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 64a9536d..afd93a8c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "Amalthea", - "image": "mcr.microsoft.com/devcontainers/python:3.12-bookworm", + "image": "mcr.microsoft.com/devcontainers/python:2.1.2-3.12-trixie", "build": { "args": { "DEV_BUILD": true @@ -14,7 +14,9 @@ "yqVersion": "latest" }, "ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {}, - "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "moby": false, + }, "ghcr.io/mpriscella/features/kind:1": {}, "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { "minikube": "none" diff --git a/api/v1alpha1/amaltheasession_types.go b/api/v1alpha1/amaltheasession_types.go index 92bb785c..fd552742 100644 --- a/api/v1alpha1/amaltheasession_types.go +++ b/api/v1alpha1/amaltheasession_types.go @@ -331,6 +331,10 @@ type Culling struct { // +kubebuilder:default:="300m" // Number of CPU cores that determine a session to be idling. CPUIdleThreshold resource.Quantity `json:"cpuIdleThreshold,omitempty"` + // +optional + // +kubebuilder:validation:Format:=date-time + // +kubebuilder:validation:Type:=string + ResumeAt metav1.Time `json:"resumeAt,omitempty"` } // +kubebuilder:validation:Enum={token,oauth2proxy,oidc} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index f6884b37..d02f2727 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -288,6 +288,7 @@ func (in *Culling) DeepCopyInto(out *Culling) { out.MaxHibernatedDuration = in.MaxHibernatedDuration in.LastInteraction.DeepCopyInto(&out.LastInteraction) out.CPUIdleThreshold = in.CPUIdleThreshold.DeepCopy() + in.ResumeAt.DeepCopyInto(&out.ResumeAt) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Culling. diff --git a/bundle/manifests/amalthea.clusterserviceversion.yaml b/bundle/manifests/amalthea.clusterserviceversion.yaml index 0141a017..1a8b7328 100644 --- a/bundle/manifests/amalthea.clusterserviceversion.yaml +++ b/bundle/manifests/amalthea.clusterserviceversion.yaml @@ -21,7 +21,7 @@ metadata: } ] capabilities: Basic Install - createdAt: "2025-06-25T07:56:15Z" + createdAt: "2026-01-26T13:16:58Z" operators.operatorframework.io/builder: operator-sdk-v1.38.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v4 name: amalthea.v0.0.1 diff --git a/bundle/manifests/amalthea.dev_amaltheasessions.yaml b/bundle/manifests/amalthea.dev_amaltheasessions.yaml index 7d331c52..79f6916f 100644 --- a/bundle/manifests/amalthea.dev_amaltheasessions.yaml +++ b/bundle/manifests/amalthea.dev_amaltheasessions.yaml @@ -1233,6 +1233,9 @@ spec: valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". format: duration type: string + resumeAt: + format: date-time + type: string type: object dataSources: description: A list of data sources that should be added to the session diff --git a/config/crd/bases/amalthea.dev_amaltheasessions.yaml b/config/crd/bases/amalthea.dev_amaltheasessions.yaml index 525873f2..bf111eb5 100644 --- a/config/crd/bases/amalthea.dev_amaltheasessions.yaml +++ b/config/crd/bases/amalthea.dev_amaltheasessions.yaml @@ -1233,6 +1233,9 @@ spec: valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". format: duration type: string + resumeAt: + format: date-time + type: string type: object dataSources: description: A list of data sources that should be added to the session diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 762c1237..ad13e96b 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: example.com/amalthea - newTag: v0.0.1 + newName: controller + newTag: latest diff --git a/helm-chart/amalthea-sessions/templates/amaltheasession-crd.yaml b/helm-chart/amalthea-sessions/templates/amaltheasession-crd.yaml index c8b1f612..e4b3dff0 100644 --- a/helm-chart/amalthea-sessions/templates/amaltheasession-crd.yaml +++ b/helm-chart/amalthea-sessions/templates/amaltheasession-crd.yaml @@ -1235,6 +1235,9 @@ spec: valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". format: duration type: string + resumeAt: + format: date-time + type: string type: object dataSources: description: A list of data sources that should be added to the session diff --git a/internal/controller/amaltheasession_controller.go b/internal/controller/amaltheasession_controller.go index 57986eb2..4a1c288f 100644 --- a/internal/controller/amaltheasession_controller.go +++ b/internal/controller/amaltheasession_controller.go @@ -87,6 +87,23 @@ func (r *AmaltheaSessionReconciler) Reconcile(ctx context.Context, req ctrl.Requ return ctrl.Result{}, err } + if amaltheasession.Spec.Culling.ResumeAt.After(time.Now()) { + + // If session is not hibernated, remove the resumeAt + if !amaltheasession.Spec.Hibernated { + amaltheasession.Spec.Culling.ResumeAt = time.Time{} + return ctrl.Result{}, nil + } + + // Set hibernated to false + amaltheasession.Spec.Hibernated = false + + // remove resumeAt + amaltheasession.Spec.Culling.ResumeAt = time.Time{} + + return ctrl.Result{}, nil + } + if amaltheasession.GetDeletionTimestamp() == nil { if reflect.DeepEqual(amaltheasession.Status, amaltheadevv1alpha1.AmaltheaSessionStatus{State: amaltheadevv1alpha1.NotReady, Idle: false}) { // First status update/render