From bdaf849c0f3ea87a204f409a3539d3b7da87cfd9 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Tue, 22 Dec 2020 13:30:42 +0000 Subject: [PATCH] test images: Remove busybox-helper image We cannot have any RUN commands in the Windows stage when using docker buildx, which is why we were using the busybox-helper image. The purpose of the image was to contain a few things that we would obtain by running a few commands: - symlinks for the busybox binary - run vcredist_x64.exe which would also give us the vcruntime140.dll which is necessary for dig or httpd. There are alternatives to the commands above that can be achieved in a Linux stage as well: - we can create the symlinks in a Linux stage with ln -s. Copying them over to Windows will allow them to work just as well as if they were being copied over from a Windows image. The 'Files\' prefix issue to the symlink target still persists. - we can download the vcruntime140.dll directly, allowing us to skip the vcredist_x64.exe installation. --- build/dependencies.yaml | 2 +- test/images/agnhost/Dockerfile_windows | 2 - test/images/agnhost/VERSION | 2 +- test/images/agnhost/agnhost.go | 2 +- test/images/busybox/Dockerfile_windows | 54 ++++++++++++++---- .../images/jessie-dnsutils/Dockerfile_windows | 2 - test/images/jessie-dnsutils/VERSION | 2 +- test/images/windows/Makefile | 2 +- test/images/windows/busybox-helper/Dockerfile | 56 ------------------- test/images/windows/busybox-helper/VERSION | 1 - 10 files changed, 48 insertions(+), 77 deletions(-) delete mode 100644 test/images/windows/busybox-helper/Dockerfile delete mode 100644 test/images/windows/busybox-helper/VERSION diff --git a/build/dependencies.yaml b/build/dependencies.yaml index be5987c6106..05fe3dfdac6 100644 --- a/build/dependencies.yaml +++ b/build/dependencies.yaml @@ -1,7 +1,7 @@ dependencies: # agnhost: bump this one first - name: "agnhost" - version: "2.26" + version: "2.27" refPaths: - path: test/images/agnhost/VERSION match: \d.\d diff --git a/test/images/agnhost/Dockerfile_windows b/test/images/agnhost/Dockerfile_windows index 94b8ae45cb8..5fb6e6d914d 100644 --- a/test/images/agnhost/Dockerfile_windows +++ b/test/images/agnhost/Dockerfile_windows @@ -29,7 +29,6 @@ RUN tar -xzvf /coredns.tgz &&\ mv iperf-2.0.9-win64 iperf &&\ mkdir /uploads -FROM e2eteam/busybox-helper:1.29.0 as busybox-helper FROM --platform=linux/amd64 $REGISTRY/windows-servercore-cache:1.0-linux-amd64-$OS_VERSION as servercore-helper FROM $BASEIMAGE @@ -42,7 +41,6 @@ FROM $BASEIMAGE # - curl, nc: used by a lot of e2e tests (inherited from BASEIMAGE) # from iperf image # install necessary packages: iperf -COPY --from=busybox-helper /dig /dig COPY --from=servercore-helper /Windows/System32/netapi32.dll /Windows/System32/netapi32.dll COPY --from=prep /coredns.exe /coredns.exe COPY --from=prep /iperf /iperf diff --git a/test/images/agnhost/VERSION b/test/images/agnhost/VERSION index e90e35faf56..7dba3a2df98 100644 --- a/test/images/agnhost/VERSION +++ b/test/images/agnhost/VERSION @@ -1 +1 @@ -2.26 +2.27 diff --git a/test/images/agnhost/agnhost.go b/test/images/agnhost/agnhost.go index 8bb19733b79..2185fe41d3f 100644 --- a/test/images/agnhost/agnhost.go +++ b/test/images/agnhost/agnhost.go @@ -51,7 +51,7 @@ import ( func main() { rootCmd := &cobra.Command{ Use: "app", - Version: "2.26", + Version: "2.27", } rootCmd.AddCommand(auditproxy.CmdAuditProxy) diff --git a/test/images/busybox/Dockerfile_windows b/test/images/busybox/Dockerfile_windows index 5b25e06c0e9..93421b5f520 100644 --- a/test/images/busybox/Dockerfile_windows +++ b/test/images/busybox/Dockerfile_windows @@ -18,21 +18,53 @@ ARG REGISTRY # We're using a Linux image to unpack the archive, then we're copying it over to Windows. FROM --platform=linux/amd64 alpine:3.6 as prep -RUN mkdir /tmp-dir +ENV CURL_VERSION=7.57.0 + +# Available busybox functions retrieved by running busybox.exe --list +ENV BUSYBOX_EXES="[ [[ ar arch ash awk base64 basename bash bunzip2 bzcat bzip2 cal cat chmod cksum clear cmp comm cp cpio cut date dc dd df diff dirname dos2unix dpkg-deb du echo ed egrep env expand expr factor false fgrep find fold fsync ftpget ftpput getopt grep groups gunzip gzip hd head hexdump id ipcalc kill killall less link ln logname ls lzcat lzma lzop lzopcat man md5sum mkdir mktemp mv nl od paste patch pgrep pidof pipe_progress pkill printenv printf ps pwd rev rm rmdir rpm rpm2cpio sed seq sh sha1sum sha256sum sha3sum sha512sum shred shuf sleep sort split ssl_client stat strings sum tac tail tar tee test timeout touch tr true truncate ttysize uname uncompress unexpand uniq unix2dos unlink unlzma unlzop unxz unzip usleep uudecode uuencode vi watch wc wget which whoami whois xargs xxd xz xzcat yes zcat" + +ADD https://github.com/kubernetes-sigs/windows-testing/raw/master/images/busybox/busybox.exe /busybox-dir/busybox.exe +ADD https://skanthak.homepage.t-online.de/download/curl-$CURL_VERSION.cab /curl.cab +ADD https://eternallybored.org/misc/netcat/netcat-win32-1.12.zip /netcat.zip +ADD https://downloads.isc.org/isc/bind9/9.14.10/BIND9.14.10.x64.zip /bind.zip + +# We need vcruntime140.dll in order to run dig.exe, or httpd.exe +ADD https://wikidll.com/download/24194/vcruntime140.zip /vcruntime140.zip + +RUN apk --update add cabextract + +# NOTE(claudiub): We're creating symlinks for each of the busybox binaries and after that we're copying +# them over to Windows. Unfortunately, docker buildx has some issues copying over Windows symlinks. +# "Files/" is always prepended to the symlink target. The symlinks themselves are relative paths, +# so, in order to make use of them, we can simply add a busybox binary to Files\busybox.exe. +RUN cd /busybox-dir/ && \ + for busybox_binary in $BUSYBOX_EXES; do ln -s busybox.exe $busybox_binary.exe; done && \ + mkdir Files && \ + cp busybox.exe Files/busybox.exe + +RUN mkdir /curl-full /curl-dir && \ + cabextract -d /curl-full/ /curl.cab && \ + cp -r /curl-full/AMD64 /curl-full/CURL.LIC /curl-dir/ && \ + mkdir /netcat-dir && \ + unzip /netcat.zip -d /netcat-dir/ && \ + mkdir /bind-dir /dig-dir &&\ + unzip /bind.zip -d /bind-dir/ && \ + cp /bind-dir/dig.exe /bind-dir/nslookup.exe /bind-dir/*.dll /dig-dir/ && \ + unzip /vcruntime140.zip -d / && \ + mkdir /tmp-dir + + +# Windows Stage -FROM e2eteam/busybox-helper:1.29.0 as busybox-helper FROM e2eteam/powershell-helper:6.2.7 as ps-helper FROM $BASEIMAGE COPY --from=prep /tmp-dir /tmp -COPY --from=busybox-helper /bin /bin - -# NOTE(claudiub): Unfortunately, docker buildx has some issues copying over Windows symlinks. -# "Files/" is always prepended to the symlink target. The symlinks themselves are relative paths, -# so, in order to make use of them, we can simply add a busybox binary to C:\bin\Files\busybox.exe. -COPY --from=busybox-helper /bin/busybox.exe /bin/Files/ -COPY --from=busybox-helper /curl /curl -COPY --from=busybox-helper /netcat/nc64.exe /bin/nc.exe +COPY --from=prep /busybox-dir /bin +COPY --from=prep /curl-dir /curl +COPY --from=prep /netcat-dir/nc64.exe /bin/nc.exe +COPY --from=prep /dig-dir /dig +COPY --from=prep /vcruntime140.dll /Windows/System32/ # include powershell and its Module analysis cache. COPY --from=ps-helper ["/PowerShell", "/Program Files/PowerShell"] @@ -46,7 +78,7 @@ ADD hostname /bin/hostname.exe USER ContainerAdministrator # NOTE(claudiub): docker buildx sets the PATH env variable to a Linux-like PATH, which is not desirable. -ENV PATH="C:\bin;C:\curl;C:\Windows\System32;C:\Windows;C:\Program Files\PowerShell;" \ +ENV PATH="C:\dig\;C:\bin;C:\curl;C:\Windows\System32;C:\Windows;C:\Program Files\PowerShell;" \ ProgramFiles="C:\Program Files" \ # set a fixed location for the Module analysis cache LOCALAPPDATA="C:\Users\ContainerAdministrator\AppData\Local" \ diff --git a/test/images/jessie-dnsutils/Dockerfile_windows b/test/images/jessie-dnsutils/Dockerfile_windows index 3b41a1243a0..445852ad899 100644 --- a/test/images/jessie-dnsutils/Dockerfile_windows +++ b/test/images/jessie-dnsutils/Dockerfile_windows @@ -20,11 +20,9 @@ FROM --platform=linux/amd64 alpine:3.6 as prep ADD https://github.com/coredns/coredns/releases/download/v1.5.0/coredns_1.5.0_windows_amd64.tgz /coredns.tgz RUN tar -xzvf /coredns.tgz -FROM e2eteam/busybox-helper:1.29.0 as busybox-helper FROM $BASEIMAGE COPY --from=prep /coredns.exe /coredns.exe -COPY --from=busybox-helper /dig /dig # NOTE(claudiub): docker buildx sets the PATH env variable to a Linux-like PATH, which is not desirable. ENV PATH="C:\dig\;C:\bin;C:\curl;C:\Windows\System32;C:\Windows;C:\Program Files\PowerShell;" diff --git a/test/images/jessie-dnsutils/VERSION b/test/images/jessie-dnsutils/VERSION index 7e32cd56983..c068b2447cc 100644 --- a/test/images/jessie-dnsutils/VERSION +++ b/test/images/jessie-dnsutils/VERSION @@ -1 +1 @@ -1.3 +1.4 diff --git a/test/images/windows/Makefile b/test/images/windows/Makefile index 368db163197..40cbba03d7a 100644 --- a/test/images/windows/Makefile +++ b/test/images/windows/Makefile @@ -17,7 +17,7 @@ REMOTE_DOCKER_URL ?= DOCKER_CERT_PATH ?= "$(HOME)/.docker" export -ALL_IMAGES = busybox-helper powershell-helper +ALL_IMAGES = powershell-helper sub-build-%: img_version=$(shell cat $*/VERSION); \ diff --git a/test/images/windows/busybox-helper/Dockerfile b/test/images/windows/busybox-helper/Dockerfile deleted file mode 100644 index 00dfe3756ca..00000000000 --- a/test/images/windows/busybox-helper/Dockerfile +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2020 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM mcr.microsoft.com/windows/servercore:ltsc2019 as prep - -ENV CURL_VERSION=7.57.0 - -ADD https://github.com/kubernetes-sigs/windows-testing/raw/master/images/busybox/busybox.exe /bin/busybox.exe -ADD https://skanthak.homepage.t-online.de/download/curl-$CURL_VERSION.cab /curl/curl.cab -ADD https://eternallybored.org/misc/netcat/netcat-win32-1.12.zip /netcat/netcat.zip -ADD https://downloads.isc.org/isc/bind9/9.14.10/BIND9.14.10.x64.zip /bind.zip - -USER ContainerAdministrator - -# NOTE(claudiub): We have to create relative path symlinks because docker buildx has an issue when copying -# over symlinks, it prepends "Files\" to the symlink target. "Files\C:\bin\busybox.exe" would be an -# invalid path. -RUN cd C:\bin && FOR /f "tokens=*" %i IN ('.\busybox --list') DO mklink .\%i.exe busybox.exe - -RUN cd C:\curl &\ - expand /R curl.cab /F:* . &\ - del C:\curl\curl.cab &\ - cd C:\netcat &\ - tar.exe -xf netcat.zip &\ - del netcat.zip &\ - setx /M PATH "C:\bin;C:\curl\;%PATH%" - -# Download bind and prepare a folder just for dig. -RUN powershell -Command "\ - Expand-Archive -Path C:\bind.zip -DestinationPath C:\bind; \ - $s = [System.Diagnostics.Process]::Start('C:\bind\vcredist_x64.exe', '/quiet'); \ - $s.WaitForExit(); \ - mkdir C:\dig; \ - cp C:\bind\dig.exe C:\dig\; \ - cp C:\bind\nslookup.exe C:\dig\; \ - cp C:\bind\*.dll C:\dig\; \ - cp C:\Windows\System32\vcruntime140.dll C:\dig\; \ - rm C:\bind.zip;" - -FROM mcr.microsoft.com/windows/nanoserver:1809 - -COPY --from=prep /bin /bin -COPY --from=prep /curl/AMD64 /curl/CURL.LIC /curl/ -COPY --from=prep /dig /dig -COPY --from=prep /netcat /netcat diff --git a/test/images/windows/busybox-helper/VERSION b/test/images/windows/busybox-helper/VERSION deleted file mode 100644 index 5e57fb89558..00000000000 --- a/test/images/windows/busybox-helper/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.29.0