Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: microsoft/hcsshim
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.12.0
Choose a base ref
...
head repository: microsoft/hcsshim
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.12.1
Choose a head ref
  • 3 commits
  • 4 files changed
  • 3 contributors

Commits on Mar 20, 2024

  1. Add spans and drop large size high volume trace logs

    Signed-off-by: Kirtana Ashok <kiashok@microsoft.com>
    (cherry picked from commit c91d82d)
    Signed-off-by: Kirtana Ashok <kiashok@microsoft.com>
    kiashok committed Mar 20, 2024
    Copy the full SHA
    202f90a View commit details

Commits on Mar 22, 2024

  1. Updating permissions and github release action versions (#2078) (#2079)

    Signed-off-by: Heather Garvison <hgarvison@microsoft.com>
    (cherry picked from commit a58b414)
    
    Co-authored-by: Heather Garvison <hgarvison@microsoft.com>
    anmaxvl and hgarvison authored Mar 22, 2024
    Copy the full SHA
    6588c1c View commit details

Commits on Mar 23, 2024

  1. fix: move permissions to the correct job (#2080) (#2081)

    The permissions block should be under `create_release` job, rather
    than `build`.
    
    Signed-off-by: Maksim An <maksiman@microsoft.com>
    (cherry picked from commit 3eeba90)
    anmaxvl authored Mar 23, 2024
    Copy the full SHA
    ad1ccf5 View commit details
Showing with 30 additions and 9 deletions.
  1. +3 −1 .github/workflows/release.yml
  2. +1 −1 cmd/containerd-shim-runhcs-v1/exec_hcs.go
  3. +22 −4 internal/gcs/bridge.go
  4. +4 −3 internal/guest/bridge/bridge.go
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -32,14 +32,16 @@ jobs:
create_release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: binaries

- name: Publish release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2.0.4
with:
prerelease: ${{ contains(github.ref, 'rc') }}
files: |
2 changes: 1 addition & 1 deletion cmd/containerd-shim-runhcs-v1/exec_hcs.go
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ func newHcsExec(
"eid": id, // Init exec ID is always same as Task ID
"bundle": bundle,
"wcow": isWCOW,
}).Debug("newHcsExec")
}).Trace("newHcsExec")

he := &hcsExec{
events: events,
26 changes: 22 additions & 4 deletions internal/gcs/bridge.go
Original file line number Diff line number Diff line change
@@ -16,9 +16,11 @@ import (
"time"

"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
"golang.org/x/sys/windows"

"github.com/Microsoft/hcsshim/internal/log"
"github.com/Microsoft/hcsshim/internal/oc"
)

const (
@@ -258,6 +260,9 @@ func (brdg *bridge) recvLoopRoutine() {
}

func readMessage(r io.Reader) (int64, msgType, []byte, error) {
_, span := oc.StartSpan(context.Background(), "bridge receive read message", oc.WithClientSpanKind)
defer span.End()

var h [hdrSize]byte
_, err := io.ReadFull(r, h[:])
if err != nil {
@@ -266,6 +271,10 @@ func readMessage(r io.Reader) (int64, msgType, []byte, error) {
typ := msgType(binary.LittleEndian.Uint32(h[hdrOffType:]))
n := binary.LittleEndian.Uint32(h[hdrOffSize:])
id := int64(binary.LittleEndian.Uint64(h[hdrOffID:]))
span.AddAttributes(
trace.StringAttribute("type", typ.String()),
trace.Int64Attribute("message-id", id))

if n < hdrSize || n > maxMsgSize {
return 0, 0, nil, fmt.Errorf("invalid message size %d", n)
}
@@ -298,7 +307,8 @@ func (brdg *bridge) recvLoop() error {
brdg.log.WithFields(logrus.Fields{
"payload": string(b),
"type": typ.String(),
"message-id": id}).Debug("bridge receive")
"message-id": id}).Trace("bridge receive")

switch typ & msgTypeMask {
case msgTypeResponse:
// Find the request associated with this response.
@@ -372,19 +382,27 @@ func (brdg *bridge) sendLoop() {
}

func (brdg *bridge) writeMessage(buf *bytes.Buffer, enc *json.Encoder, typ msgType, id int64, req interface{}) error {
var err error
_, span := oc.StartSpan(context.Background(), "bridge send", oc.WithClientSpanKind)
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes(
trace.StringAttribute("type", typ.String()),
trace.Int64Attribute("message-id", id))

// Prepare the buffer with the message.
var h [hdrSize]byte
binary.LittleEndian.PutUint32(h[hdrOffType:], uint32(typ))
binary.LittleEndian.PutUint64(h[hdrOffID:], uint64(id))
buf.Write(h[:])
err := enc.Encode(req)
err = enc.Encode(req)
if err != nil {
return fmt.Errorf("bridge encode: %w", err)
}
// Update the message header with the size.
binary.LittleEndian.PutUint32(buf.Bytes()[hdrOffSize:], uint32(buf.Len()))

if brdg.log.Logger.GetLevel() >= logrus.DebugLevel {
if brdg.log.Logger.GetLevel() > logrus.DebugLevel {
b := buf.Bytes()[hdrSize:]
switch typ {
// container environment vars are in rpCreate for linux; rpcExecuteProcess for windows
@@ -399,7 +417,7 @@ func (brdg *bridge) writeMessage(buf *bytes.Buffer, enc *json.Encoder, typ msgTy
brdg.log.WithFields(logrus.Fields{
"payload": string(b),
"type": typ.String(),
"message-id": id}).Debug("bridge send")
"message-id": id}).Trace("bridge send")
}

// Write the message.
7 changes: 4 additions & 3 deletions internal/guest/bridge/bridge.go
Original file line number Diff line number Diff line change
@@ -310,7 +310,7 @@ func (b *Bridge) ListenAndServe(bridgeIn io.ReadCloser, bridgeOut io.WriteCloser
trace.StringAttribute("cid", base.ContainerID))

entry := log.G(ctx)
if entry.Logger.GetLevel() >= logrus.DebugLevel {
if entry.Logger.GetLevel() > logrus.DebugLevel {
s := string(message)
switch header.Type {
case prot.ComputeSystemCreateV1:
@@ -320,7 +320,7 @@ func (b *Bridge) ListenAndServe(bridgeIn io.ReadCloser, bridgeOut io.WriteCloser
entry.WithError(err).Warning("could not scrub bridge payload")
}
}
entry.WithField("message", s).Debug("request read message")
entry.WithField("message", s).Trace("request read message")
}
requestChan <- &Request{
Context: ctx,
@@ -384,7 +384,8 @@ func (b *Bridge) ListenAndServe(bridgeIn io.ReadCloser, bridgeOut io.WriteCloser

s := trace.FromContext(resp.ctx)
if s != nil {
log.G(resp.ctx).WithField("message", string(responseBytes)).Debug("request write response")
log.G(resp.ctx).WithField("message", string(responseBytes)).Trace("request write response")
s.AddAttributes(trace.StringAttribute("response-message-type", resp.header.Type.String()))
s.End()
}
}