Skip to content

[shimV2] implements task, shimdiag service and wires up pod/container controllers#2685

Open
rawahars wants to merge 1 commit intomicrosoft:mainfrom
rawahars:task_service
Open

[shimV2] implements task, shimdiag service and wires up pod/container controllers#2685
rawahars wants to merge 1 commit intomicrosoft:mainfrom
rawahars:task_service

Conversation

@rawahars
Copy link
Copy Markdown
Contributor

Summary

This PR replaces all ErrNotImplemented stubs in the LCOW containerd shim (containerd-shim-lcow-v2) with full TaskService and ShimDiag implementations. These updates successfully delegate tasks to the pod, container, and process controllers introduced in the previous commit.

File Changes & Implementations

  • service_task_internal.go: Implements every task lifecycle RPC (Create, Start, Delete, Kill, Exec, Wait, State, Pids, Stats, Update, CloseIO, ResizePty, Shutdown).
    • Create: Distinguishes sandbox vs. workload containers via OCI annotations and manages pod/container controller mappings.
    • Delete: Handles both individual container and full pod teardown, including network cleanup.
    • Kill: Supports fan-out to all workload containers when the All flag is set on a sandbox.
    • Shutdown: Operates as a no-op since teardown is deferred to SandboxService.ShutdownSandbox.
  • service_shimdiag_internal.go:
    • Implements DiagTasks (lists all containers and their exec processes across every pod).
    • Implements DiagShare (shares a host path into the guest VM via the plan9 controller).
    • Implements DiagStacks (collects goroutine stacks from both the host shim and the guest VM).
  • service.go:
    • Introduces podControllers and containerPodMapping maps to track active pods and their containers.
    • Upgrades sync.Mutex to sync.RWMutex.
    • Adds an ensureVMRunning() precondition guard.
    • Activates send() for task event publishing.
  • main.go: Adds a minimum Windows build version check (≥ 26100 / V25H1Server) at startup and updates the build tag to windows && lcow.
  • plugin/plugin.go: Updates ETW provider ID and uses the logfields.SandboxID constant for structured logging.
  • Global: All files have been updated with the //go:build windows && lcow build constraint.

Signed-off-by: Harsh Rawat harshrawat@microsoft.com

… controllers

Implements the full TaskService and ShimDiag service methods for the
LCOW containerd shim (containerd-shim-lcow-v2), replacing the previous
`ErrNotImplemented` stubs with working lifecycle management.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>

sandboxsvc "github.com/containerd/containerd/api/runtime/sandbox/v1"
tasksvc "github.com/containerd/containerd/api/runtime/task/v3"
tasksvc "github.com/containerd/containerd/api/runtime/task/v2"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter what version?

// the provided server so that containerd can call into the shim over TTRPC.
func (s *Service) RegisterTTRPC(server *ttrpc.Server) error {
tasksvc.RegisterTTRPCTaskService(server, s)
tasksvc.RegisterTaskService(server, s)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh? Doesnt this have to be ttrpc for contained?

return nil, err
}

ec, err := s.vmController.ExecIntoHost(ctx, request)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it seem like the vmController ExecIntoHost should just handle the is_running? This would ensure its locked for the check and call versus it could change between these calls?

s.mu.RLock()
defer s.mu.RUnlock()

ctrl, ok := s.podControllers[podID]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it an error for containers but not here?

}

// Retrieve the process controller for the target exec (or init) process.
proc, err := ctrCtrl.GetProcess(request.ExecID)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a notfound by contract as well?

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.

2 participants