Skip to content

Commit 1285c6d

Browse files
committed
Windows CI: Add support for testing with containerd
Signed-off-by: Olli Janatuinen <[email protected]>
1 parent ba2adee commit 1285c6d

13 files changed

Lines changed: 81 additions & 21 deletions

File tree

Dockerfile.windows

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,15 @@ FROM microsoft/windowsservercore
166166
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
167167

168168
ARG GO_VERSION=1.16.7
169+
ARG CONTAINERD_VERSION=1.5.5
169170
ARG GOTESTSUM_COMMIT=v0.5.3
170171

171172
# Environment variable notes:
172173
# - GO_VERSION must be consistent with 'Dockerfile' used by Linux.
174+
# - CONTAINERD_VERSION must be consistent with 'hack/dockerfile/install/containerd.installer' used by Linux.
173175
# - FROM_DOCKERFILE is used for detection of building within a container.
174176
ENV GO_VERSION=${GO_VERSION} `
177+
CONTAINERD_VERSION=${CONTAINERD_VERSION} `
175178
GIT_VERSION=2.11.1 `
176179
GOPATH=C:\gopath `
177180
GO111MODULE=off `
@@ -211,7 +214,7 @@ RUN `
211214
} `
212215
} `
213216
`
214-
setx /M PATH $('C:\git\cmd;C:\git\usr\bin;'+$Env:PATH+';C:\gcc\bin;C:\go\bin'); `
217+
setx /M PATH $('C:\git\cmd;C:\git\usr\bin;'+$Env:PATH+';C:\gcc\bin;C:\go\bin;C:\containerd\bin'); `
215218
`
216219
Write-Host INFO: Downloading git...; `
217220
$location='https://www.nuget.org/api/v2/package/GitForWindows/'+$Env:GIT_VERSION; `
@@ -252,6 +255,16 @@ RUN `
252255
Remove-Item C:\binutils.zip; `
253256
Remove-Item C:\gitsetup.zip; `
254257
`
258+
Write-Host INFO: Downloading containerd; `
259+
Install-Package -Force 7Zip4PowerShell; `
260+
$location='https://github.com/containerd/containerd/releases/download/v'+$Env:CONTAINERD_VERSION+'/containerd-'+$Env:CONTAINERD_VERSION+'-windows-amd64.tar.gz'; `
261+
Download-File $location C:\containerd.tar.gz; `
262+
New-Item -Path C:\containerd -ItemType Directory; `
263+
Expand-7Zip C:\containerd.tar.gz C:\; `
264+
Expand-7Zip C:\containerd.tar C:\containerd; `
265+
Remove-Item C:\containerd.tar.gz; `
266+
Remove-Item C:\containerd.tar; `
267+
`
255268
# Ensure all directories exist that we will require below....
256269
$srcDir = """$Env:GOPATH`\src\github.com\docker\docker\bundles"""; `
257270
Write-Host INFO: Ensuring existence of directory $srcDir...; `

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ pipeline {
13081308
Write-Host -ForegroundColor Green "Creating ${bundleName}-bundles.zip"
13091309
13101310
# archiveArtifacts does not support env-vars to , so save the artifacts in a fixed location
1311-
Compress-Archive -Path "bundles/CIDUT.out", "bundles/CIDUT.err", "bundles/junit-report-*.xml" -CompressionLevel Optimal -DestinationPath "${bundleName}-bundles.zip"
1311+
Compress-Archive -Path "bundles/CIDUT.out", "bundles/CIDUT.err", "bundles/containerd.out", "bundles/containerd.err", "bundles/junit-report-*.xml" -CompressionLevel Optimal -DestinationPath "${bundleName}-bundles.zip"
13121312
'''
13131313

13141314
archiveArtifacts artifacts: '*-bundles.zip', allowEmptyArchive: true

cmd/dockerd/daemon_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ func newCgroupParent(config *config.Config) string {
9494
}
9595

9696
func (cli *DaemonCli) initContainerD(_ context.Context) (func(time.Duration) error, error) {
97-
system.InitContainerdRuntime(cli.Config.Experimental, cli.Config.ContainerdAddr)
97+
system.InitContainerdRuntime(cli.Config.ContainerdAddr)
9898
return nil, nil
9999
}

daemon/start_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88

99
func (daemon *Daemon) getLibcontainerdCreateOptions(_ *container.Container) (string, interface{}, error) {
1010
if system.ContainerdRuntimeSupported() {
11-
// Set the runtime options to debug regardless of current logging level.
12-
return "", &options.Options{Debug: true}, nil
11+
opts := &options.Options{}
12+
return "io.containerd.runhcs.v1", opts, nil
1313
}
1414
return "", nil, nil
1515
}

hack/ci/windows.ps1

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ Function Nuke-Everything {
179179
}
180180
}
181181

182+
# Kill any spurious containerd.
183+
$pids=$(get-process | where-object {$_.ProcessName -like 'containerd'}).id
184+
foreach ($p in $pids) {
185+
Write-Host "INFO: Killing containerd with PID $p"
186+
Stop-Process -Id $p -Force -ErrorAction SilentlyContinue
187+
}
188+
182189
Stop-Process -name "cc1" -Force -ErrorAction SilentlyContinue 2>&1 | Out-Null
183190
Stop-Process -name "link" -Force -ErrorAction SilentlyContinue 2>&1 | Out-Null
184191
Stop-Process -name "compile" -Force -ErrorAction SilentlyContinue 2>&1 | Out-Null
@@ -521,6 +528,15 @@ Try {
521528
Throw "ERROR: gotestsum.exe not found...." `
522529
}
523530

531+
docker cp "$COMMITHASH`:c`:\containerd\bin\containerd.exe" $env:TEMP\binary\
532+
if (-not (Test-Path "$env:TEMP\binary\containerd.exe")) {
533+
Throw "ERROR: containerd.exe not found...." `
534+
}
535+
docker cp "$COMMITHASH`:c`:\containerd\bin\containerd-shim-runhcs-v1.exe" $env:TEMP\binary\
536+
if (-not (Test-Path "$env:TEMP\binary\containerd-shim-runhcs-v1.exe")) {
537+
Throw "ERROR: containerd-shim-runhcs-v1.exe not found...." `
538+
}
539+
524540
$ErrorActionPreference = "Stop"
525541

526542
# Copy the built dockerd.exe to dockerd-$COMMITHASH.exe so that easily spotted in task manager.
@@ -594,6 +610,12 @@ Try {
594610
$dutArgs += "-D"
595611
}
596612

613+
# Arguments: Are we starting the daemon under test in containerd mode?
614+
if (-not ("$env:DOCKER_WINDOWS_CONTAINERD_RUNTIME" -eq "")) {
615+
Write-Host -ForegroundColor Green "INFO: Running the daemon under test in containerd mode"
616+
$dutArgs += "--containerd \\.\pipe\containerd-containerd"
617+
}
618+
597619
# Arguments: Are we starting the daemon under test with Hyper-V containers as the default isolation?
598620
if (-not ("$env:DOCKER_DUT_HYPERV" -eq "")) {
599621
Write-Host -ForegroundColor Green "INFO: Running the daemon under test with Hyper-V containers as the default"
@@ -616,6 +638,15 @@ Try {
616638
Write-Host -ForegroundColor Green "INFO: Args: $dutArgs"
617639
New-Item -ItemType Directory $env:TEMP\daemon -ErrorAction SilentlyContinue | Out-Null
618640

641+
# Start containerd first
642+
if (-not ("$env:DOCKER_WINDOWS_CONTAINERD_RUNTIME" -eq "")) {
643+
Start-Process "$env:TEMP\binary\containerd.exe" `
644+
-ArgumentList "--log-level debug" `
645+
-RedirectStandardOutput "$env:TEMP\containerd.out" `
646+
-RedirectStandardError "$env:TEMP\containerd.err"
647+
Write-Host -ForegroundColor Green "INFO: Containerd started successfully."
648+
}
649+
619650
# Cannot fathom why, but always writes to stderr....
620651
Start-Process "$env:TEMP\binary\dockerd-$COMMITHASH" `
621652
-ArgumentList $dutArgs `
@@ -943,6 +974,15 @@ Finally {
943974
Copy-Item "$env:TEMP\dut.out" "bundles\CIDUT.out" -Force -ErrorAction SilentlyContinue
944975
Write-Host -ForegroundColor Green "INFO: Saving daemon under test log ($env:TEMP\dut.err) to bundles\CIDUT.err"
945976
Copy-Item "$env:TEMP\dut.err" "bundles\CIDUT.err" -Force -ErrorAction SilentlyContinue
977+
978+
Write-Host -ForegroundColor Green "INFO: Saving containerd logs to bundles"
979+
if (Test-Path -Path "$env:TEMP\containerd.out") {
980+
Copy-Item "$env:TEMP\containerd.out" "bundles\containerd.out" -Force -ErrorAction SilentlyContinue
981+
Copy-Item "$env:TEMP\containerd.err" "bundles\containerd.err" -Force -ErrorAction SilentlyContinue
982+
} else {
983+
"" | Out-File -FilePath "bundles\containerd.out"
984+
"" | Out-File -FilePath "bundles\containerd.err"
985+
}
946986
}
947987

948988
Set-Location "$env:SOURCES_DRIVE\$env:SOURCES_SUBDIR" -ErrorAction SilentlyContinue

integration-cli/docker_api_stats_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ import (
1818
"github.com/docker/docker/client"
1919
"github.com/docker/docker/testutil/request"
2020
"gotest.tools/v3/assert"
21+
"gotest.tools/v3/skip"
2122
)
2223

2324
var expectedNetworkInterfaceStats = strings.Split("rx_bytes rx_dropped rx_errors rx_packets tx_bytes tx_dropped tx_errors tx_packets", " ")
2425

2526
func (s *DockerSuite) TestAPIStatsNoStreamGetCpu(c *testing.T) {
27+
skip.If(c, RuntimeIsWindowsContainerd(), "FIXME: Broken on Windows + containerd combination")
2628
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "while true;usleep 100; do echo 'Hello'; done")
2729

2830
id := strings.TrimSpace(out)
@@ -98,6 +100,7 @@ func (s *DockerSuite) TestAPIStatsStoppedContainerInGoroutines(c *testing.T) {
98100
}
99101

100102
func (s *DockerSuite) TestAPIStatsNetworkStats(c *testing.T) {
103+
skip.If(c, RuntimeIsWindowsContainerd(), "FIXME: Broken on Windows + containerd combination")
101104
testRequires(c, testEnv.IsLocalDaemon)
102105

103106
out := runSleepingContainer(c)

integration-cli/docker_cli_commit_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import (
77
"github.com/docker/docker/api/types/versions"
88
"github.com/docker/docker/integration-cli/cli"
99
"gotest.tools/v3/assert"
10+
"gotest.tools/v3/skip"
1011
)
1112

1213
func (s *DockerSuite) TestCommitAfterContainerIsDone(c *testing.T) {
14+
skip.If(c, RuntimeIsWindowsContainerd(), "FIXME: Broken on Windows + containerd combination")
1315
out := cli.DockerCmd(c, "run", "-i", "-a", "stdin", "busybox", "echo", "foo").Combined()
1416

1517
cleanedContainerID := strings.TrimSpace(out)

integration-cli/docker_cli_ps_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ func (s *DockerSuite) TestPsListContainersFilterStatus(c *testing.T) {
227227
}
228228

229229
func (s *DockerSuite) TestPsListContainersFilterHealth(c *testing.T) {
230+
skip.If(c, RuntimeIsWindowsContainerd(), "FIXME. Hang on Windows + containerd combination")
230231
existingContainers := ExistingContainerIDs(c)
231232
// Test legacy no health check
232233
out := runSleepingContainer(c, "--name=none_legacy")

integration-cli/docker_cli_run_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"github.com/moby/sys/mountinfo"
3838
"gotest.tools/v3/assert"
3939
"gotest.tools/v3/icmd"
40+
"gotest.tools/v3/skip"
4041
)
4142

4243
// "test123" should be printed by docker run
@@ -1984,6 +1985,7 @@ func (s *DockerSuite) TestRunCidFileCheckIDLength(c *testing.T) {
19841985
}
19851986

19861987
func (s *DockerSuite) TestRunSetMacAddress(c *testing.T) {
1988+
skip.If(c, RuntimeIsWindowsContainerd(), "FIXME: Broken on Windows + containerd combination")
19871989
mac := "12:34:56:78:9a:bc"
19881990
var out string
19891991
if testEnv.OSType == "windows" {

integration-cli/requirements_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ func RegistryHosting() bool {
181181
return err == nil
182182
}
183183

184+
func RuntimeIsWindowsContainerd() bool {
185+
return os.Getenv("DOCKER_WINDOWS_CONTAINERD_RUNTIME") == "1"
186+
}
187+
184188
func SwarmInactive() bool {
185189
return testEnv.DaemonInfo.Swarm.LocalNodeState == swarm.LocalNodeStateInactive
186190
}

0 commit comments

Comments
 (0)