Skip to content

Suggest sudo when a non-root onctl can't pause/stop a root-owned fc VM - #1142

Merged
cdalar merged 1 commit into
mainfrom
fc-privilege-hint
Sep 27, 2026
Merged

cdalar merged 1 commit into
mainfrom
fc-privilege-hint

Conversation

@cdalar

@cdalar cdalar commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Problem

A Firecracker microVM created with sudo onctl create is owned by root: its firecracker process and its API socket both belong to root. Running onctl pause or onctl delete without root against it returns bare errors that don't say what to do:

failed to pause microVM: Patch "http://unix/vm": dial unix /opt/fc-vms/vms/kerneltest/fc.sock: connect: permission denied
failed to stop microVM: operation not permitted

Change

  • New withRootHint helper in pkg/cloud/fc.go. When an error is os.ErrPermission (EACCES/EPERM), it appends (microVM "<name>" is owned by another user, typically root; re-run with sudo). The original error stays wrapped, so errors.Is checks still work.
  • Applied at four places: Pause's SetState call, Pause's stop after the snapshot, Destroy's stop, and Restart's stop.
  • Resume and Deploy are unchanged (out of scope).

Tests

TestProviderFC_PermissionErrorsSuggestSudo sends EACCES and EPERM through Pause, Destroy and Restart and asserts that the hint appears. It also checks that a failed Destroy leaves the VM's files in place, and that non-permission errors get no hint. go test ./pkg/cloud/ ./internal/providerfc/ passes, and go vet is clean for linux and windows.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KTuQfhvGE9iLYpSpvUt1yy

Pause, Destroy and Restart surfaced bare 'permission denied' / 'operation
not permitted' errors when run without root against a microVM created
with sudo. Wrap EACCES/EPERM from the API socket and process signal with a
hint to re-run with sudo.

Claude-Session: https://claude.ai/code/session_01KTuQfhvGE9iLYpSpvUt1yy
@codecov

codecov Bot commented Sep 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 34.65%. Comparing base (4f2cb2c) to head (03700b5).

Files with missing lines Patch % Lines
pkg/cloud/fc.go 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1142      +/-   ##
==========================================
+ Coverage   34.56%   34.65%   +0.08%     
==========================================
  Files          51       51              
  Lines        5612     5615       +3     
==========================================
+ Hits         1940     1946       +6     
+ Misses       3672     3669       -3     

☔ 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.

@cdalar
cdalar merged commit c89a52d into main Sep 27, 2026
14 checks passed
@cdalar
cdalar deleted the fc-privilege-hint branch September 27, 2026 17:25
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.

1 participant

⌂ 换网址