Skip to content

Commit

Permalink
Merged PR 5895108: update ADO to d36cc7c
Browse files Browse the repository at this point in the history
  • Loading branch information
ambarve committed Mar 31, 2022
2 parents ae28e33 + d36cc7c commit 6a5be6f
Show file tree
Hide file tree
Showing 376 changed files with 21,279 additions and 5,505 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.15.0'
go-version: '^1.17.0'

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
Expand All @@ -31,7 +31,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.15.0'
go-version: '^1.17.0'
- name: Validate main modules
shell: powershell
run: |
Expand All @@ -50,7 +50,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.15.0'
go-version: '^1.17.0'
- name: Validate test modules
shell: powershell
run: |
Expand All @@ -70,7 +70,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.15.0'
go-version: '^1.17.0'

- run: go test -gcflags=all=-d=checkptr -v ./... -tags admin
- run: go test -gcflags=all=-d=checkptr -v ./internal -tags admin
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.15.0'
go-version: '^1.17.0'

- run: go build ./cmd/containerd-shim-runhcs-v1
- run: go build ./cmd/runhcs
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
- name: Install go
uses: actions/setup-go@v2
with:
go-version: '^1.15.0'
go-version: '^1.17.0'

- name: Pull busybox image
run: docker pull busybox
Expand Down
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# Ignore vscode setting files
.vscode/
.idea/

