Skip to content

Fix : Remove default maxSessionDuration for AgentRuntime#410

Open
safiya2610 wants to merge 1 commit into
volcano-sh:mainfrom
safiya2610:fix/issue-303
Open

Fix : Remove default maxSessionDuration for AgentRuntime#410
safiya2610 wants to merge 1 commit into
volcano-sh:mainfrom
safiya2610:fix/issue-303

Conversation

@safiya2610

@safiya2610 safiya2610 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

This PR resolves Issue #303 by making AgentRuntime.spec.maxSessionDuration optional instead of defaulting to 8 hours.

Changes

Removed the default maxSessionDuration value for AgentRuntime.
Updated the workload builder to set Sandbox.Spec.Lifecycle.ShutdownTime only when maxSessionDuration is explicitly configured.
Preserved the existing default maximum session duration behavior for CodeInterpreter.
Updated the AgentRuntime CRD to reflect the optional field.
Added and updated unit tests to cover the new behavior.
Why
Previously, every AgentRuntime was assigned a default maximum session duration of 8 hours, causing long-running agents to be terminated even when they were still active. With this change, long-running AgentRuntime instances are no longer force-terminated unless a maximum session duration is explicitly specified, while CodeInterpreter continues to retain its existing behavior.

Testing
go test ./pkg/workloadmanager/...
go test ./pkg/apis/runtime/v1alpha1/...
go build ./...

Which issue(s) this PR fixes:
Fixes #303

Copilot AI review requested due to automatic review settings June 28, 2026 12:32
@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kevin-wangzefeng for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request makes maxSessionDuration optional for AgentRuntime by removing its default value and required validation in both the CRD and Go API definitions. It also updates the workload builder logic to only set a sandbox shutdown time if a TTL is specified, defaulting to DefaultSandboxTTL specifically for code interpreters, and adds a corresponding unit test assertion. Feedback highlights that maxSessionDuration is still listed in the required list at the bottom of the CRD file, which will cause Kubernetes to reject resources that omit it.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to resolve Issue #303 by making AgentRuntime.spec.maxSessionDuration optional (removing the implicit 8h hard lifetime), while preserving the existing default max session duration behavior for CodeInterpreter. It updates sandbox construction so a hard ShutdownTime is only set when explicitly configured, updates the AgentRuntime API/CRD, and adjusts unit tests accordingly.

Changes:

  • Remove the default hard max lifetime for AgentRuntime sessions by not setting Sandbox.Spec.Lifecycle.ShutdownTime unless maxSessionDuration is provided.
  • Preserve CodeInterpreter’s default hard max lifetime (8h) by explicitly applying DefaultSandboxTTL when maxSessionDuration is omitted.
  • Update the AgentRuntime API/CRD and unit tests to reflect the new optional semantics.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pkg/workloadmanager/workload_builder.go Stop defaulting TTL in the generic sandbox builder; set ShutdownTime only when TTL is explicitly configured; preserve CodeInterpreter TTL defaulting.
pkg/workloadmanager/workload_builder_test.go Update AgentRuntime default timeout test to assert ShutdownTime is nil when maxSessionDuration is omitted.
pkg/apis/runtime/v1alpha1/agent_type.go Remove kubebuilder-required/default markers and document MaxSessionDuration as optional for AgentRuntime.
manifests/charts/base/crds/runtime.agentcube.volcano.sh_agentruntimes.yaml Remove the CRD default value for maxSessionDuration.
Comments suppressed due to low confidence (1)

manifests/charts/base/crds/runtime.agentcube.volcano.sh_agentruntimes.yaml:50

  • The Helm CRD still marks spec.maxSessionDuration as required even though the default was removed. In this CRD, spec.required still includes - maxSessionDuration (see same file around line 8505), so clients will still be forced to provide the field, which contradicts making it optional in AgentRuntimeSpec.

Update the CRD schema to remove maxSessionDuration from the spec.required list (ideally by regenerating the CRD from controller-gen after removing the +kubebuilder:validation:Required tag in pkg/apis/runtime/v1alpha1/agent_type.go).

              maxSessionDuration:
                description: |-
                  MaxSessionDuration describes the maximum duration for a session.
                  After this duration, the session will be terminated no matter active or inactive.
                type: string

