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: 2 additions & 2 deletions cmd/containerd-shim-lcow-v2/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ func (m *shimManager) Start(ctx context.Context, id string, opts shim.StartOpts)
// It reads and logs any panic messages written to panic.log, then tries to
// terminate the associated HCS compute system and waits up to 30 seconds for
// it to exit.
func (m *shimManager) Stop(_ context.Context, id string) (resp shim.StopStatus, err error) {
ctx, span := ot.StartSpan(context.Background(), "delete")
func (m *shimManager) Stop(ctx context.Context, id string) (resp shim.StopStatus, err error) {
ctx, span := ot.StartSpan(ctx, "delete")
defer span.End()
defer func() { ot.SetSpanStatus(span, err) }()

Expand Down
18 changes: 18 additions & 0 deletions cmd/containerd-shim-lcow-v2/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,29 @@
package main

import (
"context"
"os"
"path/filepath"
"testing"

"github.com/Microsoft/hcsshim/internal/shim"
)

func TestStopPreservesShimOptionsContext(t *testing.T) {
ctx := context.WithValue(t.Context(), shim.OptsKey{}, shim.Opts{BundlePath: t.TempDir()})

status, err := newShimManager("test").Stop(ctx, "nonexistent-stop-context-test")
if err != nil {
t.Fatalf("Stop: %v", err)
}
if status.ExitStatus != 255 {
t.Fatalf("ExitStatus = %d, want 255", status.ExitStatus)
}
if status.ExitedAt.IsZero() {
t.Fatal("ExitedAt is zero")
}
}

// TestLimitedRead verifies that limitedRead correctly enforces the byte limit
// when the file is larger than the limit, and reads the full content when the
// file is smaller than the limit.
Expand Down
Loading