Skip to content
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ jobs:
run: ${{ env.GO_BUILD_CMD }} -mod=mod -o sample-logging-driver.exe ./cri-containerd/helpers/log.go
working-directory: test

- uses: actions/upload-artifact@v7
- uses: actions/upload-artifact@v6

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.

This should remain at V7.

if: ${{ github.event_name == 'pull_request' }}
with:
name: test_binaries_${{ matrix.name }}
Expand Down Expand Up @@ -723,7 +723,7 @@ jobs:
- run: ${{ env.GO_BUILD_CMD }} ./internal/tools/zapdir
name: Build zapdir.exe

- uses: actions/upload-artifact@v7
- uses: actions/upload-artifact@v6

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.

This should remain at V7.

if: ${{ github.event_name == 'pull_request' }}
with:
name: binaries
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ jobs:
sarif_file: sarif-results

- name: Upload SARIF Results as Build Artifact
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v6

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.

This should remain at V7.

with:
name: sarif-results-${{ matrix.goos }}
path: sarif-results
Expand Down
8 changes: 4 additions & 4 deletions cmd/containerd-shim-lcow-v2/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
runhcsopts "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
hcs "github.com/Microsoft/hcsshim/internal/hcs/v2"
"github.com/Microsoft/hcsshim/internal/memory"
"github.com/Microsoft/hcsshim/internal/oc"
"github.com/Microsoft/hcsshim/internal/ot"
"github.com/Microsoft/hcsshim/internal/shim"
hcsversion "github.com/Microsoft/hcsshim/internal/version"

