Skip to content

ocispec: raise actor RLIMIT_NOFILE from 1024 to 1048576 - #2242

Merged
Benjamin Elder (BenTheElder) merged 1 commit into
agent-substrate:mainfrom
ygao-g:ocispec-nofile-default
Oct 7, 2026
Merged

Benjamin Elder (BenTheElder) merged 1 commit into
agent-substrate:mainfrom
ygao-g:ocispec-nofile-default

Conversation

@ygao-g

Copy link
Copy Markdown
Collaborator

Pods have no rlimit field and inherit the runtime's limit, which is 1048576 on GKE for plain pods, containerd, atelet and the runsc sandbox. With no RLIMIT_NOFILE in the spec, the actor inherits the runsc sandbox process's host limit (1073741816 on kind, 1048576 on GKE).

Test plan

kind cluster built from this branch with hack/create-kind-cluster.sh and hack/install-ate-kind.sh --deploy-ate-system --deploy-demo-counter. An actor from the counter image with --validate-existing-file-path=/proc/self/limits returns its own limits through atenet-router:

$ curl -s -X POST -H "ate-target-actor: ate-demo-counter/limits-1" http://localhost:18000
Max open files            1048576              1048576              files

🤖 This PR was developed with AI assistance. I have reviewed and tested all changes.

Comment thread internal/ocispec/ocispec.go Outdated
const hostname = "actor"

// noFileLimit is the RLIMIT_NOFILE soft and hard limit for actor containers.
// It matches what containerd and runsc give a process on a GKE node.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's not leave suggestions in the code that we're just doing whatever GKE does and not considering other clusters ... and let's make sure that we have considered ecosystem. What does crun do? Does the OCI spec specify this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed, thanks!

Did some investigation with AI:

  • The OCI spec leaves process.rlimits optional and defines no default. Its sample config, runc spec, and crun spec all template 1024/1024, which is where Substrate's original pin came from.
  • At runtime runc and crun apply only what the spec lists and otherwise inherit their own limit.
  • Suggestions: keep pinning a value rather than inherit, because runsc refuses a restore whose rlimits differ from the checkpoint, as a result, snapshots restore only on nodes with the same host limit.

Comment thread internal/ocispec/ocispec.go Outdated
const hostname = "actor"

// noFileLimit is the RLIMIT_NOFILE soft and hard limit for actor containers.
const noFileLimit = 1048576

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why move this out to a top level const? just document it inline?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

generally OK with this, I don't think we should copy out the literal constant to a top level constant though, it's just harder to read and not being used anywhere else

@BenTheElder Benjamin Elder (BenTheElder) added kind/feature An enhancement / feature request or implementation area/node labels Oct 7, 2026
@ygao-g
Yuan Gao (ygao-g) force-pushed the ocispec-nofile-default branch 2 times, most recently from 61b0c01 to 6e30794 Compare October 7, 2026 01:18
Comment thread internal/ocispec/ocispec.go Outdated

// Build returns a runtime-neutral OCI spec for an actor container.
func Build(o Options) *specs.Spec {
// noFileLimit is the RLIMIT_NOFILE soft and hard limit: the kernel's

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

... being more explicit: before this change, these were literal inline constants. is there a good reason to not continue that and just update the value?

we don't need to explain what RLIMIT_NOFILE is if we just set them directly in the Rlimit spec.

This PR could be +2/-2 and easier to read later, the context below you don't know if noFileLimit is computed or constant.

Comment thread internal/ocispec/ocispec_test.go Outdated
}
}

func TestBuild_NoFileLimit(t *testing.T) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Testing a constant seems overkill?

Comment thread internal/ocispec/ocispec.go Outdated
Comment on lines +116 to +117
Hard: noFileLimit,
Soft: noFileLimit,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Hard: noFileLimit,
Soft: noFileLimit,
// NOTE: We raised NOFILE because <reason>
Hard: 1048576,
Soft: 1048576,

@BenTheElder
Benjamin Elder (BenTheElder) added this pull request to the merge queue Oct 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 7, 2026
@ygao-g

Copy link
Copy Markdown
Collaborator Author

PR got removed from merge queue due to FAIL: TestActorIdentity_AfterRestore_IsOwnID_NotGolden, which seems not directly relevant to the PR. Benjamin Elder (@BenTheElder) Can you please add the PR again to merge queue?

The OCI spec pinned RLIMIT_NOFILE for every actor container at 1024
soft and 1024 hard, with which a proxy-heavy actor can run out of sockets.
On the other hand, pods have no rlimit field and inherit the runtime's
limit, which on GKE is 1048576.
@BenTheElder
Benjamin Elder (BenTheElder) added this pull request to the merge queue Oct 7, 2026
Merged via the queue into agent-substrate:main with commit ff8420e Oct 7, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/node kind/feature An enhancement / feature request or implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the actor container RLIMIT_NOFILE configurable

2 participants