Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

[19.03 backport] bump hcsshim to fix docker build failing on Windows 1903 #429

Merged
Merged
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
4 changes: 2 additions & 2 deletions daemon/daemon_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"strings"
"time"

containerd_cgroups "github.com/containerd/cgroups"
statsV1 "github.com/containerd/cgroups/stats/v1"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/blkiodev"
pblkiodev "github.com/docker/docker/api/types/blkiodev"
Expand Down Expand Up @@ -1347,7 +1347,7 @@ func (daemon *Daemon) conditionalUnmountOnCleanup(container *container.Container
return daemon.Unmount(container)
}

func copyBlkioEntry(entries []*containerd_cgroups.BlkIOEntry) []types.BlkioStatEntry {
func copyBlkioEntry(entries []*statsV1.BlkIOEntry) []types.BlkioStatEntry {
out := make([]types.BlkioStatEntry, len(entries))
for i, re := range entries {
out[i] = types.BlkioStatEntry{
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (d *Daemon) CheckActiveContainerCount(c *testing.T) (interface{}, string) {
if len(strings.TrimSpace(out)) == 0 {
return 0, ""
}
return len(strings.Split(strings.TrimSpace(out), "\n")), fmt.Sprintf("output: %q", string(out))
return len(strings.Split(strings.TrimSpace(out), "\n")), fmt.Sprintf("output: %q", out)
}

// WaitRun waits for a container to be running for 10s
Expand Down
4 changes: 2 additions & 2 deletions integration-cli/docker_api_attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (s *DockerSuite) TestGetContainersAttachWebsocket(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-dit", "busybox", "cat")

rwc, err := request.SockConn(time.Duration(10*time.Second), request.DaemonHost())
rwc, err := request.SockConn(10*time.Second, request.DaemonHost())
assert.NilError(c, err)

cleanedContainerID := strings.TrimSpace(out)
Expand Down Expand Up @@ -237,7 +237,7 @@ func sockRequestHijack(method, endpoint string, data io.Reader, ct string, daemo
// Deprecated: Use New instead of NewRequestClient
// Deprecated: use request.Do (or Get, Delete, Post) instead
func newRequestClient(method, endpoint string, data io.Reader, ct, daemon string, modifiers ...func(*http.Request)) (*http.Request, *httputil.ClientConn, error) {
c, err := request.SockConn(time.Duration(10*time.Second), daemon)
c, err := request.SockConn(10*time.Second, daemon)
if err != nil {
return nil, nil, fmt.Errorf("could not dial docker daemon: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions integration-cli/docker_api_containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func (s *DockerSuite) TestContainerAPIPause(c *testing.T) {
func (s *DockerSuite) TestContainerAPITop(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "top")
id := strings.TrimSpace(string(out))
id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id))

cli, err := client.NewClientWithOpts(client.FromEnv)
Expand All @@ -417,7 +417,7 @@ func (s *DockerSuite) TestContainerAPITop(c *testing.T) {
func (s *DockerSuite) TestContainerAPITopWindows(c *testing.T) {
testRequires(c, DaemonIsWindows)
out := runSleepingContainer(c, "-d")
id := strings.TrimSpace(string(out))
id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id))

cli, err := client.NewClientWithOpts(client.FromEnv)
Expand Down Expand Up @@ -614,7 +614,7 @@ func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode)
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
assert.NilError(c, err)

assert.Equal(c, containerJSON.HostConfig.NetworkMode, containertypes.NetworkMode(networkMode), "Mismatched NetworkMode")
assert.Equal(c, containerJSON.HostConfig.NetworkMode, networkMode, "Mismatched NetworkMode")
}

func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_api_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *testing.T) {
assert.Equal(c, res.StatusCode, http.StatusOK)

inspectOut := cli.InspectCmd(c, id, cli.Format(".Id")).Combined()
assert.Equal(c, strings.TrimSpace(string(inspectOut)), id, "load did not work properly")
assert.Equal(c, strings.TrimSpace(inspectOut), id, "load did not work properly")
}

func (s *DockerSuite) TestAPIImagesDelete(c *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions integration-cli/docker_api_swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ func (s *DockerSwarmSuite) TestAPISwarmForceNewCluster(c *testing.T) {

func simpleTestService(s *swarm.Service) {
ureplicas := uint64(1)
restartDelay := time.Duration(100 * time.Millisecond)
restartDelay := 100 * time.Millisecond

s.Spec = swarm.ServiceSpec{
TaskTemplate: swarm.TaskSpec{
Expand All @@ -618,7 +618,7 @@ func simpleTestService(s *swarm.Service) {

func serviceForUpdate(s *swarm.Service) {
ureplicas := uint64(1)
restartDelay := time.Duration(100 * time.Millisecond)
restartDelay := 100 * time.Millisecond

s.Spec = swarm.ServiceSpec{
TaskTemplate: swarm.TaskSpec{
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ CMD ["cat", "/foo"]`),
}).Assert(c, icmd.Success)

res := inspectField(c, name, "Config.Cmd")
assert.Equal(c, strings.TrimSpace(string(res)), `[cat /foo]`)
assert.Equal(c, strings.TrimSpace(res), `[cat /foo]`)
}

// FIXME(vdemeester) migrate to docker/cli tests (unit or e2e)
Expand Down
4 changes: 2 additions & 2 deletions integration-cli/docker_cli_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (s *DockerSuite) TestCreateArgs(c *testing.T) {
assert.Equal(c, len(containers), 1)

cont := containers[0]
assert.Equal(c, string(cont.Path), "command", fmt.Sprintf("Unexpected container path. Expected command, received: %s", cont.Path))
assert.Equal(c, cont.Path, "command", fmt.Sprintf("Unexpected container path. Expected command, received: %s", cont.Path))

b := false
expected := []string{"arg1", "arg2", "arg with space", "-c", "flags"}
Expand Down Expand Up @@ -333,7 +333,7 @@ func (s *DockerSuite) TestCreateWithInvalidLogOpts(c *testing.T) {
// #20972
func (s *DockerSuite) TestCreate64ByteHexID(c *testing.T) {
out := inspectField(c, "busybox", "Id")
imageID := strings.TrimPrefix(strings.TrimSpace(string(out)), "sha256:")
imageID := strings.TrimPrefix(strings.TrimSpace(out), "sha256:")

dockerCmd(c, "create", imageID)
}
Expand Down
6 changes: 3 additions & 3 deletions integration-cli/docker_cli_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1854,11 +1854,11 @@ func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *testing.T) {

out, err := s.d.Cmd("run", "--name", name, "busybox", "cat", "/proc/self/cgroup")
assert.NilError(c, err)
cgroupPaths := ParseCgroupPaths(string(out))
assert.Assert(c, len(cgroupPaths) != 0, "unexpected output - %q", string(out))
cgroupPaths := ParseCgroupPaths(out)
assert.Assert(c, len(cgroupPaths) != 0, "unexpected output - %q", out)
out, err = s.d.Cmd("inspect", "-f", "{{.Id}}", name)
assert.NilError(c, err)
id := strings.TrimSpace(string(out))
id := strings.TrimSpace(out)
expectedCgroup := path.Join(cgroupParent, id)
found := false
for _, path := range cgroupPaths {
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (s *DockerSuite) TestImagesFormat(c *testing.T) {
dockerCmd(c, "tag", "busybox", tag+":v2")

out, _ := dockerCmd(c, "images", "--format", "{{.Repository}}", tag)
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
lines := strings.Split(strings.TrimSpace(out), "\n")

expected := []string{"myimage", "myimage"}
var names []string
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_links_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (s *DockerSuite) TestLinksUpdateOnRestart(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
dockerCmd(c, "run", "-d", "--name", "one", "busybox", "top")
out, _ := dockerCmd(c, "run", "-d", "--name", "two", "--link", "one:onetwo", "--link", "one:one", "busybox", "top")
id := strings.TrimSpace(string(out))
id := strings.TrimSpace(out)

realIP := inspectField(c, "one", "NetworkSettings.Networks.bridge.IPAddress")
content := readContainerFileWithExec(c, id, "/etc/hosts")
Expand Down
8 changes: 4 additions & 4 deletions integration-cli/docker_cli_network_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,14 +812,14 @@ func (s *DockerDaemonSuite) TestDockerNetworkNoDiscoveryDefaultBridgeNetwork(c *
// verify first container's etc/hosts file has not changed after spawning the second named container
hostsPost, err := s.d.Cmd("exec", cid1, "cat", hostsFile)
assert.NilError(c, err)
assert.Equal(c, string(hosts), string(hostsPost), fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
assert.Equal(c, hosts, hostsPost, fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
// stop container 2 and verify first container's etc/hosts has not changed
_, err = s.d.Cmd("stop", cid2)
assert.NilError(c, err)

hostsPost, err = s.d.Cmd("exec", cid1, "cat", hostsFile)
assert.NilError(c, err)
assert.Equal(c, string(hosts), string(hostsPost), fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
assert.Equal(c, hosts, hostsPost, fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
// but discovery is on when connecting to non default bridge network
network := "anotherbridge"
out, err = s.d.Cmd("network", "create", network)
Expand All @@ -834,7 +834,7 @@ func (s *DockerDaemonSuite) TestDockerNetworkNoDiscoveryDefaultBridgeNetwork(c *

hostsPost, err = s.d.Cmd("exec", cid1, "cat", hostsFile)
assert.NilError(c, err)
assert.Equal(c, string(hosts), string(hostsPost), fmt.Sprintf("Unexpected %s change on second network connection", hostsFile))
assert.Equal(c, hosts, hostsPost, fmt.Sprintf("Unexpected %s change on second network connection", hostsFile))
}

func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *testing.T) {
Expand Down Expand Up @@ -1683,7 +1683,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *testing.T)
// Cleanup because these containers will not be shut down by daemon
out, err = s.d.Cmd("stop", newCon)
if err != nil {
t.Fatalf("err: %v %v", err, string(out))
t.Fatalf("err: %v %v", err, out)
}
_, err = s.d.Cmd("stop", strings.TrimSpace(id))
if err != nil {
Expand Down
46 changes: 23 additions & 23 deletions integration-cli/docker_cli_ps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,22 +478,22 @@ func (s *DockerSuite) TestPsRightTagName(c *testing.T) {

var id1 string
out := runSleepingContainer(c)
id1 = strings.TrimSpace(string(out))
id1 = strings.TrimSpace(out)

var id2 string
out = runSleepingContainerInImage(c, tag)
id2 = strings.TrimSpace(string(out))
id2 = strings.TrimSpace(out)

var imageID string
out = inspectField(c, "busybox", "Id")
imageID = strings.TrimSpace(string(out))
imageID = strings.TrimSpace(out)

var id3 string
out = runSleepingContainerInImage(c, imageID)
id3 = strings.TrimSpace(string(out))
id3 = strings.TrimSpace(out)

out, _ = dockerCmd(c, "ps", "--no-trunc")
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
lines := strings.Split(strings.TrimSpace(out), "\n")
lines = RemoveLinesForExistingElements(lines, existingContainers)
// skip header
lines = lines[1:]
Expand Down Expand Up @@ -562,7 +562,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *testing.T) {
result = icmd.RunCommand(dockerBinary, "ps", "--no-trunc")
result.Assert(c, icmd.Success)

lines := strings.Split(strings.TrimSpace(string(result.Combined())), "\n")
lines := strings.Split(strings.TrimSpace(result.Combined()), "\n")
lines = RemoveLinesForExistingElements(lines, existingContainers)
// skip header
lines = lines[1:]
Expand All @@ -579,7 +579,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *testing.T) {
result = icmd.RunCommand(dockerBinary, "ps", "--no-trunc")
result.Assert(c, icmd.Success)

lines = strings.Split(strings.TrimSpace(string(result.Combined())), "\n")
lines = strings.Split(strings.TrimSpace(result.Combined()), "\n")
lines = RemoveLinesForExistingElements(lines, existingContainers)
// skip header
lines = lines[1:]
Expand All @@ -597,15 +597,15 @@ func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) {
dockerCmd(c, "run", "--name=foo", "-d", "-p", "5000:5000", "busybox", "top")
assert.Assert(c, waitRun("foo") == nil)
out, _ := dockerCmd(c, "ps")
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
lines := strings.Split(strings.TrimSpace(out), "\n")
expected := "0.0.0.0:5000->5000/tcp"
fields := strings.Fields(lines[1])
assert.Equal(c, fields[len(fields)-2], expected, fmt.Sprintf("Expected: %v, got: %v", expected, fields[len(fields)-2]))

dockerCmd(c, "kill", "foo")
dockerCmd(c, "wait", "foo")
out, _ = dockerCmd(c, "ps", "-l")
lines = strings.Split(strings.TrimSpace(string(out)), "\n")
lines = strings.Split(strings.TrimSpace(out), "\n")
fields = strings.Fields(lines[1])
assert.Assert(c, fields[len(fields)-2] != expected, "Should not got %v", expected)
}
Expand Down Expand Up @@ -638,7 +638,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {

out, _ := dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}")

lines := strings.Split(strings.TrimSpace(string(out)), "\n")
lines := strings.Split(strings.TrimSpace(out), "\n")
lines = RemoveLinesForExistingElements(lines, existingContainers)
assert.Equal(c, len(lines), 3)

Expand All @@ -658,7 +658,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
// filter by volume name
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume=ps-volume-test")

lines = strings.Split(strings.TrimSpace(string(out)), "\n")
lines = strings.Split(strings.TrimSpace(out), "\n")
lines = RemoveLinesForExistingElements(lines, existingContainers)
assert.Equal(c, len(lines), 1)

Expand All @@ -667,12 +667,12 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {

// empty results filtering by unknown volume
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume=this-volume-should-not-exist")
assert.Equal(c, len(strings.TrimSpace(string(out))), 0)
assert.Equal(c, len(strings.TrimSpace(out)), 0)

// filter by mount destination
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+mp)

lines = strings.Split(strings.TrimSpace(string(out)), "\n")
lines = strings.Split(strings.TrimSpace(out), "\n")
lines = RemoveLinesForExistingElements(lines, existingContainers)
assert.Equal(c, len(lines), 2)

Expand All @@ -684,7 +684,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
// filter by bind mount source
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountSource)

lines = strings.Split(strings.TrimSpace(string(out)), "\n")
lines = strings.Split(strings.TrimSpace(out), "\n")
lines = RemoveLinesForExistingElements(lines, existingContainers)
assert.Equal(c, len(lines), 1)

Expand All @@ -696,7 +696,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
// filter by bind mount destination
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountDestination)

lines = strings.Split(strings.TrimSpace(string(out)), "\n")
lines = strings.Split(strings.TrimSpace(out), "\n")
lines = RemoveLinesForExistingElements(lines, existingContainers)
assert.Equal(c, len(lines), 1)

Expand All @@ -707,7 +707,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {

// empty results filtering by unknown mount point
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+prefix+slash+"this-path-was-never-mounted")
assert.Equal(c, len(strings.TrimSpace(string(out))), 0)
assert.Equal(c, len(strings.TrimSpace(out)), 0)
}

func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
Expand All @@ -723,7 +723,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {

// Filter docker ps on non existing network
out, _ := dockerCmd(c, "ps", "--filter", "network=doesnotexist")
containerOut := strings.TrimSpace(string(out))
containerOut := strings.TrimSpace(out)
lines := strings.Split(containerOut, "\n")

// skip header
Expand All @@ -734,7 +734,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {

// Filter docker ps on network bridge
out, _ = dockerCmd(c, "ps", "--filter", "network=bridge")
containerOut = strings.TrimSpace(string(out))
containerOut = strings.TrimSpace(out)

lines = strings.Split(containerOut, "\n")

Expand All @@ -748,7 +748,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
assert.Assert(c, strings.Contains(containerOut, "onbridgenetwork"), "Missing the container on network\n")
// Filter docker ps on networks bridge and none
out, _ = dockerCmd(c, "ps", "--filter", "network=bridge", "--filter", "network=none")
containerOut = strings.TrimSpace(string(out))
containerOut = strings.TrimSpace(out)

lines = strings.Split(containerOut, "\n")

Expand All @@ -765,15 +765,15 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {

// Filter by network ID
out, _ = dockerCmd(c, "ps", "--filter", "network="+nwID)
containerOut = strings.TrimSpace(string(out))
containerOut = strings.TrimSpace(out)

assert.Assert(c, is.Contains(containerOut, "onbridgenetwork"))

// Filter by partial network ID
partialnwID := string(nwID[0:4])
partialnwID := nwID[0:4]

out, _ = dockerCmd(c, "ps", "--filter", "network="+partialnwID)
containerOut = strings.TrimSpace(string(out))
containerOut = strings.TrimSpace(out)

lines = strings.Split(containerOut, "\n")

Expand Down Expand Up @@ -849,7 +849,7 @@ func (s *DockerSuite) TestPsNotShowLinknamesOfDeletedContainer(c *testing.T) {
dockerCmd(c, "create", "--name=bbb", "--link=aaa", "busybox", "top")

out, _ := dockerCmd(c, "ps", "--no-trunc", "-a", "--format", "{{.Names}}")
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
lines := strings.Split(strings.TrimSpace(out), "\n")
lines = RemoveLinesForExistingElements(lines, existingContainers)
expected := []string{"bbb", "aaa,bbb/aaa"}
var names []string
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_pull_local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (s *DockerRegistrySuite) TestPullManifestList(c *testing.T) {
err = os.MkdirAll(blobDir, 0755)
assert.NilError(c, err, "error creating blob dir")
blobPath := filepath.Join(blobDir, "data")
err = ioutil.WriteFile(blobPath, []byte(manifestListJSON), 0644)
err = ioutil.WriteFile(blobPath, manifestListJSON, 0644)
assert.NilError(c, err, "error writing manifest list")

// Add to revision store
Expand Down
6 changes: 3 additions & 3 deletions integration-cli/docker_cli_registry_user_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ func unescapeBackslashSemicolonParens(s string) string {
ret := re.ReplaceAll([]byte(s), []byte(";"))

re = regexp.MustCompile(`\\\(`)
ret = re.ReplaceAll([]byte(ret), []byte("("))
ret = re.ReplaceAll(ret, []byte("("))

re = regexp.MustCompile(`\\\)`)
ret = re.ReplaceAll([]byte(ret), []byte(")"))
ret = re.ReplaceAll(ret, []byte(")"))

re = regexp.MustCompile(`\\\\`)
ret = re.ReplaceAll([]byte(ret), []byte(`\`))
ret = re.ReplaceAll(ret, []byte(`\`))

return string(ret)
}
Expand Down
Loading