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
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,11 @@ jobs:
run: ${{ env.GOTESTSUM_CMD }} -gcflags=all=-d=checkptr -tags wcow -timeout=10m ./...

- name: Run non-functional tests
run: ${{ env.GOTESTSUM_CMD }} -mod=mod -gcflags=all=-d=checkptr ./internal/... ./pkg/... ./parity/...
run: ${{ env.GOTESTSUM_CMD }} -mod=mod -gcflags=all=-d=checkptr ./internal/... ./pkg/...
working-directory: test

- name: Run lcow parity tests
run: ${{ env.GOTESTSUM_CMD }} -mod=mod -gcflags=all=-d=checkptr -tags lcow ./parity/...
working-directory: test

- name: Build and run containerd-shim-runhcs-v1 tests
Expand Down
2 changes: 1 addition & 1 deletion internal/builder/vm/lcow/boot.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build windows
//go:build windows && lcow

package lcow

Expand Down
2 changes: 1 addition & 1 deletion internal/builder/vm/lcow/confidential.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build windows
//go:build windows && lcow

package lcow

Expand Down
2 changes: 1 addition & 1 deletion internal/builder/vm/lcow/devices.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build windows
//go:build windows && lcow

package lcow

Expand Down
2 changes: 2 additions & 0 deletions internal/builder/vm/lcow/doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build windows && lcow

// Package lcow encapsulates the business logic to parse annotations, devices,
// and runhcs options into an hcsschema.ComputeSystem document which will be used
// by the shim to create UVMs (Utility VMs) via the Host Compute Service (HCS).
Expand Down
2 changes: 1 addition & 1 deletion internal/builder/vm/lcow/kernel_args.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build windows
//go:build windows && lcow

package lcow

Expand Down
2 changes: 1 addition & 1 deletion internal/builder/vm/lcow/sandbox_options.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build windows
//go:build windows && lcow

package lcow

Expand Down
2 changes: 1 addition & 1 deletion internal/builder/vm/lcow/specs.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build windows
//go:build windows && lcow

package lcow

Expand Down
2 changes: 1 addition & 1 deletion internal/builder/vm/lcow/specs_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build windows
//go:build windows && lcow

package lcow

Expand Down
2 changes: 1 addition & 1 deletion internal/builder/vm/lcow/topology.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build windows
//go:build windows && lcow

package lcow

Expand Down
46 changes: 23 additions & 23 deletions internal/controller/device/plan9/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ type combinedGuest struct {
unmounter *mountmocks.MockGuestPlan9Unmounter
}

