Skip to content

FIX - implement OCI runtime state command [Enhancement]#621

Open
abhaygoudannavar wants to merge 4 commits intourunc-dev:mainfrom
abhaygoudannavar:two/OCI
Open

FIX - implement OCI runtime state command [Enhancement]#621
abhaygoudannavar wants to merge 4 commits intourunc-dev:mainfrom
abhaygoudannavar:two/OCI

Conversation

@abhaygoudannavar
Copy link
Copy Markdown

@abhaygoudannavar abhaygoudannavar commented May 4, 2026

Description

This PR implements the OCI state command for urunc, which outputs the current state information of a container instance conforming to the OCI runtime specification.

The implementation has been aligned with the reference runc implementation. Instead of blindly reading and marshaling state.json, it dynamically verifies the process status (using syscall.Kill(pid, 0)) to detect if the VMM has exited. It formats the JSON output using a custom containerState struct exactly as runc does to ensure orchestrators parsing the output receive the expected OCI schema.

Related issues

How was this tested?

  1. Created and started a unikernel container using urunc.
  2. Invoked urunc state <container-id> while the container was running and verified the output correctly matched the OCI JSON schema with status "running".
  3. Stopped the container and invoked urunc state <container-id> again, verifying it correctly dynamically detected the stopped state (returning status: "stopped" and pid: 0).
  4. Ran make unittest and verified no existing tests were broken.

LLM usage

No usage

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

When timestamps are enabled but the target file cannot be opened
(e.g. missing directory), NewZerologMetrics returned nil. This
caused a nil pointer dereference on subsequent metrics.Capture() calls.
This fix gracefully degrades to a no-op mockWriter and logs a warning.

Signed-off-by: abhaygoudannavar <abhaysgoudnvr@gmail.com>
Added TestZerologMetricsInvalidFileDoesNotPanic to ensure that if
the metrics log file cannot be opened, it gracefully degrades
instead of causing a nil pointer dereference.

Signed-off-by: abhaygoudannavar <abhaysgoudnvr@gmail.com>
Add the state command as defined in the OCI Runtime Specification (Query State). The command reads the persisted state.json and outputs OCI-compliant JSON to stdout. Falls back to runc for non-unikernel containers.

Signed-off-by: abhaygoudannavar <abhaysgoudnvr@gmail.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 4, 2026

Deploy Preview for urunc ready!

Name Link
🔨 Latest commit 034a222
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/69fba8b6669e6d000815ad63
😎 Deploy Preview https://deploy-preview-621--urunc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@cmainas
Copy link
Copy Markdown
Contributor

cmainas commented May 5, 2026

Hello @abhaygoudannavar ,

this PR contains unrelated changes. Also please use a similar implementation with https://github.com/opencontainers/runc/blob/main/state.go

@abhaygoudannavar
Copy link
Copy Markdown
Author

@cmainas, I have updated the PR to resolve both of your points:

  • I've removed the unrelated changes from this branch.
  • I've rewritten cmd/urunc/state.go to match the runc implementation.
  • updated the PR description.
    Let me know if everything looks good to go now.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement the OCI runtime state command [Enhancement]

2 participants