Comment thread pkg/workloadmanager/workload_builder.go
@codecov-commenter

codecov-commenter commented Jun 28, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.56%. Comparing base (524e55e) to head (bf7d76d).
⚠️ Report is 176 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #410       +/-   ##
===========================================
+ Coverage   47.57%   58.56%   +10.99%     
===========================================
  Files          30       36        +6     
  Lines        2819     3468      +649     
===========================================
+ Hits         1341     2031      +690     
+ Misses       1338     1228      -110     
- Partials      140      209       +69     
Flag Coverage Δ
unittests 58.56% <100.00%> (+10.99%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment thread pkg/workloadmanager/workload_builder.go Outdated
Comment thread pkg/workloadmanager/sandbox_helper.go Outdated
Comment thread pkg/workloadmanager/garbage_collection.go Outdated
Comment thread pkg/workloadmanager/workload_builder.go Outdated
@acsoto

acsoto commented Jul 8, 2026

Copy link
Copy Markdown
Member

This matches the direction discussed in #303: AgentRuntime should not get an implicit 8h hard lifetime, while CodeInterpreter can keep the existing default. Please run make gen/make gen-check and include the generated changes; the current Codegen Check is failing because the generated AgentRuntime CRD is missing the new maxSessionDuration description line, and go mod tidy also changes go.sum.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment thread pkg/workloadmanager/workload_builder.go
Comment thread pkg/workloadmanager/workload_builder.go Outdated
Comment thread pkg/workloadmanager/garbage_collection.go Outdated
Copilot AI review requested due to automatic review settings July 8, 2026 07:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread pkg/workloadmanager/garbage_collection.go Outdated
Comment thread pkg/workloadmanager/sandbox_helper.go Outdated
Copilot AI review requested due to automatic review settings July 8, 2026 07:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment thread pkg/apis/runtime/v1alpha1/agent_type.go
Comment thread pkg/workloadmanager/garbage_collection.go Outdated
Comment thread pkg/workloadmanager/sandbox_helper.go Outdated
Copilot AI review requested due to automatic review settings July 9, 2026 08:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread pkg/workloadmanager/workload_builder_test.go
Comment thread pkg/workloadmanager/workload_builder_test.go Outdated
Copilot AI review requested due to automatic review settings July 9, 2026 08:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread pkg/workloadmanager/workload_builder_test.go Outdated
Copilot AI review requested due to automatic review settings July 9, 2026 08:52
@safiya2610

Copy link
Copy Markdown
Contributor Author

One small follow-up: NoExpiryDeadline looks like an internal sentinel and is currently an exported mutable variable. Please make it unexported (for example noExpiryDeadline) so other packages cannot accidentally change the GC/store expiry behavior.

done, Please check.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Comment thread pkg/workloadmanager/workload_builder.go
Comment thread pkg/apis/runtime/v1alpha1/agent_type.go
Comment thread pkg/workloadmanager/workload_builder_test.go
Comment thread pkg/workloadmanager/workload_builder_test.go Outdated
Comment thread pkg/workloadmanager/sandbox_helper.go
Copilot AI review requested due to automatic review settings July 9, 2026 09:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 9, 2026 09:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment thread pkg/workloadmanager/workload_builder.go
Comment thread pkg/workloadmanager/workload_builder_test.go
Comment thread pkg/workloadmanager/sandbox_helper_test.go
Copilot AI review requested due to automatic review settings July 9, 2026 09:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment on lines +161 to +165
var shutdownTime *metav1.Time
if params.ttl != 0 {
st := metav1.NewTime(time.Now().Add(params.ttl))
shutdownTime = &st
}
Comment thread pkg/workloadmanager/workload_builder_test.go
Copilot AI review requested due to automatic review settings July 9, 2026 10:11
Make maxSessionDuration optional by falling back to DefaultSandboxTTL
when unset. Document the non-positive maxSessionDuration behavior,
make the noExpiryDeadline sentinel unexported, and strengthen the
default TTL fallback test.

Signed-off-by: Safiya <147792763+safiya2610@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 9, 2026 10:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@safiya2610

Copy link
Copy Markdown
Contributor Author

@acsoto ig, everything is done, Please review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove AgentRuntime default max ttl

5 participants