# Test binary, build with `go test -c`
*.test
Expand All @@ -28,11 +29,9 @@ service/pkg/
.rootfs-done
bin/*
rootfs/*
rootfs-conv/*
*.o
/build/

deps/*
out/*

.idea/
.vscode/
out/*
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ run:

linters:
enable:
- gofmt
- stylecheck

linters-settings:
Expand Down
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ GCS_TOOLS=\

.PHONY: all always rootfs test

.DEFAULT_GOAL := all

all: out/initrd.img out/rootfs.tar.gz

clean:
Expand All @@ -32,14 +34,21 @@ clean:
test:
cd $(SRCROOT) && go test -v ./internal/guest/...

out/delta.tar.gz: bin/init bin/vsockexec bin/cmd/gcs bin/cmd/gcstools Makefile
rootfs: out/rootfs.vhd

out/rootfs.vhd: out/rootfs.tar.gz bin/cmd/tar2ext4
gzip -f -d ./out/rootfs.tar.gz
bin/cmd/tar2ext4 -vhd -i ./out/rootfs.tar -o $@

out/delta.tar.gz: bin/init bin/vsockexec bin/cmd/gcs bin/cmd/gcstools bin/cmd/hooks/wait-paths Makefile
@mkdir -p out
rm -rf rootfs
mkdir -p rootfs/bin/
cp bin/init rootfs/
cp bin/vsockexec rootfs/bin/
cp bin/cmd/gcs rootfs/bin/
cp bin/cmd/gcstools rootfs/bin/
cp bin/cmd/hooks/wait-paths rootfs/bin/
for tool in $(GCS_TOOLS); do ln -s gcstools rootfs/bin/$$tool; done
git -C $(SRCROOT) rev-parse HEAD > rootfs/gcs.commit && \
git -C $(SRCROOT) rev-parse --abbrev-ref HEAD > rootfs/gcs.branch
Expand All @@ -60,6 +69,8 @@ out/initrd.img: $(BASE) out/delta.tar.gz $(SRCROOT)/hack/catcpio.sh

-include deps/cmd/gcs.gomake
-include deps/cmd/gcstools.gomake
-include deps/cmd/hooks/wait-paths.gomake
-include deps/cmd/tar2ext4.gomake

# Implicit rule for includes that define Go targets.
%.gomake: $(SRCROOT)/Makefile
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio

## Dependencies

This project requires Golang 1.13 or newer to build.
This project requires Golang 1.17 or newer to build.

For system requirements to run this project, see the Microsoft docs on [Windows Container requirements](https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/system-requirements).

Expand Down
21 changes: 19 additions & 2 deletions cmd/containerd-shim-runhcs-v1/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/Microsoft/hcsshim/internal/hcs"
"github.com/Microsoft/hcsshim/internal/oc"
"github.com/Microsoft/hcsshim/internal/winapi"
"github.com/containerd/containerd/runtime/v2/task"
"github.com/gogo/protobuf/proto"
"github.com/pkg/errors"
Expand Down Expand Up @@ -49,8 +50,8 @@ The delete command will be executed in the container's bundle as its cwd.
SkipArgReorder: true,
Action: func(context *cli.Context) (err error) {
// We cant write anything to stdout for this cmd other than the
// task.DeleteResponse by protcol. We can write to stderr which will be
// warning logged in containerd.
// task.DeleteResponse by protocol. We can write to stderr which will be
// logged as a warning in containerd.

ctx, span := trace.StartSpan(gcontext.Background(), "delete")
defer span.End()
Expand Down Expand Up @@ -99,6 +100,22 @@ The delete command will be executed in the container's bundle as its cwd.
}
}

// For Host Process containers if a group name is passed as the user for the container the shim will create a
// temporary user for the container to run as and add it to the specified group. On container exit the account will
// be deleted, but if the shim crashed unexpectedly (panic, terminated etc.) then the account may still be around.
// The username will be the container ID so try and delete it here. The username character limit is 20, so we need to
// slice down the container ID a bit.
username := idFlag[:winapi.UserNameCharLimit]

// Always try and delete the user, if it doesn't exist we'll get a specific error code that we can use to
// not log any warnings.
if err := winapi.NetUserDel(
"",
username,
); err != nil && err != winapi.NERR_UserNotFound {
fmt.Fprintf(os.Stderr, "failed to delete user %q: %v", username, err)
}

if data, err := proto.Marshal(&task.DeleteResponse{
ExitedAt: time.Now(),
ExitStatus: 255,
Expand Down
19 changes: 10 additions & 9 deletions cmd/containerd-shim-runhcs-v1/exec_hcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ import (
"sync"
"time"

"github.com/Microsoft/hcsshim/internal/cmd"
"github.com/Microsoft/hcsshim/internal/cow"
"github.com/Microsoft/hcsshim/internal/guestrequest"
"github.com/Microsoft/hcsshim/internal/log"
"github.com/Microsoft/hcsshim/internal/signals"
"github.com/Microsoft/hcsshim/internal/uvm"
"github.com/Microsoft/hcsshim/osversion"
eventstypes "github.com/containerd/containerd/api/events"
containerd_v1_types "github.com/containerd/containerd/api/types/task"
"github.com/containerd/containerd/errdefs"
Expand All @@ -21,6 +14,14 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"

"github.com/Microsoft/hcsshim/internal/cmd"
"github.com/Microsoft/hcsshim/internal/cow"
"github.com/Microsoft/hcsshim/internal/log"
"github.com/Microsoft/hcsshim/internal/protocol/guestresource"
"github.com/Microsoft/hcsshim/internal/signals"
"github.com/Microsoft/hcsshim/internal/uvm"
"github.com/Microsoft/hcsshim/osversion"
)

// newHcsExec creates an exec to track the lifetime of `spec` in `c` which is
Expand Down Expand Up @@ -268,13 +269,13 @@ func (he *hcsExec) Kill(ctx context.Context, signal uint32) error {
var options interface{}
var err error
if he.isWCOW {
var opt *guestrequest.SignalProcessOptionsWCOW
var opt *guestresource.SignalProcessOptionsWCOW
opt, err = signals.ValidateWCOW(int(signal), supported)
if opt != nil {
options = opt
}
} else {
var opt *guestrequest.SignalProcessOptionsLCOW
var opt *guestresource.SignalProcessOptionsLCOW
opt, err = signals.ValidateLCOW(int(signal), supported)
if opt != nil {
options = opt
Expand Down
4 changes: 4 additions & 0 deletions cmd/containerd-shim-runhcs-v1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"strings"
"time"

"github.com/Microsoft/go-winio/pkg/etw"
"github.com/Microsoft/go-winio/pkg/etwlogrus"
Expand Down Expand Up @@ -41,6 +42,9 @@ var (
containerdBinaryFlag string

idFlag string

// gracefulShutdownTimeout is how long to wait for clean-up before just exiting
gracefulShutdownTimeout = 3 * time.Second
)

func etwCallback(sourceID guid.GUID, state etw.ProviderState, level etw.Level, matchAnyKeyword uint64, matchAllKeyword uint64, filterData uintptr) {
Expand Down
Loading

0 comments on commit 6a5be6f

Please sign in to comment.