Repository navigation
Recover Sessions with StatefulSets - #1455
Conversation
There was a problem hiding this comment.
1 issue found across 27 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/controller/session_controller.go">
<violation number="1" location="internal/controller/session_controller.go:574">
P2: Sessions using a workspace-mounted `extraInitContainer` rerun that container after recovery, so migrations, resets, or seed scripts can overwrite preserved workspace state. Extend recovery guarding to supported user workspace setup or reject/document non-idempotent workspace init containers for Sessions.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| break | ||
| } | ||
| } | ||
| if err := prepareSessionWorkspaceInit(podSpec.InitContainers); err != nil { |
There was a problem hiding this comment.
P2: Sessions using a workspace-mounted extraInitContainer rerun that container after recovery, so migrations, resets, or seed scripts can overwrite preserved workspace state. Extend recovery guarding to supported user workspace setup or reject/document non-idempotent workspace init containers for Sessions.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/controller/session_controller.go, line 574:
<comment>Sessions using a workspace-mounted `extraInitContainer` rerun that container after recovery, so migrations, resets, or seed scripts can overwrite preserved workspace state. Extend recovery guarding to supported user workspace setup or reject/document non-idempotent workspace init containers for Sessions.</comment>
<file context>
@@ -476,6 +563,17 @@ func (r *SessionReconciler) buildSessionPod(session *kelos.Session, workspace *k
+ break
+ }
+ }
+ if err := prepareSessionWorkspaceInit(podSpec.InitContainers); err != nil {
+ return nil, nil, err
+ }
</file context>
knechtionscoding
left a comment
There was a problem hiding this comment.
@gjkim42 this seems like an exceptional amount of code/work to handle what could be handled by having session pods use a stateful set?
There was a problem hiding this comment.
1 issue found across 12 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/sessionruntime/server.go">
<violation number="1" location="internal/sessionruntime/server.go:306">
P1: When `journal.Append` fails in `submitMessage`, the turn was already enqueued on `s.turns` but `turn.accepted` is never closed. The `runTurns` goroutine then blocks forever on `<-turn.accepted`, preventing any further turns from being processed. This deadlocks the session runtime until the serve context is cancelled indirectly through journal failure detection.
Suggest closing `turn.accepted` before returning the error, or better, journal the event *before* enqueuing the turn so the turn is never sent unless the event is durably recorded.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| } | ||
| select { | ||
| case s.turns <- turn: | ||
| if err := s.journal.Append(Event{Type: EventUserMessage, RequestID: requestID, TurnID: turn.id, Text: turn.text}); err != nil { |
There was a problem hiding this comment.
P1: When journal.Append fails in submitMessage, the turn was already enqueued on s.turns but turn.accepted is never closed. The runTurns goroutine then blocks forever on <-turn.accepted, preventing any further turns from being processed. This deadlocks the session runtime until the serve context is cancelled indirectly through journal failure detection.
Suggest closing turn.accepted before returning the error, or better, journal the event before enqueuing the turn so the turn is never sent unless the event is durably recorded.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/sessionruntime/server.go, line 306:
<comment>When `journal.Append` fails in `submitMessage`, the turn was already enqueued on `s.turns` but `turn.accepted` is never closed. The `runTurns` goroutine then blocks forever on `<-turn.accepted`, preventing any further turns from being processed. This deadlocks the session runtime until the serve context is cancelled indirectly through journal failure detection.
Suggest closing `turn.accepted` before returning the error, or better, journal the event *before* enqueuing the turn so the turn is never sent unless the event is durably recorded.</comment>
<file context>
@@ -295,7 +303,9 @@ func (s *Server) submitMessage(text string) error {
select {
case s.turns <- turn:
- s.journal.Append(Event{Type: EventUserMessage, TurnID: turn.id, Text: turn.text})
+ if err := s.journal.Append(Event{Type: EventUserMessage, RequestID: requestID, TurnID: turn.id, Text: turn.text}); err != nil {
+ return fmt.Errorf("recording Session message: %w", err)
+ }
</file context>
036746f to
f6fe792
Compare
f6fe792 to
0d4d2ec
Compare
What type of PR is this?
/kind feature
What this PR does / why we need it:
Makes a Session a recoverable remote-control surface for one provider conversation.
Session.spec.volumeClaimTemplate; configured Sessions persist the workspace and runtime journal in a StatefulSet volume claim, while omitted storage usesemptyDirWhich issue(s) this PR is related to:
N/A
Special notes for your reviewer:
The headless Service is only the StatefulSet governing Service. Terminal and web clients continue to use the shared Session control path rather than connecting through a per-Session Service.
Pod replacement preserves workspace and conversation state only when
spec.volumeClaimTemplateis configured. A Session that omits it receives a freshemptyDirafter replacement.Validated locally with
make update,make build,make test,make verify, andmake test-integration(123 controller/CLI integration specs and 12 install-integration specs). The full e2e suite runs in CI.Does this PR introduce a user-facing change?