Skip to content

Commit 4d88914

Browse files
committed
ActivateLayer: log via containerd/log
1 parent 0e7c065 commit 4d88914

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

internal/wclayer/activatelayer.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ package wclayer
44

55
import (
66
"context"
7-
"fmt"
8-
"os"
97
"syscall"
108
"time"
119

10+
"github.com/containerd/log"
1211
"github.com/Microsoft/hcsshim/internal/hcserror"
1312
"github.com/Microsoft/hcsshim/internal/oc"
1413
"go.opencensus.io/trace"
@@ -29,25 +28,27 @@ func ActivateLayer(ctx context.Context, path string) (err error) {
2928
defer func() { oc.SetSpanStatus(span, err) }()
3029
span.AddAttributes(trace.StringAttribute("path", path))
3130

31+
logEntry := log.G(ctx)
32+
3233
sleepSecs := 1
3334
for sleepSecs <= 30 {
34-
fmt.Fprintf(os.Stderr, "calling activateLayer\n")
35+
logEntry.Info("calling activateLayer")
3536
err = activateLayer(&stdDriverInfo, path)
3637
if err == nil {
37-
fmt.Fprintf(os.Stderr, "activateLayer succeeded\n")
38+
logEntry.Info("activateLayer succeeded")
3839
break
3940
}
4041
if errnoErr, ok := err.(syscall.Errno); ok {
4142
errnoInt := uintptr(errnoErr)
42-
fmt.Fprintf(os.Stderr, "it's an errno error and our errno is %d\n", errnoInt)
43+
logEntry.Infof("it's an errno error and our errno is %d", errnoInt)
4344
if errnoInt == errnoERROR_SHARING_VIOLATION {
44-
fmt.Fprintf(os.Stderr, "it's a sharing violation; sleeping %d this time\n", sleepSecs)
45+
logEntry.Infof("it's a sharing violation; sleeping %d s this time", sleepSecs)
4546
time.Sleep(time.Duration(sleepSecs * 1000000000))
4647
sleepSecs = sleepSecs * 2
4748
continue
4849
}
4950
} else {
50-
fmt.Fprintf(os.Stderr, "it's not an errno error\n")
51+
logEntry.Info("it's not an errno error")
5152
}
5253

5354
break

0 commit comments

Comments
 (0)