Skip to content

Commit

Permalink
Merged PR 4370459: Update ADO to github commit d9474d2
Browse files Browse the repository at this point in the history
  • Loading branch information
katiewasnothere committed Apr 14, 2021
2 parents dfca4db + c1d3621 commit ed39d07
Show file tree
Hide file tree
Showing 2,223 changed files with 41,131 additions and 449,565 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,87 @@
name: CI
on:
- push
- pull_request

env:
GOPROXY: off
GOFLAGS: -mod=vendor

jobs:
lint:
runs-on: 'windows-2019'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.15.0'

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.38.0
args: --timeout=5m

test:
runs-on: 'windows-2019'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.15.0'

- run: go test -gcflags=all=-d=checkptr -v ./... -tags admin
- run: go test -gcflags=all=-d=checkptr -v ./internal -tags admin
working-directory: test
- run: go test -gcflags=all=-d=checkptr -c ./containerd-shim-runhcs-v1/ -tags functional
working-directory: test
- run: go test -gcflags=all=-d=checkptr -c ./cri-containerd/ -tags functional
working-directory: test
- run: go test -gcflags=all=-d=checkptr -c ./functional/ -tags functional
working-directory: test
- run: go test -gcflags=all=-d=checkptr -c ./runhcs/ -tags functional
working-directory: test
- run: go build -o sample-logging-driver.exe ./cri-containerd/helpers/log.go
working-directory: test

- uses: actions/upload-artifact@v2
with:
name: test_binaries
path: |
test/containerd-shim-runhcs-v1.test.exe
test/cri-containerd.test.exe
test/functional.test.exe
test/runhcs.test.exe
test/sample-logging-driver.exe
build:
runs-on: 'windows-2019'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.15.0'

- run: go build ./cmd/containerd-shim-runhcs-v1
- run: go build ./cmd/runhcs
- run: go build ./cmd/tar2ext4
- run: go build ./cmd/wclayer
- run: go build ./cmd/device-util
- run: go build ./cmd/ncproxy
- run: go build ./internal/tools/grantvmgroupaccess
- run: go build ./internal/tools/uvmboot
- run: go build ./internal/tools/zapdir

- uses: actions/upload-artifact@v2
with:
name: binaries
path: |
containerd-shim-runhcs-v1.exe
runhcs.exe
tar2ext4.exe
device-util.exe
wclayer.exe
grantvmgroupaccess.exe
uvmboot.exe
zapdir.exe
ncproxy.exe
17 changes: 0 additions & 17 deletions .gometalinter.json

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
# hcsshim

