Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
echo "KUBECONFIG=${KUBECONFIG}" >> "$GITHUB_ENV"

- name: Build and deploy
uses: SwissDataScienceCenter/renku-actions/deploy-renku@v1.22.1
uses: SwissDataScienceCenter/renku-actions/deploy-renku@leafty/what-da-heck
env:
DOCKER_PASSWORD: ${{ secrets.RENKU_DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.RENKU_DOCKER_USERNAME }}
Expand Down
18 changes: 14 additions & 4 deletions api/v1alpha1/amaltheasession_children.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,22 @@ func (cr *AmaltheaSession) StatefulSet(cfg config.AmaltheaSessionConfiguration)
return appsv1.StatefulSet{}, err
}

labels := cr.childLabels()
annotations := map[string]string{}
for key := range cr.Spec.Template.Metadata.Annotations {
annotations[key] = cr.Spec.Template.Metadata.Annotations[key]
}
// Add the annotation for the runID
if cr.Status.RunId != "" {
annotations["renku.io/run_id"] = cr.Status.RunId
}

sts := appsv1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Name: cr.Name,
Namespace: cr.Namespace,
Labels: cr.childLabels(),
Annotations: cr.Spec.Template.Metadata.Annotations,
Labels: labels,
Annotations: annotations,
},
Spec: appsv1.StatefulSetSpec{
// NOTE: Parallel pod management policy is important
Expand All @@ -235,8 +245,8 @@ func (cr *AmaltheaSession) StatefulSet(cfg config.AmaltheaSessionConfiguration)
},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: cr.childLabels(),
Annotations: cr.Spec.Template.Metadata.Annotations,
Labels: labels,
Annotations: annotations,
},
Spec: *pod,
},
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/amaltheasession_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@ type AmaltheaSessionStatus struct {
// The date-time when the session is hibernated.
WillHibernateAt metav1.Time `json:"willHibernateAt,omitempty"`

// The ID of the current run of the workload. A run is a continuous execution of the workload;
// every time a session gets resumed from hibernation, it gets a new runID.
RunId string `json:"runID,omitempty"`

// If the state is failed then the message will contain information about what went wrong, otherwise it is empty
// +optional
Error string `json:"error,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/amalthea.dev_amaltheasessions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6590,6 +6590,11 @@ spec:
total:
type: integer
type: object
runID:
description: |-
The ID of the current run of the workload. A run is a continuous execution of the workload;
every time a session gets resumed from hibernation, it gets a new runID.
type: string
state:
default: NotReady
enum:
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/oapi-codegen/oapi-codegen/v2 v2.5.0
github.com/oapi-codegen/runtime v1.1.2
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037
github.com/oklog/ulid/v2 v2.1.1
github.com/onsi/ginkgo/v2 v2.23.4
github.com/onsi/gomega v1.37.0
github.com/prometheus/client_golang v1.19.1
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//J
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037/go.mod h1:2bpvgLBZEtENV5scfDFEtB/5+1M4hkQhDQrccEJ/qGw=
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 h1:bQx3WeLcUWy+RletIKwUIt4x3t8n2SxavmoclizMb8c=
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o=
github.com/oklog/ulid/v2 v2.1.1 h1:suPZ4ARWLOJLegGFiZZ1dFAkqzhMjL3J1TzI+5wHz8s=
github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
Expand All @@ -226,6 +228,7 @@ github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6592,6 +6592,11 @@ spec:
total:
type: integer
type: object
runID:
description: |-
The ID of the current run of the workload. A run is a continuous execution of the workload;
every time a session gets resumed from hibernation, it gets a new runID.
type: string
state:
default: NotReady
enum:
Expand Down
15 changes: 15 additions & 0 deletions internal/controller/amaltheasession_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/getsentry/sentry-go"
"github.com/oklog/ulid/v2"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -144,6 +145,8 @@ func (r *AmaltheaSessionReconciler) reconcileInner(ctx context.Context, req ctrl
if reflect.DeepEqual(amaltheasession.Status, amaltheadevv1alpha1.AmaltheaSessionStatus{State: amaltheadevv1alpha1.NotReady, Idle: false}) {
// First status update/render
amaltheasession.Status.URL = amaltheasession.GetURLString()
// NEW, do we need this here?
// amaltheasession.Status.RunId = ulid.Make().String()
err := r.Status().Update(ctx, amaltheasession)
if err != nil {
err = r.Get(ctx, req.NamespacedName, amaltheasession)
Expand Down Expand Up @@ -199,6 +202,18 @@ func (r *AmaltheaSessionReconciler) reconcileInner(ctx context.Context, req ctrl
return ctrl.Result{Requeue: true}, nil
}

// NEW
// We need to handle run ID before generating children resources
runID := amaltheasession.Status.RunId
if amaltheasession.Spec.Hibernated {
// The session is getting hibernated, unset the run ID
runID = ""
} else if runID == "" {
// The session just got created or is being resumed, set the new run ID
runID = ulid.Make().String()
}
amaltheasession.Status.RunId = runID

children, err := NewChildResources(amaltheasession, r.Configuration)
if err != nil {
log.Error(
Expand Down
11 changes: 11 additions & 0 deletions internal/controller/children.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,16 @@ func (c ChildResourceUpdates) Status(

hibernationDate := calculateHibernationDate(log, cr.GetCreationTimestamp(), cr.Status, cr.Spec.Culling)

// NEW
// runID := cr.Status.RunId
// if cr.Spec.Hibernated {
// // The session is getting hibernated, unset the run ID
// runID = ""
// } else if runID == "" {
// // The session just got created or is being resumed, set the new run ID
// runID = ulid.Make().String()
// }

status := amaltheadevv1alpha1.AmaltheaSessionStatus{
Conditions: Conditions(state, ctx, r, cr),
State: state,
Expand All @@ -833,6 +843,7 @@ func (c ChildResourceUpdates) Status(
FailingSince: failingSince,
HibernatedSince: hibernatedSince,
WillHibernateAt: hibernationDate,
RunId: cr.Status.RunId,
Error: failMsg,
}
warning := c.warningMessage(pod)
Expand Down
Loading