Skip to content
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

Automatic ttrpc and bridge span creation #1379

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/containerd-shim-runhcs-v1/exec_hcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ func (he *hcsExec) waitForContainerExit() {
trace.StringAttribute("tid", he.tid),
trace.StringAttribute("eid", he.id))

// wait for container or process to exit and ckean up resrources
// wait for container or process to exit and clean up resources
select {
case <-he.c.WaitChannel():
// Container exited first. We need to force the process into the exited
Expand Down
16 changes: 13 additions & 3 deletions cmd/containerd-shim-runhcs-v1/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"go.opencensus.io/trace"
"golang.org/x/sys/windows"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"

runhcsopts "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
"github.com/Microsoft/hcsshim/internal/extendedtask"
hcslog "github.com/Microsoft/hcsshim/internal/log"
"github.com/Microsoft/hcsshim/internal/logfields"
"github.com/Microsoft/hcsshim/internal/shimdiag"
"github.com/Microsoft/hcsshim/pkg/octtrpc"
)
Expand Down Expand Up @@ -116,7 +118,7 @@ var serveCommand = cli.Command{
// TODO: JTERRY75 we need this to be the reconnect log listener or
// switch to events
// TODO: JTERRY75 switch containerd to use the protected path.
//const logAddrFmt = "\\\\.\\pipe\\ProtectedPrefix\\Administrators\\containerd-shim-%s-%s-log"
// const logAddrFmt = "\\\\.\\pipe\\ProtectedPrefix\\Administrators\\containerd-shim-%s-%s-log"
const logAddrFmt = "\\\\.\\pipe\\containerd-shim-%s-%s-log"
logl, err := winio.ListenPipe(fmt.Sprintf(logAddrFmt, namespaceFlag, idFlag), nil)
if err != nil {
Expand Down Expand Up @@ -193,7 +195,15 @@ var serveCommand = cli.Command{
return fmt.Errorf("failed to create new service: %w", err)
}

s, err := ttrpc.NewServer(ttrpc.WithUnaryServerInterceptor(octtrpc.ServerInterceptor()))
s, err := ttrpc.NewServer(
ttrpc.WithUnaryServerInterceptor(octtrpc.ServerInterceptor(
octtrpc.WithAttributes( // TODO (helsaawy) set these in resource when we switch to OTel
trace.StringAttribute(logfields.ShimID, svc.tid),
trace.BoolAttribute(logfields.IsSandbox, svc.isSandbox),
),
octtrpc.WithAddMessage(),
octtrpc.WithAddMessageHook(hcslog.ScrubShimTTRPC),
)))
if err != nil {
return err
}
Expand Down Expand Up @@ -310,7 +320,7 @@ func createEvent(event string) (windows.Handle, error) {
}

// setupDebuggerEvent listens for an event to allow a debugger such as delve
// to attach for advanced debugging. It's called when handling a ContainerCreate
// to attach for advanced debugging. It's called when handling a ContainerCreate.
func setupDebuggerEvent() {
if os.Getenv("CONTAINERD_SHIM_RUNHCS_V1_WAIT_DEBUGGER") == "" {
return
Expand Down
Loading
Loading