[![Build status](https://ci.appveyor.com/api/projects/status/nbcw28mnkqml0loa/branch/master?svg=true)](https://ci.appveyor.com/project/WindowsVirtualization/hcsshim/branch/master)
[![Build status](https://github.com/microsoft/hcsshim/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/microsoft/hcsshim/actions?query=branch%3Amaster)

This package contains the Golang interface for using the Windows [Host Compute Service](https://techcommunity.microsoft.com/t5/containers/introducing-the-host-compute-service-hcs/ba-p/382332) (HCS) to launch and manage [Windows Containers](https://docs.microsoft.com/en-us/virtualization/windowscontainers/about/). It also contains other helpers and functions for managing Windows Containers such as the Golang interface for the Host Network Service (HNS).

Expand Down
51 changes: 0 additions & 51 deletions appveyor.yml

This file was deleted.

4 changes: 0 additions & 4 deletions cmd/containerd-shim-runhcs-v1/events_test.go
Expand Up @@ -19,7 +19,3 @@ func (p *fakePublisher) publishEvent(ctx context.Context, topic string, event in
p.events = append(p.events, event)
return nil
}

func (p *fakePublisher) getEvents() []interface{} {
return p.events
}
52 changes: 18 additions & 34 deletions cmd/containerd-shim-runhcs-v1/exec_hcs.go
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"
"strings"
"sync"
"time"

Expand All @@ -22,18 +21,6 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
"golang.org/x/sys/windows"
)

const (
// processStopTimeout is the amount of time after signaling the process with
// a signal expected to kill the process that the exec must wait before
// forcibly terminating the process.
//
// For example, sending a SIGKILL is expected to kill a process. If the
// process does not stop within `processStopTimeout` we will forcibly
// terminate the process without a signal.
processStopTimeout = time.Second * 5
)

// newHcsExec creates an exec to track the lifetime of `spec` in `c` which is
Expand Down Expand Up @@ -199,7 +186,7 @@ func (he *hcsExec) startInternal(ctx context.Context, initializeContainer bool)
}
defer func() {
if err != nil {
he.c.Terminate(ctx)
_ = he.c.Terminate(ctx)
he.c.Close()
}
}()
Expand Down Expand Up @@ -233,22 +220,26 @@ func (he *hcsExec) startInternal(ctx context.Context, initializeContainer bool)
// Publish the task/exec start event. This MUST happen before waitForExit to
// avoid publishing the exit previous to the start.
if he.id != he.tid {
he.events.publishEvent(
if err := he.events.publishEvent(
ctx,
runtime.TaskExecStartedEventTopic,
&eventstypes.TaskExecStarted{
ContainerID: he.tid,
ExecID: he.id,
Pid: uint32(he.pid),
})
}); err != nil {
return err
}
} else {
he.events.publishEvent(
if err := he.events.publishEvent(
ctx,
runtime.TaskStartEventTopic,
&eventstypes.TaskStart{
ContainerID: he.tid,
Pid: uint32(he.pid),
})
}); err != nil {
return err
}
}

// wait in the background for the exit.
Expand All @@ -271,7 +262,7 @@ func (he *hcsExec) Kill(ctx context.Context, signal uint32) error {
return nil
case shimExecStateRunning:
supported := false
if osversion.Get().Build >= osversion.RS5 {
if osversion.Build() >= osversion.RS5 {
supported = he.host == nil || he.host.SignalProcessSupported()
}
var options interface{}
Expand Down Expand Up @@ -350,7 +341,7 @@ func (he *hcsExec) ForceExit(ctx context.Context, status int) {
he.exitFromCreatedL(ctx, status)
case shimExecStateRunning:
// Kill the process to unblock `he.waitForExit`
he.p.Process.Kill(ctx)
_, _ = he.p.Process.Kill(ctx)
}
}
}
Expand Down Expand Up @@ -451,14 +442,14 @@ func (he *hcsExec) waitForExit() {
he.sl.Unlock()

// Wait for all IO copies to complete and free the resources.
he.p.Wait()
_ = he.p.Wait()
he.io.Close(ctx)

// Only send the `runtime.TaskExitEventTopic` notification if this is a true
// exec. For the `init` exec this is handled in task teardown.
if he.tid != he.id {
// We had a valid process so send the exited notification.
he.events.publishEvent(
if err := he.events.publishEvent(
ctx,
runtime.TaskExitEventTopic,
&eventstypes.TaskExit{
Expand All @@ -467,7 +458,9 @@ func (he *hcsExec) waitForExit() {
Pid: uint32(he.pid),
ExitStatus: he.exitStatus,
ExitedAt: he.exitedAt,
})
}); err != nil {
log.G(ctx).WithError(err).Error("failed to publish TaskExitEvent")
}
}

// Free any waiters.
Expand All @@ -490,7 +483,7 @@ func (he *hcsExec) waitForContainerExit() {

cexit := make(chan struct{})
go func() {
he.c.Wait()
_ = he.c.Wait()
close(cexit)
}()
select {
Expand All @@ -503,20 +496,11 @@ func (he *hcsExec) waitForContainerExit() {
he.exitFromCreatedL(ctx, 1)
case shimExecStateRunning:
// Kill the process to unblock `he.waitForExit`.
he.p.Process.Kill(ctx)
_, _ = he.p.Process.Kill(ctx)
}
he.sl.Unlock()
case <-he.processDone:
// Process exited first. This is the normal case do nothing because
// `he.waitForExit` will release any waiters.
}
}

// escapeArgs makes a Windows-style escaped command line from a set of arguments
func escapeArgs(args []string) string {
escapedArgs := make([]string, len(args))
for i, a := range args {
escapedArgs[i] = windows.EscapeArg(a)
}
return strings.Join(escapedArgs, " ")
}
6 changes: 2 additions & 4 deletions cmd/containerd-shim-runhcs-v1/exec_wcow_podsandbox.go
Expand Up @@ -130,17 +130,15 @@ func (wpse *wcowPodSandboxExec) Start(ctx context.Context) error {
wpse.state = shimExecStateRunning
wpse.pid = 1 // Fake but init pid is always 1

// Publish the task start event. We mever have an exec for the WCOW
// Publish the task start event. We never have an exec for the WCOW
// PodSandbox.
wpse.events.publishEvent(
return wpse.events.publishEvent(
ctx,
runtime.TaskStartEventTopic,
&eventstypes.TaskStart{
ContainerID: wpse.tid,
Pid: uint32(wpse.pid),
})

return nil
}

func (wpse *wcowPodSandboxExec) Kill(ctx context.Context, signal uint32) error {
Expand Down
14 changes: 1 addition & 13 deletions cmd/containerd-shim-runhcs-v1/main.go
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"os"
"runtime"
"strings"

"github.com/Microsoft/go-winio/pkg/etw"
Expand Down Expand Up @@ -44,17 +43,6 @@ var (
idFlag string
)

func stack() []byte {
buf := make([]byte, 1024)
for {
n := runtime.Stack(buf, true) // true means all goroutines
if n < len(buf) {
return buf[:n]
}
buf = make([]byte, 2*len(buf))
}
}

func etwCallback(sourceID guid.GUID, state etw.ProviderState, level etw.Level, matchAnyKeyword uint64, matchAllKeyword uint64, filterData uintptr) {
if state == etw.ProviderStateCaptureState {
resp, err := svc.DiagStacks(context.Background(), &shimdiag.StacksRequest{})
Expand Down Expand Up @@ -83,7 +71,7 @@ func main() {
}
}

provider.WriteEvent(
_ = provider.WriteEvent(
"ShimLaunched",
nil,
etw.WithFields(
Expand Down

0 comments on commit ed39d07

Please sign in to comment.