func (g *combinedGuest) AddLCOWMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error {
return g.mounter.AddLCOWMappedDirectory(ctx, settings)
func (g *combinedGuest) AddMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error {
return g.mounter.AddMappedDirectory(ctx, settings)
}

func (g *combinedGuest) RemoveLCOWMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error {
return g.unmounter.RemoveLCOWMappedDirectory(ctx, settings)
func (g *combinedGuest) RemoveMappedDirectory(ctx context.Context, settings guestresource.LCOWMappedDirectory) error {
return g.unmounter.RemoveMappedDirectory(ctx, settings)
}

type testController struct {
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestMapToGuest_HappyPath(t *testing.T) {
id, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{})

tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)

guestPath, err := tc.c.MapToGuest(tc.ctx, id)
if err != nil {
Expand Down Expand Up @@ -256,7 +256,7 @@ func TestMapToGuest_GuestMountFails_RetryMapToGuest_Fails(t *testing.T) {

// First MapToGuest: VM add succeeds, guest mount fails.
tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(errMount)
tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(errMount)

_, err := tc.c.MapToGuest(tc.ctx, id)
if err == nil {
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestMapToGuest_GuestMountFails_UnmapFromGuest_CleansUp(t *testing.T) {

// MapToGuest: VM add succeeds, guest mount fails.
tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(errMount)
tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(errMount)

_, err := tc.c.MapToGuest(tc.ctx, id)
if err == nil {
Expand All @@ -315,7 +315,7 @@ func TestMapToGuest_GuestMountFails_UnmapFromGuest_CleansUp(t *testing.T) {
}

// TestMapToGuest_SharedPath_VMAddCalledOnce verifies that when two reservations
// share the same host path, AddPlan9 and AddLCOWMappedDirectory are each called
// share the same host path, AddPlan9 and AddMappedDirectory are each called
// exactly once — the second MapToGuest is a no-op that returns the existing
// guest path.
func TestMapToGuest_SharedPath_VMAddCalledOnce(t *testing.T) {
Expand All @@ -325,9 +325,9 @@ func TestMapToGuest_SharedPath_VMAddCalledOnce(t *testing.T) {
id1, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{})
id2, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{})

// AddPlan9 and AddLCOWMappedDirectory each called exactly once.
// AddPlan9 and AddMappedDirectory each called exactly once.
tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil).Times(1)
tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1)
tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1)

gp1, err := tc.c.MapToGuest(tc.ctx, id1)
if err != nil {
Expand Down Expand Up @@ -356,10 +356,10 @@ func TestUnmapFromGuest_HappyPath(t *testing.T) {
id, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{})

tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
_, _ = tc.c.MapToGuest(tc.ctx, id)

tc.guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.vmRemove.EXPECT().RemovePlan9(gomock.Any(), gomock.Any()).Return(nil)

if err := tc.c.UnmapFromGuest(tc.ctx, id); err != nil {
Expand All @@ -383,11 +383,11 @@ func TestUnmapFromGuest_GuestUnmountFails_Retryable(t *testing.T) {
id, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{})

tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
_, _ = tc.c.MapToGuest(tc.ctx, id)

// First unmap: guest unmount fails.
tc.guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(errUnmount)
tc.guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(errUnmount)
if err := tc.c.UnmapFromGuest(tc.ctx, id); err == nil {
t.Fatal("expected error on failed guest unmount")
}
Expand All @@ -396,7 +396,7 @@ func TestUnmapFromGuest_GuestUnmountFails_Retryable(t *testing.T) {
}

// Retry succeeds.
tc.guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.vmRemove.EXPECT().RemovePlan9(gomock.Any(), gomock.Any()).Return(nil)
if err := tc.c.UnmapFromGuest(tc.ctx, id); err != nil {
t.Fatalf("retry UnmapFromGuest failed: %v", err)
Expand All @@ -414,11 +414,11 @@ func TestUnmapFromGuest_VMRemoveFails_Retryable(t *testing.T) {
id, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{})

tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
_, _ = tc.c.MapToGuest(tc.ctx, id)

// First unmap: guest unmount succeeds, VM remove fails.
tc.guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.vmRemove.EXPECT().RemovePlan9(gomock.Any(), gomock.Any()).Return(errVMRemove)
if err := tc.c.UnmapFromGuest(tc.ctx, id); err == nil {
t.Fatal("expected error on failed VM remove")
Expand Down Expand Up @@ -446,7 +446,7 @@ func TestUnmapFromGuest_RefCounting_VMRemoveOnLastRef(t *testing.T) {
id2, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{})

tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil).Times(1)
tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1)
tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1)
_, _ = tc.c.MapToGuest(tc.ctx, id1)
_, _ = tc.c.MapToGuest(tc.ctx, id2)

Expand All @@ -459,7 +459,7 @@ func TestUnmapFromGuest_RefCounting_VMRemoveOnLastRef(t *testing.T) {
}

// Second unmap: last ref — guest unmount and VM remove issued.
tc.guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1)
tc.guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil).Times(1)
tc.vmRemove.EXPECT().RemovePlan9(gomock.Any(), gomock.Any()).Return(nil).Times(1)
if err := tc.c.UnmapFromGuest(tc.ctx, id2); err != nil {
t.Fatalf("second UnmapFromGuest: %v", err)
Expand Down Expand Up @@ -501,9 +501,9 @@ func TestFullLifecycle_ReuseAfterRelease(t *testing.T) {
// First full cycle.
id1, _ := tc.c.Reserve(tc.ctx, share.Config{HostPath: "/host/path"}, mount.Config{})
tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
_, _ = tc.c.MapToGuest(tc.ctx, id1)
tc.guestUnmount.EXPECT().RemoveLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.guestUnmount.EXPECT().RemoveMappedDirectory(gomock.Any(), gomock.Any()).Return(nil)
tc.vmRemove.EXPECT().RemovePlan9(gomock.Any(), gomock.Any()).Return(nil)
_ = tc.c.UnmapFromGuest(tc.ctx, id1)

Expand Down Expand Up @@ -568,7 +568,7 @@ func TestUnmapFromGuest_AddToVMFails_MultipleReservations_AllDrain(t *testing.T)

// TestUnmapFromGuest_GuestMountFails_MultipleReservations_AllDrain verifies
// that when two callers reserve the same host path and MapToGuest fails at the
// guest mount stage (AddToVM succeeds, AddLCOWMappedDirectory fails), the share
// guest mount stage (AddToVM succeeds, AddMappedDirectory fails), the share
// and mount stay in the controller's maps until all callers have called
// UnmapFromGuest to drain their mount reservations.
func TestUnmapFromGuest_GuestMountFails_MultipleReservations_AllDrain(t *testing.T) {
Expand All @@ -581,7 +581,7 @@ func TestUnmapFromGuest_GuestMountFails_MultipleReservations_AllDrain(t *testing

// First caller attempts MapToGuest — AddToVM succeeds, guest mount fails.
tc.vmAdd.EXPECT().AddPlan9(gomock.Any(), gomock.Any()).Return(nil)
tc.guestMount.EXPECT().AddLCOWMappedDirectory(gomock.Any(), gomock.Any()).Return(errMount)
tc.guestMount.EXPECT().AddMappedDirectory(gomock.Any(), gomock.Any()).Return(errMount)
_, err := tc.c.MapToGuest(tc.ctx, id1)
if err == nil {
t.Fatal("expected error when guest mount fails")
Expand Down
24 changes: 12 additions & 12 deletions internal/controller/device/plan9/mount/mocks/mock_mount.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/controller/device/plan9/mount/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (m *Mount) MountToGuest(ctx context.Context, guest GuestPlan9Mounter) (stri
log.G(ctx).Debug("mounting Plan9 share in guest")

// Issue the guest mount via the GCS mapped directory API.
if err := guest.AddLCOWMappedDirectory(ctx, guestresource.LCOWMappedDirectory{
if err := guest.AddMappedDirectory(ctx, guestresource.LCOWMappedDirectory{
MountPath: m.guestPath,
ShareName: m.shareName,
Port: vmutils.Plan9Port,
Expand Down Expand Up @@ -143,7 +143,7 @@ func (m *Mount) UnmountFromGuest(ctx context.Context, guest GuestPlan9Unmounter)
log.G(ctx).Debug("unmounting Plan9 share from guest")

// Last reference — issue the physical guest unmount.
if err := guest.RemoveLCOWMappedDirectory(ctx, guestresource.LCOWMappedDirectory{
if err := guest.RemoveMappedDirectory(ctx, guestresource.LCOWMappedDirectory{
MountPath: m.guestPath,
ShareName: m.shareName,
Port: vmutils.Plan9Port,
Expand Down
Loading
Loading