From 2a3b325824b7a5e6f474276ace488f40c7a5a44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezequiel=20Fern=C3=A1ndez=20Ponce?= <20102608+ezfepo@users.noreply.github.com> Date: Tue, 13 Sep 2022 09:44:34 -0300 Subject: [PATCH] [CONSUL-424] Replace pkill in kill_envoy function (#52) --- build-support-windows/BUILD-IMAGES.md | 10 ++--- .../Dockerfile-consul-dev-windows | 45 ------------------- .../Dockerfile-consul-dev-windows.sh | 14 ------ .../Dockerfile-consul-local-windows | 2 +- build-support-windows/build-images.sh | 10 ++--- .../connect/envoy/helpers.windows.bash | 5 ++- .../connect/envoy/run-tests.windows.sh | 2 +- 7 files changed, 16 insertions(+), 72 deletions(-) delete mode 100644 build-support-windows/Dockerfile-consul-dev-windows delete mode 100644 build-support-windows/Dockerfile-consul-dev-windows.sh diff --git a/build-support-windows/BUILD-IMAGES.md b/build-support-windows/BUILD-IMAGES.md index 2839484802..7bea80ecdc 100644 --- a/build-support-windows/BUILD-IMAGES.md +++ b/build-support-windows/BUILD-IMAGES.md @@ -4,7 +4,7 @@ - [About](#about-this-file) - [Consul-windows](#consul-windows) -- [Dockerfile-consul-dev-windows](#dockerfile-consul-dev-windows) +- [Dockerfile-consul-local-windows](#dockerfile-consul-local-windows) - [Dockerfile-openzipkin-windows](#dockerfile-openzipkin-windows) - [Dockerfile-socat-windows](#dockerfile-socat-windows) - [Build images](#build-images) @@ -31,22 +31,22 @@ docker run --rm -p 8300:8300 -p 8301:8301 -p 8302:8302 -p 8500:8500 -p 8600:8600 If everything works properly you should openning the browser and check the Consul UI running on: `http://localhost:8500` -## Dockerfile-consul-dev-windows +## Dockerfile-consul-local-windows -The Consul-dev custom image deployed in the "Dockerfile-consul-dev-windows" DockerFile is generated by the sh script of the same name. +The Consul:local custom image deployed in the "Dockerfile-consul-local-windows" DockerFile is generated by the shell script of the same name. When executing it, the compilation of Consul is carried out and it is saved in the _"dist"_ directory, this file is then copied to a container created from the _"windows/consul"_ image. It is necessary that the _"windows/consul"_ image has been built first. To build this image you need to run the following command on your terminal: ```shell -./Dockerfile-consul-dev-windows.sh +./Dockerfile-consul-local-windows.sh ``` You can test the built file by running the following command: ```shell -docker run --rm -p 8300:8300 -p 8301:8301 -p 8302:8302 -p 8500:8500 -p 8600:8600 --name consul-dev --hostname "consul-primary-server" --network-alias "consul-primary-server" windows/consul-dev agent -dev -datacenter "primary" -grpc-port -1 -client "0.0.0.0" -bind "0.0.0.0" +docker run --rm -p 8300:8300 -p 8301:8301 -p 8302:8302 -p 8500:8500 -p 8600:8600 --name consul-local --hostname "consul-primary-server" --network-alias "consul-primary-server" windows/consul:local agent -dev -datacenter "primary" -grpc-port -1 -client "0.0.0.0" -bind "0.0.0.0" ``` If everything works properly you should openning the browser and check the Consul UI running on: `http://localhost:8500` diff --git a/build-support-windows/Dockerfile-consul-dev-windows b/build-support-windows/Dockerfile-consul-dev-windows deleted file mode 100644 index 6f54892408..0000000000 --- a/build-support-windows/Dockerfile-consul-dev-windows +++ /dev/null @@ -1,45 +0,0 @@ -ARG ENVOY_VERSION=v1.19.5 -ARG CONSUL_IMAGE_VERSION=latest - -FROM envoyproxy/envoy-windows:${ENVOY_VERSION} as envoy -FROM windows/consul:${CONSUL_IMAGE_VERSION} -COPY dist/ C:\\consul - -# Fortio binary downloaded -RUN mkdir fortio -ENV FORTIO_URL=https://github.com/fortio/fortio/releases/download/v1.33.0/fortio_win_1.33.0.zip -RUN curl %FORTIO_URL% -L -o fortio.zip -RUN tar -xf fortio.zip -C fortio - -# Copy envoy.exe from FROM envoyproxy/envoy-windows:${ENVOY_VERSION} -COPY --from=envoy ["C:/Program Files/envoy/", "C:/envoy/"] - -RUN choco install openssl -yf -RUN choco install jq -yf - -# Install Bats -ENV BATS_URL=https://github.com/bats-core/bats-core/archive/refs/tags/v1.7.0.zip -RUN curl %BATS_URL% -L -o bats.zip -RUN mkdir bats-core -RUN tar -xf bats.zip -C bats-core --strip-components=1 -RUN cd "C:\\Program Files\\Git\\bin" && bash.exe -c "/c/bats-core/install.sh /c/bats" - -# Install Jaeger -ENV JAEGER_URL=https://github.com/jaegertracing/jaeger/releases/download/v1.11.0/jaeger-1.11.0-windows-amd64.tar.gz -RUN curl %JAEGER_URL% -L -o jaeger.tar.gz -RUN mkdir jaeger -RUN tar -xf jaeger.tar.gz -C jaeger --strip-components=1 - -# Copy test-sds-server binary and certs -COPY --from=test-sds-server ["C:/go/src/", "C:/test-sds-server/"] - -EXPOSE 8300 -EXPOSE 8301 8301/udp 8302 8302/udp -EXPOSE 8500 8600 8600/udp -EXPOSE 8502 - -EXPOSE 19000 19001 19002 19003 19004 -EXPOSE 21000 21001 21002 21003 21004 -EXPOSE 5000 1234 2345 - -RUN SETX /M path "%PATH%;C:\consul;C:\envoy;C:\fortio;C:\jaeger;C:\Program Files\Git\bin;C:\Program Files\OpenSSL-Win64\bin;C:\bats\bin\bats;C:\ProgramData\chocolatey\lib\jq\tools;" diff --git a/build-support-windows/Dockerfile-consul-dev-windows.sh b/build-support-windows/Dockerfile-consul-dev-windows.sh deleted file mode 100644 index 8ddcc56361..0000000000 --- a/build-support-windows/Dockerfile-consul-dev-windows.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -cd ../ -rm -rf dist - -export GOOS=windows GOARCH=amd64 -CONSUL_VERSION=1.12.0 -CONSUL_BUILDDATE=$(date +"%Y-%m-%dT%H:%M:%SZ") -GIT_IMPORT=github.com/hashicorp/consul/version -GOLDFLAGS=" -X $GIT_IMPORT.Version=$CONSUL_VERSION -X $GIT_IMPORT.VersionPrerelease=local -X $GIT_IMPORT.BuildDate=$CONSUL_BUILDDATE " - -go build -ldflags "$GOLDFLAGS" -o ./dist/ . - -docker build -t windows/consul-dev -f ./build-support-windows/Dockerfile-consul-dev-windows . diff --git a/build-support-windows/Dockerfile-consul-local-windows b/build-support-windows/Dockerfile-consul-local-windows index a09c446e93..b65510f3dd 100644 --- a/build-support-windows/Dockerfile-consul-local-windows +++ b/build-support-windows/Dockerfile-consul-local-windows @@ -1,4 +1,4 @@ -ARG ENVOY_VERSION=v1.23.0 +ARG ENVOY_VERSION=v1.19.5 ARG CONSUL_IMAGE_VERSION=latest FROM envoyproxy/envoy-windows:${ENVOY_VERSION} as envoy diff --git a/build-support-windows/build-images.sh b/build-support-windows/build-images.sh index 77b63f41ae..5376c04cc8 100644 --- a/build-support-windows/build-images.sh +++ b/build-support-windows/build-images.sh @@ -12,12 +12,11 @@ echo " " echo "Build Windows Consul Image" docker build -t "windows/consul" -f ../Dockerfile-windows ../ -# Build Windows Consul-Dev Image +# Build Windows Consul:local Image echo " " -echo "Build Windows Consul-Dev Image" -./Dockerfile-consul-dev-windows.sh +echo "Build Windows Consul:local Image" +./Dockerfile-consul-local-windows.sh -# TODO: Check if this image is required # Pull Windows Nanoserver image echo " " echo "Pull Windows Nanoserver image" @@ -25,7 +24,8 @@ docker pull mcr.microsoft.com/windows/nanoserver:1809 # Tag Windows Nanoserver image echo " " echo "Tag Windows Nanoserver image" -# docker tag mcr.microsoft.com/windows/nanoserver:1809 "${HASHICORP_DOCKER_PROXY}/windows/nanoserver" +docker tag mcr.microsoft.com/windows/nanoserver:1809 "${HASHICORP_DOCKER_PROXY}/windows/nanoserver" + # Pull Kubernetes/pause image echo " " diff --git a/test/integration/connect/envoy/helpers.windows.bash b/test/integration/connect/envoy/helpers.windows.bash index edb4aec088..6ca7568ca9 100644 --- a/test/integration/connect/envoy/helpers.windows.bash +++ b/test/integration/connect/envoy/helpers.windows.bash @@ -608,7 +608,10 @@ function kill_envoy { local BOOTSTRAP_NAME=$1 local DC=${2:-primary} - pkill -TERM -f "envoy -c /workdir/$DC/envoy/${BOOTSTRAP_NAME}-bootstrap.json" + + PORT=$( cat /c/workdir/$DC/envoy/${BOOTSTRAP_NAME}-bootstrap.json | jq .admin.address.socket_address.port_value ) + PID=$( netstat -qo | grep "127.0.0.1:$PORT" | sed -r "s/.* //g" ) + KILL=$( tskill $PID ) } function must_match_in_statsd_logs { diff --git a/test/integration/connect/envoy/run-tests.windows.sh b/test/integration/connect/envoy/run-tests.windows.sh index 004d8d365c..72fe2f116e 100644 --- a/test/integration/connect/envoy/run-tests.windows.sh +++ b/test/integration/connect/envoy/run-tests.windows.sh @@ -17,7 +17,7 @@ DEBUG=${DEBUG:-} XDS_TARGET=${XDS_TARGET:-server} # ENVOY_VERSION to run each test against -ENVOY_VERSION=${ENVOY_VERSION:-"1.23.0"} +ENVOY_VERSION=${ENVOY_VERSION:-"1.19.5"} export ENVOY_VERSION export DOCKER_BUILDKIT=0