Expand Down Expand Up @@ -183,10 +183,10 @@ 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(ctx context.Context, id string) (resp shim.StopStatus, err error) {
ctx, span := oc.StartSpan(ctx, "delete")
func (m *shimManager) Stop(_ context.Context, id string) (resp shim.StopStatus, err error) {
ctx, span := ot.StartSpan(context.Background(), "delete")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

var bundlePath string
if opts, ok := ctx.Value(shim.OptsKey{}).(shim.Opts); ok {
Expand Down
68 changes: 34 additions & 34 deletions cmd/containerd-shim-lcow-v2/service/service_sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (

"github.com/Microsoft/hcsshim/internal/log"
"github.com/Microsoft/hcsshim/internal/logfields"
"github.com/Microsoft/hcsshim/internal/oc"
"github.com/Microsoft/hcsshim/internal/ot"

"github.com/containerd/containerd/api/runtime/sandbox/v1"
"github.com/containerd/errdefs/pkg/errgrpc"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
"go.opentelemetry.io/otel/attribute"
)

// Ensure Service implements the TTRPCSandboxService interface at compile time.
Expand All @@ -21,16 +21,16 @@ var _ sandbox.TTRPCSandboxService = &Service{}
// CreateSandbox creates (or prepares) a new sandbox for the given SandboxID.
// This method is part of the instrumentation layer and business logic is included in createSandboxInternal.
func (s *Service) CreateSandbox(ctx context.Context, request *sandbox.CreateSandboxRequest) (resp *sandbox.CreateSandboxResponse, err error) {
ctx, span := oc.StartSpan(ctx, "CreateSandbox")
ctx, span := ot.StartSpan(ctx, "CreateSandbox")
defer span.End()
defer func() {
oc.SetSpanStatus(span, err)
ot.SetSpanStatus(span, err)
}()

span.AddAttributes(
trace.StringAttribute(logfields.SandboxID, request.SandboxID),
trace.StringAttribute(logfields.Bundle, request.BundlePath),
trace.StringAttribute(logfields.NetNsPath, request.NetnsPath),
span.SetAttributes(
attribute.String(logfields.SandboxID, request.SandboxID),
attribute.String(logfields.Bundle, request.BundlePath),
attribute.String(logfields.NetNsPath, request.NetnsPath),
)

// Set the sandbox ID in the logger context for all subsequent logs in this request.
Expand All @@ -43,11 +43,11 @@ func (s *Service) CreateSandbox(ctx context.Context, request *sandbox.CreateSand
// StartSandbox transitions a previously created sandbox to the "running" state.
// This method is part of the instrumentation layer and business logic is included in startSandboxInternal.
func (s *Service) StartSandbox(ctx context.Context, request *sandbox.StartSandboxRequest) (resp *sandbox.StartSandboxResponse, err error) {
ctx, span := oc.StartSpan(ctx, "StartSandbox")
ctx, span := ot.StartSpan(ctx, "StartSandbox")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(trace.StringAttribute(logfields.SandboxID, request.SandboxID))
span.SetAttributes(attribute.String(logfields.SandboxID, request.SandboxID))

// Set the sandbox ID in the logger context for all subsequent logs in this request.
ctx, _ = log.WithContext(ctx, logrus.WithField(logfields.SandboxID, request.SandboxID))
Expand All @@ -59,11 +59,11 @@ func (s *Service) StartSandbox(ctx context.Context, request *sandbox.StartSandbo
// Platform returns the platform details for the sandbox ("windows/amd64" or "linux/amd64").
// This method is part of the instrumentation layer and business logic is included in platformInternal.
func (s *Service) Platform(ctx context.Context, request *sandbox.PlatformRequest) (resp *sandbox.PlatformResponse, err error) {
ctx, span := oc.StartSpan(ctx, "Platform")
ctx, span := ot.StartSpan(ctx, "Platform")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(trace.StringAttribute(logfields.SandboxID, request.SandboxID))
span.SetAttributes(attribute.String(logfields.SandboxID, request.SandboxID))

r, e := s.platformInternal(ctx, request)
return r, errgrpc.ToGRPC(e)
Expand All @@ -72,12 +72,12 @@ func (s *Service) Platform(ctx context.Context, request *sandbox.PlatformRequest
// StopSandbox attempts a graceful stop of the sandbox within the specified timeout.
// This method is part of the instrumentation layer and business logic is included in stopSandboxInternal.
func (s *Service) StopSandbox(ctx context.Context, request *sandbox.StopSandboxRequest) (resp *sandbox.StopSandboxResponse, err error) {
ctx, span := oc.StartSpan(ctx, "StopSandbox")
ctx, span := ot.StartSpan(ctx, "StopSandbox")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(trace.StringAttribute(logfields.SandboxID, request.SandboxID))
span.AddAttributes(trace.Int64Attribute(logfields.Timeout, int64(request.TimeoutSecs)))
span.SetAttributes(attribute.String(logfields.SandboxID, request.SandboxID))
span.SetAttributes(attribute.Int64(logfields.Timeout, int64(request.TimeoutSecs)))

// Set the sandbox ID in the logger context for all subsequent logs in this request.
ctx, _ = log.WithContext(ctx, logrus.WithField(logfields.SandboxID, request.SandboxID))
Expand All @@ -89,11 +89,11 @@ func (s *Service) StopSandbox(ctx context.Context, request *sandbox.StopSandboxR
// WaitSandbox blocks until the sandbox reaches a terminal state (stopped/errored) and returns the outcome.
// This method is part of the instrumentation layer and business logic is included in waitSandboxInternal.
func (s *Service) WaitSandbox(ctx context.Context, request *sandbox.WaitSandboxRequest) (resp *sandbox.WaitSandboxResponse, err error) {
ctx, span := oc.StartSpan(ctx, "WaitSandbox")
ctx, span := ot.StartSpan(ctx, "WaitSandbox")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(trace.StringAttribute(logfields.SandboxID, request.SandboxID))
span.SetAttributes(attribute.String(logfields.SandboxID, request.SandboxID))

// Set the sandbox ID in the logger context for all subsequent logs in this request.
ctx, _ = log.WithContext(ctx, logrus.WithField(logfields.SandboxID, request.SandboxID))
Expand All @@ -105,12 +105,12 @@ func (s *Service) WaitSandbox(ctx context.Context, request *sandbox.WaitSandboxR
// SandboxStatus returns current status for the sandbox, optionally verbose.
// This method is part of the instrumentation layer and business logic is included in sandboxStatusInternal.
func (s *Service) SandboxStatus(ctx context.Context, request *sandbox.SandboxStatusRequest) (resp *sandbox.SandboxStatusResponse, err error) {
ctx, span := oc.StartSpan(ctx, "SandboxStatus")
ctx, span := ot.StartSpan(ctx, "SandboxStatus")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(trace.StringAttribute(logfields.SandboxID, request.SandboxID))
span.AddAttributes(trace.BoolAttribute(logfields.Verbose, request.Verbose))
span.SetAttributes(attribute.String(logfields.SandboxID, request.SandboxID))
span.SetAttributes(attribute.Bool(logfields.Verbose, request.Verbose))

// Set the sandbox ID in the logger context for all subsequent logs in this request.
ctx, _ = log.WithContext(ctx, logrus.WithField(logfields.SandboxID, request.SandboxID))
Expand All @@ -122,11 +122,11 @@ func (s *Service) SandboxStatus(ctx context.Context, request *sandbox.SandboxSta
// PingSandbox performs a minimal liveness check on the sandbox and returns quickly.
// This method is part of the instrumentation layer and business logic is included in pingSandboxInternal.
func (s *Service) PingSandbox(ctx context.Context, request *sandbox.PingRequest) (resp *sandbox.PingResponse, err error) {
ctx, span := oc.StartSpan(ctx, "PingSandbox")
ctx, span := ot.StartSpan(ctx, "PingSandbox")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(trace.StringAttribute(logfields.SandboxID, request.SandboxID))
span.SetAttributes(attribute.String(logfields.SandboxID, request.SandboxID))

// Set the sandbox ID in the logger context for all subsequent logs in this request.
ctx, _ = log.WithContext(ctx, logrus.WithField(logfields.SandboxID, request.SandboxID))
Expand All @@ -139,11 +139,11 @@ func (s *Service) PingSandbox(ctx context.Context, request *sandbox.PingRequest)
// typically used by the higher-level controller to tear down resources and exit the shim.
// This method is part of the instrumentation layer and business logic is included in shutdownSandboxInternal.
func (s *Service) ShutdownSandbox(ctx context.Context, request *sandbox.ShutdownSandboxRequest) (resp *sandbox.ShutdownSandboxResponse, err error) {
ctx, span := oc.StartSpan(ctx, "ShutdownSandbox")
ctx, span := ot.StartSpan(ctx, "ShutdownSandbox")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(trace.StringAttribute(logfields.SandboxID, request.SandboxID))
span.SetAttributes(attribute.String(logfields.SandboxID, request.SandboxID))

// Set the sandbox ID in the logger context for all subsequent logs in this request.
ctx, _ = log.WithContext(ctx, logrus.WithField(logfields.SandboxID, request.SandboxID))
Expand All @@ -156,11 +156,11 @@ func (s *Service) ShutdownSandbox(ctx context.Context, request *sandbox.Shutdown
// suitable for monitoring and autoscaling decisions.
// This method is part of the instrumentation layer and business logic is included in sandboxMetricsInternal.
func (s *Service) SandboxMetrics(ctx context.Context, request *sandbox.SandboxMetricsRequest) (resp *sandbox.SandboxMetricsResponse, err error) {
ctx, span := oc.StartSpan(ctx, "SandboxMetrics")
ctx, span := ot.StartSpan(ctx, "SandboxMetrics")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(trace.StringAttribute(logfields.SandboxID, request.SandboxID))
span.SetAttributes(attribute.String(logfields.SandboxID, request.SandboxID))

// Set the sandbox ID in the logger context for all subsequent logs in this request.
ctx, _ = log.WithContext(ctx, logrus.WithField(logfields.SandboxID, request.SandboxID))
Expand Down
60 changes: 30 additions & 30 deletions cmd/containerd-shim-lcow-v2/service/service_shimdiag.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (

"github.com/Microsoft/hcsshim/internal/log"
"github.com/Microsoft/hcsshim/internal/logfields"
"github.com/Microsoft/hcsshim/internal/oc"
"github.com/Microsoft/hcsshim/internal/ot"
"github.com/Microsoft/hcsshim/internal/shimdiag"

"github.com/containerd/errdefs/pkg/errgrpc"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
"go.opentelemetry.io/otel/attribute"
)

// Ensure Service implements the ShimDiagService interface at compile time.
Expand All @@ -23,18 +23,18 @@ var _ shimdiag.ShimDiagService = &Service{}
// DiagExecInHost executes a process in the host namespace for diagnostic purposes.
// This method is part of the instrumentation layer and business logic is included in diagExecInHostInternal.
func (s *Service) DiagExecInHost(ctx context.Context, request *shimdiag.ExecProcessRequest) (resp *shimdiag.ExecProcessResponse, err error) {
ctx, span := oc.StartSpan(ctx, "DiagExecInHost")
ctx, span := ot.StartSpan(ctx, "DiagExecInHost")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(
trace.StringAttribute(logfields.SandboxID, s.sandboxID),
trace.StringAttribute(logfields.Args, strings.Join(request.Args, " ")),
trace.StringAttribute(logfields.Workdir, request.Workdir),
trace.BoolAttribute(logfields.Terminal, request.Terminal),
trace.StringAttribute(logfields.Stdin, request.Stdin),
trace.StringAttribute(logfields.Stdout, request.Stdout),
trace.StringAttribute(logfields.Stderr, request.Stderr))
span.SetAttributes(
attribute.String(logfields.SandboxID, s.sandboxID),
attribute.String(logfields.Args, strings.Join(request.Args, " ")),
attribute.String(logfields.Workdir, request.Workdir),
attribute.Bool(logfields.Terminal, request.Terminal),
attribute.String(logfields.Stdin, request.Stdin),
attribute.String(logfields.Stdout, request.Stdout),
attribute.String(logfields.Stderr, request.Stderr))

// Set the sandbox ID in the logger context for all subsequent logs in this request.
ctx, _ = log.WithContext(ctx, logrus.WithField(logfields.SandboxID, s.sandboxID))
Expand All @@ -46,13 +46,13 @@ func (s *Service) DiagExecInHost(ctx context.Context, request *shimdiag.ExecProc
// DiagTasks returns information about all tasks in the shim.
// This method is part of the instrumentation layer and business logic is included in diagTasksInternal.
func (s *Service) DiagTasks(ctx context.Context, request *shimdiag.TasksRequest) (resp *shimdiag.TasksResponse, err error) {
ctx, span := oc.StartSpan(ctx, "DiagTasks")
ctx, span := ot.StartSpan(ctx, "DiagTasks")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(
trace.StringAttribute(logfields.SandboxID, s.sandboxID),
trace.BoolAttribute(logfields.Execs, request.Execs))
span.SetAttributes(
attribute.String(logfields.SandboxID, s.sandboxID),
attribute.Bool(logfields.Execs, request.Execs))

// Set the sandbox ID in the logger context for all subsequent logs in this request.
ctx, _ = log.WithContext(ctx, logrus.WithField(logfields.SandboxID, s.sandboxID))
Expand All @@ -64,15 +64,15 @@ func (s *Service) DiagTasks(ctx context.Context, request *shimdiag.TasksRequest)
// DiagShare shares a directory from the host into the sandbox.
// This method is part of the instrumentation layer and business logic is included in diagShareInternal.
func (s *Service) DiagShare(ctx context.Context, request *shimdiag.ShareRequest) (resp *shimdiag.ShareResponse, err error) {
ctx, span := oc.StartSpan(ctx, "DiagShare")
ctx, span := ot.StartSpan(ctx, "DiagShare")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(
trace.StringAttribute(logfields.SandboxID, s.sandboxID),
trace.StringAttribute(logfields.HostPath, request.HostPath),
trace.StringAttribute(logfields.UVMPath, request.UvmPath),
trace.BoolAttribute(logfields.ReadOnly, request.ReadOnly))
span.SetAttributes(
attribute.String(logfields.SandboxID, s.sandboxID),
attribute.String(logfields.HostPath, request.HostPath),
attribute.String(logfields.UVMPath, request.UvmPath),
attribute.Bool(logfields.ReadOnly, request.ReadOnly))

// Set the sandbox ID in the logger context for all subsequent logs in this request.
ctx, _ = log.WithContext(ctx, logrus.WithField(logfields.SandboxID, s.sandboxID))
Expand All @@ -84,11 +84,11 @@ func (s *Service) DiagShare(ctx context.Context, request *shimdiag.ShareRequest)
// DiagStacks returns the stack traces of all goroutines in the shim.
// This method is part of the instrumentation layer and business logic is included in diagStacksInternal.
func (s *Service) DiagStacks(ctx context.Context, _ *shimdiag.StacksRequest) (resp *shimdiag.StacksResponse, err error) {
ctx, span := oc.StartSpan(ctx, "DiagStacks")
ctx, span := ot.StartSpan(ctx, "DiagStacks")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(trace.StringAttribute(logfields.SandboxID, s.sandboxID))
span.SetAttributes(attribute.String(logfields.SandboxID, s.sandboxID))

// Set the sandbox ID in the logger context for all subsequent logs in this request.
ctx, _ = log.WithContext(ctx, logrus.WithField(logfields.SandboxID, s.sandboxID))
Expand All @@ -99,11 +99,11 @@ func (s *Service) DiagStacks(ctx context.Context, _ *shimdiag.StacksRequest) (re

// DiagPid returns the process ID (PID) of the shim for diagnostic purposes.
func (s *Service) DiagPid(ctx context.Context, _ *shimdiag.PidRequest) (resp *shimdiag.PidResponse, err error) {
_, span := oc.StartSpan(ctx, "DiagPid")
_, span := ot.StartSpan(ctx, "DiagPid")
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
defer func() { ot.SetSpanStatus(span, err) }()

span.AddAttributes(trace.StringAttribute(logfields.SandboxID, s.sandboxID))
span.SetAttributes(attribute.String(logfields.SandboxID, s.sandboxID))

return &shimdiag.PidResponse{
Pid: int32(os.Getpid()),
Expand Down
Loading
Loading