Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ useful than saying where the real one is.

### Fixed

- **`skrog compact` no longer fails at `fstrim` on WSL 3.0** ([#560](https://github.com/wslkit/skrog/issues/560)).
WSL 3.0's `wsl --exec` does not find tools in `/sbin` by name, so the first step failed
with `execvpe(fstrim) failed`. It now runs `/sbin/fstrim`. On WSL 3.0.3 compaction still
fails at the next step, because the disk is not released; #560 tracks that.
- **`wsl.auto-memory-reclaim` now takes effect** ([#550](https://github.com/wslkit/skrog/issues/550)).
`skrog wsl-config apply` wrote `autoMemoryReclaim` under `[wsl2]`, but WSL reads it only
as `experimental.autoMemoryReclaim`: it ignored the line and printed `Unknown key
Expand Down
4 changes: 3 additions & 1 deletion internal/compact/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ func (r *Runner) Run(ctx context.Context, opts Options) (Report, error) {
// 1. Trim: the guest tells the disk what it no longer uses. Without this,
// compaction has nothing to reclaim.
if !opts.NoTrim {
out, err := r.WSL.Exec(ctx, opts.Distro, "root", "fstrim", "-v", "/")
// By path: WSL 3.0's `wsl --exec` does not find /sbin tools by name
// (#560). The rootfs is ours, so the path is fixed.
out, err := r.WSL.Exec(ctx, opts.Distro, "root", "/sbin/fstrim", "-v", "/")
if err != nil {
return rep, fmt.Errorf("compact: fstrim in %s: %w: %s", opts.Distro, err, strings.TrimSpace(out))
}
Expand Down
7 changes: 6 additions & 1 deletion internal/compact/compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ type fakeWSL struct {

func (f *fakeWSL) Exec(_ context.Context, distro, user string, args ...string) (string, error) {
f.calls = append(f.calls, "exec:"+distro+":"+strings.Join(args, " "))
// WSL 3.0's relay does not search /sbin for `wsl --exec`, though /sbin is
// on the PATH the process gets (#560).
if args[0] == "fstrim" {
return "execvpe(fstrim) failed: No such file or directory", errors.New("exit status 1")
}
return f.fstrimOut, f.fstrimErr
}

Expand Down Expand Up @@ -94,7 +99,7 @@ func TestHappyPathOrdersTrimStopTerminateCompact(t *testing.T) {
if !started {
t.Error("--restart did not start the engine again")
}
if got := strings.Join(w.calls, "|"); !strings.Contains(got, "exec:skrog-engine:fstrim -v /") ||
if got := strings.Join(w.calls, "|"); !strings.Contains(got, "exec:skrog-engine:/sbin/fstrim -v /") ||
!strings.Contains(got, "terminate:skrog-engine") {
t.Errorf("calls = %s", got)
}
Expand Down
Loading