-
Notifications
You must be signed in to change notification settings - Fork 281
[shimV2] implements task, shimdiag service and wires up pod/container controllers #2685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,11 +7,13 @@ import ( | |
| "os" | ||
| "strings" | ||
|
|
||
| "github.com/Microsoft/hcsshim/internal/log" | ||
| "github.com/Microsoft/hcsshim/internal/logfields" | ||
| "github.com/Microsoft/hcsshim/internal/oc" | ||
| "github.com/Microsoft/hcsshim/internal/shimdiag" | ||
|
|
||
| "github.com/containerd/errdefs/pkg/errgrpc" | ||
| "github.com/sirupsen/logrus" | ||
| "go.opencensus.io/trace" | ||
| ) | ||
|
|
||
|
|
@@ -34,6 +36,9 @@ func (s *Service) DiagExecInHost(ctx context.Context, request *shimdiag.ExecProc | |
| trace.StringAttribute(logfields.Stdout, request.Stdout), | ||
| trace.StringAttribute(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)) | ||
|
|
||
| r, e := s.diagExecInHostInternal(ctx, request) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not: this is unnecessary/duplicative since any log using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right about that. While there was a way to correlate the sandbox ID from the other fields, it seemed more straightforward to just add it for now. I anyways have #2683 to re-calibrate the logging in the new shim. If it works for you, we can take a deeper look there if we want different log behaviour. |
||
| return r, errgrpc.ToGRPC(e) | ||
| } | ||
|
|
@@ -49,6 +54,9 @@ func (s *Service) DiagTasks(ctx context.Context, request *shimdiag.TasksRequest) | |
| trace.StringAttribute(logfields.SandboxID, s.sandboxID), | ||
| trace.BoolAttribute(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)) | ||
|
|
||
| r, e := s.diagTasksInternal(ctx, request) | ||
| return r, errgrpc.ToGRPC(e) | ||
| } | ||
|
|
@@ -66,20 +74,26 @@ func (s *Service) DiagShare(ctx context.Context, request *shimdiag.ShareRequest) | |
| trace.StringAttribute(logfields.UVMPath, request.UvmPath), | ||
| trace.BoolAttribute(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)) | ||
|
|
||
| r, e := s.diagShareInternal(ctx, request) | ||
| return r, errgrpc.ToGRPC(e) | ||
| } | ||
|
|
||
| // 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, request *shimdiag.StacksRequest) (resp *shimdiag.StacksResponse, err error) { | ||
| func (s *Service) DiagStacks(ctx context.Context, _ *shimdiag.StacksRequest) (resp *shimdiag.StacksResponse, err error) { | ||
| ctx, span := oc.StartSpan(ctx, "DiagStacks") | ||
| defer span.End() | ||
| defer func() { oc.SetSpanStatus(span, err) }() | ||
|
|
||
| span.AddAttributes(trace.StringAttribute(logfields.SandboxID, s.sandboxID)) | ||
|
|
||
| r, e := s.diagStacksInternal(ctx, request) | ||
| // 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)) | ||
|
|
||
| r, e := s.diagStacksInternal(ctx) | ||
| return r, errgrpc.ToGRPC(e) | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.