From ab49d5859ea75aa285169e76c7850bf97f3125ef Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Thu, 2 Feb 2023 12:28:57 +0000 Subject: [PATCH 01/29] Add rocky linux support --- Makefile | 1 + Makefile.packaging | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c10cde411..66fd3db36 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ DATE = $(shell date +%F_%H-%M-%S) # | debian | bullseye-slim, buster-slim | | # | centos | 7 | centos 7 (below 7.4) uses plus-pkgs.nginx.com as PACKAGES_REPO | # | redhatenterprise | 7, 8, 9 | | +# | rocky | 8, 9 | | # | alpine | 3.13, 3.14, 3.15, 3.16 | | # | oraclelinux | 7, 8 | | # | suse | sles12sp5, sle15 | | diff --git a/Makefile.packaging b/Makefile.packaging index a5d605c4d..3c6a313f0 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -7,7 +7,7 @@ GPG_PUBLIC_KEY := .key DEB_DISTROS?=ubuntu-jammy-22.04 ubuntu-focal-20.04 ubuntu-bionic-18.04 debian-bullseye-11 debian-buster-10 DEB_ARCHS?=arm64 amd64 -RPM_DISTROS?=centos-7-x86_64 redhatenterprise-7-x86_64 redhatenterprise-8-x86_64 redhatenterprise-9-x86_64 amazon-2-x86_64 amazon-latest-x86_64 amazon-2017.09-x86_64 suse-12-x86_64 suse-15-x86_64 +RPM_DISTROS?=centos-7-x86_64 redhatenterprise-7-x86_64 redhatenterprise-8-x86_64 redhatenterprise-9-x86_64 rocky-8-x86_64 rocky-9-x86_64 amazon-2-x86_64 amazon-latest-x86_64 amazon-2017.09-x86_64 suse-12-x86_64 suse-15-x86_64 FREEBSD_DISTROS?="FreeBSD:12:amd64" "FreeBSD:13:amd64" APK_VERSIONS?=3.13 3.14 3.15 3.16 APK_ARCHS?=aarch64 x86_64 @@ -36,7 +36,7 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages for distro in $(DEB_DISTROS); do \ deb_codename=`echo $$distro | cut -d- -f 2`; \ VERSION=$(shell echo ${VERSION} | tr -d 'v')~$${deb_codename} ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager deb --target ${PACKAGES_DIR}/deb/${PACKAGE_PREFIX}_$(shell echo ${VERSION} | tr -d 'v')~$${deb_codename}_$${arch}.deb; \ - cp ${PACKAGES_DIR}/deb/${PACKAGE_PREFIX}_$(shell echo ${VERSION} | tr -d 'v')~$${deb_codename}_$${arch}.deb ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')~$${deb_codename}_$${arch}.deb; \ + cp ${PACKAGES_DIR}/deb/${PACKAGE_PREFIX}_$(shell echo ${VERSION} | tr -d 'v')~$${deb_codename}_$${arch}.deb ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')~$${deb_codename}_$${arch}.deb; \ done; \ rm -rf ./build/nginx-agent; \ done; \ @@ -45,12 +45,13 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages @GOWORK=off CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent @for distro in $(RPM_DISTROS); do \ - rpm_distro=`echo $$distro | cut -d- -f 1`; \ - rpm_major=`echo $$distro | cut -d- -f 2`; \ + rpm_distro=$(echo $$distro | cut -d- -f 1); \ + rpm_major=$(echo $$distro | cut -d- -f 2); \ rpm_codename='na'; \ if [ "$$rpm_distro" = "centos" ] || [ "$$rpm_distro" = "redhatenterprise" ]; then rpm_codename="el$$rpm_major"; \ elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; fi; \ if [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; fi; \ + if [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; fi; \ if [ "$$rpm_codename" != "na" ]; then \ VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=amd64 nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(OSARCH).rpm; \ cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(OSARCH).rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(OSARCH).rpm; \ @@ -67,7 +68,7 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages for version in $(APK_VERSIONS); do \ if [ ! -d "$(PACKAGES_DIR)/apk/v$${version}/$${arch}" ]; then mkdir -p $(PACKAGES_DIR)/apk/v$${version}/$${arch}; fi; \ VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager apk --target $(PACKAGES_DIR)/apk/v$${version}/$${arch}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').apk; \ - cp $(PACKAGES_DIR)/apk/v$${version}/$${arch}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').apk ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-v$${version}-$${arch}.apk; \ + cp $(PACKAGES_DIR)/apk/v$${version}/$${arch}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').apk ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-v$${version}-$${arch}.apk; \ done; \ rm -rf ./build/nginx-agent; \ done; \ @@ -77,7 +78,7 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages rm -rf ./build/nginx-agent @GOWORK=off CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags=${LDFLAGS} -o ./build/nginx-agent - docker run -v `pwd`:/nginx-agent/ build-signed-packager:1.0.0 + docker run -v ${pwd}:/nginx-agent/ build-signed-packager:1.0.0 echo "DEB packages:"; \ find $(PACKAGES_DIR)/deb ;\ From 9f128b8b6f15019dd21642238c3ca2f1d9132c56 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Fri, 10 Feb 2023 14:40:00 +0000 Subject: [PATCH 02/29] Fix centos Docker image. WIP support base image override --- Makefile | 32 ++++++++------- scripts/docker/nginx-oss/centos/Dockerfile | 39 +++++++++++++++++++ test/integration/api/api_test.go | 2 +- test/integration/api/docker-compose-rpm.yml | 22 +++++++++++ .../install/docker-compose-rpm.yml | 14 +++++++ .../install/install_uninstall_test.go | 18 +++++---- 6 files changed, 103 insertions(+), 24 deletions(-) create mode 100644 scripts/docker/nginx-oss/centos/Dockerfile create mode 100644 test/integration/api/docker-compose-rpm.yml create mode 100644 test/integration/install/docker-compose-rpm.yml diff --git a/Makefile b/Makefile index 66fd3db36..dec99fe9b 100644 --- a/Makefile +++ b/Makefile @@ -16,27 +16,29 @@ DATE = $(shell date +%F_%H-%M-%S) # | debian | bullseye-slim, buster-slim | | # | centos | 7 | centos 7 (below 7.4) uses plus-pkgs.nginx.com as PACKAGES_REPO | # | redhatenterprise | 7, 8, 9 | | -# | rocky | 8, 9 | | +# | rockylinux | 8, 9 | | # | alpine | 3.13, 3.14, 3.15, 3.16 | | # | oraclelinux | 7, 8 | | # | suse | sles12sp5, sle15 | | # | freebsd | | Not supported | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -OS_RELEASE:=ubuntu -OS_VERSION:=22.04 -BASE_IMAGE="docker.io/${OS_RELEASE}:${OS_VERSION}" -IMAGE_TAG=agent_${OS_RELEASE}_${OS_VERSION} +OS_RELEASE := ubuntu +OS_VERSION := 22.04 +BASE_IMAGE = "docker.io/${OS_RELEASE}:${OS_VERSION}" +IMAGE_TAG = "agent_${OS_RELEASE}_${OS_VERSION}" + LDFLAGS = "-w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" DEBUG_LDFLAGS = "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -CERTS_DIR := ./build/certs -PACKAGE_PREFIX := nginx-agent -PACKAGES_REPO := "pkgs.nginx.com" -OS := $(shell uname -s | tr '[:upper:]' '[:lower:]') -OSARCH := $(shell uname -m) -TEST_BUILD_DIR := build/test -PACKAGE_NAME := "${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}" +CERTS_DIR := ./build/certs +PACKAGE_PREFIX := nginx-agent +PACKAGES_REPO := "pkgs.nginx.com" +OS := $(shell uname -s | tr '[:upper:]' '[:lower:]') +OSARCH := $(shell uname -m) +TEST_BUILD_DIR := build/test +TEST_DOCKER_COMPOSE_FILE = "docker-compose.yml" +PACKAGE_NAME := "${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}" # override this value if you want to change the architecture. GOOS options here: https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63 LOCAL_ARCH := amd64 @@ -180,9 +182,9 @@ test-component-run: ## Run component tests performance-test: ## Run performance tests $(CONTAINER_CLITOOL) run -v ${PWD}:/home/nginx/$(CONTAINER_VOLUME_FLAGS) --rm nginx-agent-benchmark:1.0.0 -integration-test: local-deb-package - PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} go test ./test/integration/install - PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} go test ./test/integration/api +integration-test: local-deb-package local-rpm-package + PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=$(BASE_IMAGE) DOCKER_COMPOSE_FILE=$(TEST_DOCKER_COMPOSE_FILE) go test -v ./test/integration/install + PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} DOCKER_COMPOSE_FILE=${TEST_DOCKER_COMPOSE_FILE} go test ./test/integration/api test-bench: ## Run benchmark tests cd test/performance && GOWORK=off CGO_ENABLED=0 go test -mod=vendor -count 5 -timeout 2m -bench=. -benchmem metrics_test.go diff --git a/scripts/docker/nginx-oss/centos/Dockerfile b/scripts/docker/nginx-oss/centos/Dockerfile new file mode 100644 index 000000000..275e68942 --- /dev/null +++ b/scripts/docker/nginx-oss/centos/Dockerfile @@ -0,0 +1,39 @@ +ARG BASE_IMAGE +FROM ${BASE_IMAGE} as install-nginx +LABEL maintainer="NGINX Agent Maintainers " + +ARG NGINX_CONF +ARG ENTRY_POINT + +WORKDIR /agent +COPY ./ /agent +COPY $ENTRY_POINT /agent/entrypoint.sh + +RUN set -x \ + && groupadd --system --gid 101 nginx \ + && adduser -g nginx --system --no-create-home --home /nonexistent --shell /bin/false --uid 101 nginx \ + && usermod -s /sbin/nologin nginx \ + && usermod -L nginx \ + && yum install -y git \ + wget \ + procps \ + make \ + vim \ + nginx + +RUN chmod +x /agent/entrypoint.sh +STOPSIGNAL SIGTERM + +EXPOSE 80 443 + +ENTRYPOINT ["/agent/entrypoint.sh"] + + +FROM install-nginx as install-agent + +ARG PACKAGE_NAME +ARG AGENT_CONF + +COPY $AGENT_CONF /agent/nginx-agent.conf +COPY --from=install-nginx /agent/nginx-agent.conf /etc/nginx-agent/nginx-agent.conf +RUN yum localinstall -y /agent/build/$PACKAGE_NAME.rpm diff --git a/test/integration/api/api_test.go b/test/integration/api/api_test.go index d22f7951e..c2440cd11 100644 --- a/test/integration/api/api_test.go +++ b/test/integration/api/api_test.go @@ -22,7 +22,7 @@ const ( ) func setupTestContainer(t *testing.T) { - comp, err := compose.NewDockerCompose("docker-compose.yml") + comp, err := compose.NewDockerCompose(os.Getenv("DOCKER_COMPOSE_FILE")) assert.NoError(t, err, "NewDockerComposeAPI()") t.Cleanup(func() { diff --git a/test/integration/api/docker-compose-rpm.yml b/test/integration/api/docker-compose-rpm.yml new file mode 100644 index 000000000..12c42b0fb --- /dev/null +++ b/test/integration/api/docker-compose-rpm.yml @@ -0,0 +1,22 @@ +version: '3.9' + +networks: + monitoring: + driver: bridge + +services: + agent: + build: + context: ../../../ + dockerfile: ./scripts/docker/nginx-oss/centos/Dockerfile + target: install-agent + args: + PACKAGE_NAME: ${PACKAGE_NAME} + BASE_IMAGE: ${BASE_IMAGE} + AGENT_CONF: "./test/testdata/configs/integration/api/nginx-agent.conf" + NGINX_CONF: "./test/testdata/configs/integration/api/nginx.conf" + ENTRY_POINT: "./scripts/docker/nginx-oss/entrypoint.sh" + ports: + - 9091:9091 + networks: + - monitoring diff --git a/test/integration/install/docker-compose-rpm.yml b/test/integration/install/docker-compose-rpm.yml new file mode 100644 index 000000000..8d7103e90 --- /dev/null +++ b/test/integration/install/docker-compose-rpm.yml @@ -0,0 +1,14 @@ +version: '3.9' + +services: + agent: + build: + context: ../../../ + dockerfile: ./scripts/docker/nginx-oss/centos/Dockerfile + target: install-nginx + args: + PACKAGE_NAME: ${PACKAGE_NAME} + BASE_IMAGE: ${BASE_IMAGE} + ENTRY_POINT: "./scripts/docker/nginx-oss/agentless-entrypoint.sh" + ports: + - 80 diff --git a/test/integration/install/install_uninstall_test.go b/test/integration/install/install_uninstall_test.go index f29f08b22..f8c9c1e62 100644 --- a/test/integration/install/install_uninstall_test.go +++ b/test/integration/install/install_uninstall_test.go @@ -32,7 +32,7 @@ var ( ) func setupTestContainer(t *testing.T) { - comp, err := compose.NewDockerCompose("docker-compose.yml") + comp, err := compose.NewDockerCompose(os.Getenv("DOCKER_COMPOSE_FILE")) assert.NoError(t, err, "NewDockerComposeAPI()") t.Cleanup(func() { @@ -77,8 +77,8 @@ func TestAgentManualInstallUninstall(t *testing.T) { } expectedUninstallLogMsgs := map[string]string{ - "UninstallAgent": "Removing nginx-agent", - "UninstallAgentPurgingFiles": "Purging configuration files for nginx-agent", + "UninstallAgent": "Removed:\n nginx-agent", + // "UninstallAgentPurgingFiles": "Purging configuration files for nginx-agent", } expectedAgentPaths := map[string]string{ @@ -94,9 +94,9 @@ func TestAgentManualInstallUninstall(t *testing.T) { assert.LessOrEqual(t, localAgentPkg.Size(), maxFileSize) - // Install Agent and record installation time/install output - dockerAgentPackagePath := getPackagePath(absContainerAgentPackageDir, string(osReleaseContent)) - installTime, installLog := installAgent(t, agentContainer, dockerAgentPackagePath, string(osReleaseContent)) + // Install Agent inside container and record installation time/install output + containerAgentPackagePath := getPackagePath(absContainerAgentPackageDir, string(osReleaseContent)) + installTime, installLog := installAgent(t, agentContainer, containerAgentPackagePath, string(osReleaseContent)) // Check the install time under 30s assert.LessOrEqual(t, installTime, maxInstallTime) @@ -170,7 +170,7 @@ func createInstallCommand(agentPackageFilePath, osReleaseContent string) []strin if strings.Contains(osReleaseContent, "UBUNTU") || strings.Contains(osReleaseContent, "Debian") { return []string{"dpkg", "-i", agentPackageFilePath} } else { - return []string{"yum", "localinstall", agentPackageFilePath} + return []string{"yum", "localinstall", "-y", agentPackageFilePath} } } @@ -200,7 +200,9 @@ func getPackagePath(pkgDir, osReleaseContent string) string { if strings.Contains(osReleaseContent, "UBUNTU") || strings.Contains(osReleaseContent, "Debian") { return pkgPath + ".deb" - } else { + } else if strings.Contains(osReleaseContent, "rhel") || strings.Contains(osReleaseContent, "centos") { return pkgPath + ".rpm" + } else { + return pkgPath + ".apk" } } From 5bb5f36ac61ba36d595a03bac24dff9beb15c5b9 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Fri, 10 Feb 2023 17:45:35 +0000 Subject: [PATCH 03/29] Fix debian baseimage runs --- test/integration/install/install_uninstall_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/integration/install/install_uninstall_test.go b/test/integration/install/install_uninstall_test.go index f8c9c1e62..318b04fbb 100644 --- a/test/integration/install/install_uninstall_test.go +++ b/test/integration/install/install_uninstall_test.go @@ -77,8 +77,8 @@ func TestAgentManualInstallUninstall(t *testing.T) { } expectedUninstallLogMsgs := map[string]string{ - "UninstallAgent": "Removed:\n nginx-agent", - // "UninstallAgentPurgingFiles": "Purging configuration files for nginx-agent", + "UninstallAgent": "Removing nginx-agent", + "UninstallAgentPurgingFiles": "Purging configuration files for nginx-agent", } expectedAgentPaths := map[string]string{ @@ -119,6 +119,10 @@ func TestAgentManualInstallUninstall(t *testing.T) { uninstallLog := uninstallAgent(t, agentContainer, string(osReleaseContent)) // Check uninstall output + if strings.HasSuffix(containerAgentPackagePath, "rpm") { + expectedUninstallLogMsgs["UninstallAgent"] = "Removed:\n nginx-agent" + delete(expectedInstallLogMsgs, "UninstallAgentPurgingFiles") + } for _, logMsg := range expectedUninstallLogMsgs { assert.Contains(t, uninstallLog, logMsg) } From 846811d533cf5803b4209f25fd4c93fce1f60731 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Fri, 10 Feb 2023 19:59:56 +0000 Subject: [PATCH 04/29] Fix docker volume mount --- Makefile.packaging | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.packaging b/Makefile.packaging index 3c6a313f0..41dddfdfa 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -78,7 +78,7 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages rm -rf ./build/nginx-agent @GOWORK=off CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags=${LDFLAGS} -o ./build/nginx-agent - docker run -v ${pwd}:/nginx-agent/ build-signed-packager:1.0.0 + docker run -v ${PWD}:/nginx-agent/ build-signed-packager:1.0.0 echo "DEB packages:"; \ find $(PACKAGES_DIR)/deb ;\ From b7e2f59df3abb749f90df7948731af74198ff55f Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Mon, 13 Feb 2023 14:46:43 +0000 Subject: [PATCH 05/29] WIP: Add matrix os testing --- .github/workflows/ci.yml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69e8c0b2b..3ef6a2b9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,9 +64,12 @@ jobs: - name: Run Component Tests run: make component-test - integration-test: + integration-test-deb: name: Integration Tests runs-on: ubuntu-22.04 + strategy: + matrix: + base-image: [ubuntu-22.04] steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -74,8 +77,24 @@ jobs: go-version-file: 'go.mod' - name: Run Integration Tests run: | - go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} - make integration-test + go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} + BASE_IMAGE="docker.io/${{ matrix.base-image }}" DOCKER_COMPOSE_FILE="docker-compose.yml" make integration-test + + integration-test-rpm: + name: Integration Tests + runs-on: ubuntu-22.04 + strategy: + matrix: + base-image: [rockylinux:8, rockylinux:9] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version-file: 'go.mod' + - name: Run Integration Tests + run: | + go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} + BASE_IMAGE="docker.io/${{ matrix.base-image }}" DOCKER_COMPOSE_FILE="docker-compose-rpm.yml" make integration-test performance-test: name: Performance Tests From 3f4899546b3fd0ef90c6ec0fb0eaab031b682631 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Mon, 13 Feb 2023 14:53:50 +0000 Subject: [PATCH 06/29] Quote base image tags --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ef6a2b9a..0ed230cda 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - base-image: [ubuntu-22.04] + base-image: ["ubuntu:22.04"] steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -85,7 +85,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - base-image: [rockylinux:8, rockylinux:9] + base-image: ["rockylinux:8", "rockylinux:9"] steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 From d7aa33a5ba90d4df36c28227f4626611ea6374e9 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 14 Feb 2023 10:36:23 +0000 Subject: [PATCH 07/29] Add GitHub actions matrix testing. PR feedback --- .github/workflows/ci.yml | 38 +++++++++---------- Makefile | 6 +-- ...ker-compose.yml => docker-compose-deb.yml} | 0 ...ker-compose.yml => docker-compose-deb.yml} | 0 4 files changed, 21 insertions(+), 23 deletions(-) rename test/integration/api/{docker-compose.yml => docker-compose-deb.yml} (100%) rename test/integration/install/{docker-compose.yml => docker-compose-deb.yml} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ed230cda..74b996cc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,28 +64,24 @@ jobs: - name: Run Component Tests run: make component-test - integration-test-deb: + integration-tests: + runs-on: ubuntu-22.04-${{ matrix.runner.arch }} name: Integration Tests - runs-on: ubuntu-22.04 - strategy: - matrix: - base-image: ["ubuntu:22.04"] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version-file: 'go.mod' - - name: Run Integration Tests - run: | - go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} - BASE_IMAGE="docker.io/${{ matrix.base-image }}" DOCKER_COMPOSE_FILE="docker-compose.yml" make integration-test - - integration-test-rpm: - name: Integration Tests - runs-on: ubuntu-22.04 strategy: matrix: - base-image: ["rockylinux:8", "rockylinux:9"] + runner: + - arch: amd64 + - arch: arm64 + container: + - image: rockylinux + version: 8 + compose-file: docker-compose-rpm.yml + - image: rockylinux + version: 9 + compose-file: docker-compose-rpm.yml + - image: "ubuntu" + version: "22.04" + compose-file: docker-compose-deb.yml steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -94,7 +90,9 @@ jobs: - name: Run Integration Tests run: | go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} - BASE_IMAGE="docker.io/${{ matrix.base-image }}" DOCKER_COMPOSE_FILE="docker-compose-rpm.yml" make integration-test + BASE_IMAGE="docker.io/${{ matrix.container.image }}:${{ matrix.container.version }}" \ + DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \ + make integration-test performance-test: name: Performance Tests diff --git a/Makefile b/Makefile index dec99fe9b..bbfbdb071 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ DATE = $(shell date +%F_%H-%M-%S) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # OS_RELEASE := ubuntu OS_VERSION := 22.04 -BASE_IMAGE = "docker.io/${OS_RELEASE}:${OS_VERSION}" +BASE_IMAGE := "docker.io/${OS_RELEASE}:${OS_VERSION}" IMAGE_TAG = "agent_${OS_RELEASE}_${OS_VERSION}" @@ -37,7 +37,7 @@ PACKAGES_REPO := "pkgs.nginx.com" OS := $(shell uname -s | tr '[:upper:]' '[:lower:]') OSARCH := $(shell uname -m) TEST_BUILD_DIR := build/test -TEST_DOCKER_COMPOSE_FILE = "docker-compose.yml" +TEST_DOCKER_COMPOSE_FILE := "docker-compose-deb.yml" PACKAGE_NAME := "${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}" # override this value if you want to change the architecture. GOOS options here: https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63 LOCAL_ARCH := amd64 @@ -183,7 +183,7 @@ performance-test: ## Run performance tests $(CONTAINER_CLITOOL) run -v ${PWD}:/home/nginx/$(CONTAINER_VOLUME_FLAGS) --rm nginx-agent-benchmark:1.0.0 integration-test: local-deb-package local-rpm-package - PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=$(BASE_IMAGE) DOCKER_COMPOSE_FILE=$(TEST_DOCKER_COMPOSE_FILE) go test -v ./test/integration/install + PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} DOCKER_COMPOSE_FILE=$(TEST_DOCKER_COMPOSE_FILE) go test ./test/integration/install PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} DOCKER_COMPOSE_FILE=${TEST_DOCKER_COMPOSE_FILE} go test ./test/integration/api test-bench: ## Run benchmark tests diff --git a/test/integration/api/docker-compose.yml b/test/integration/api/docker-compose-deb.yml similarity index 100% rename from test/integration/api/docker-compose.yml rename to test/integration/api/docker-compose-deb.yml diff --git a/test/integration/install/docker-compose.yml b/test/integration/install/docker-compose-deb.yml similarity index 100% rename from test/integration/install/docker-compose.yml rename to test/integration/install/docker-compose-deb.yml From 3245aefcfaa3dd49e54b3eb84272d2a9065d0963 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 14 Feb 2023 11:44:28 +0000 Subject: [PATCH 08/29] Build amd64 rpm packages --- Makefile.packaging | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Makefile.packaging b/Makefile.packaging index 41dddfdfa..451b67ad4 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -7,7 +7,8 @@ GPG_PUBLIC_KEY := .key DEB_DISTROS?=ubuntu-jammy-22.04 ubuntu-focal-20.04 ubuntu-bionic-18.04 debian-bullseye-11 debian-buster-10 DEB_ARCHS?=arm64 amd64 -RPM_DISTROS?=centos-7-x86_64 redhatenterprise-7-x86_64 redhatenterprise-8-x86_64 redhatenterprise-9-x86_64 rocky-8-x86_64 rocky-9-x86_64 amazon-2-x86_64 amazon-latest-x86_64 amazon-2017.09-x86_64 suse-12-x86_64 suse-15-x86_64 +RPM_DISTROS?=centos-7 redhatenterprise-7 redhatenterprise-8 redhatenterprise-9 rocky-8 rocky-9 amazon-2 amazon-latest amazon-2017.09 suse-12 suse-15 +RPM_ARCHS?=arm64 amd64 FREEBSD_DISTROS?="FreeBSD:12:amd64" "FreeBSD:13:amd64" APK_VERSIONS?=3.13 3.14 3.15 3.16 APK_ARCHS?=aarch64 x86_64 @@ -43,19 +44,21 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages # Create rpm packages - @GOWORK=off CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent - @for distro in $(RPM_DISTROS); do \ - rpm_distro=$(echo $$distro | cut -d- -f 1); \ - rpm_major=$(echo $$distro | cut -d- -f 2); \ - rpm_codename='na'; \ - if [ "$$rpm_distro" = "centos" ] || [ "$$rpm_distro" = "redhatenterprise" ]; then rpm_codename="el$$rpm_major"; \ - elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; fi; \ - if [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; fi; \ - if [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; fi; \ - if [ "$$rpm_codename" != "na" ]; then \ - VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=amd64 nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(OSARCH).rpm; \ - cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(OSARCH).rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(OSARCH).rpm; \ - fi; \ + @for arch in ${RPM_ARCHS}; do \ + GOWORK=off CGO_ENABLED=0 GOARCH=$${arch} GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent \ + for distro in $(RPM_DISTROS); do \ + rpm_distro=$(echo $$distro | cut -d- -f 1); \ + rpm_major=$(echo $$distro | cut -d- -f 2); \ + rpm_codename='na'; \ + if [ "$$rpm_distro" = "centos" ] || [ "$$rpm_distro" = "redhatenterprise" ]; then rpm_codename="el$$rpm_major"; \ + elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; fi; \ + elif [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; fi; \ + elif [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; fi; \ + if [ "$$rpm_codename" != "na" ]; then \ + VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm; \ + cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm; \ + fi; \ + done; \ done; \ rm -rf ./build/nginx-agent From 17f6780da961256d9f99aeb584038bbf8534b009 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 14 Feb 2023 12:08:34 +0000 Subject: [PATCH 09/29] Fix rpm builds --- Makefile.packaging | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.packaging b/Makefile.packaging index 451b67ad4..0841cef38 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -45,7 +45,7 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages # Create rpm packages @for arch in ${RPM_ARCHS}; do \ - GOWORK=off CGO_ENABLED=0 GOARCH=$${arch} GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent \ + GOWORK=off CGO_ENABLED=0 GOARCH=$${arch} GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent; \ for distro in $(RPM_DISTROS); do \ rpm_distro=$(echo $$distro | cut -d- -f 1); \ rpm_major=$(echo $$distro | cut -d- -f 2); \ @@ -59,8 +59,8 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm; \ fi; \ done; \ + rm -rf ./build/nginx-agent; \ done; \ - rm -rf ./build/nginx-agent # Create apk packages From 49800d0a766b163087384daba407189653977c9a Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 14 Feb 2023 14:32:10 +0000 Subject: [PATCH 10/29] Fix rpm packaging --- Makefile.packaging | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile.packaging b/Makefile.packaging index 0841cef38..cf8b15bd0 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -51,9 +51,10 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages rpm_major=$(echo $$distro | cut -d- -f 2); \ rpm_codename='na'; \ if [ "$$rpm_distro" = "centos" ] || [ "$$rpm_distro" = "redhatenterprise" ]; then rpm_codename="el$$rpm_major"; \ - elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; fi; \ - elif [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; fi; \ - elif [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; fi; \ + elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; \ + elif [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; \ + elif [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; \ + fi; \ if [ "$$rpm_codename" != "na" ]; then \ VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm; \ cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm; \ From d43b8fc68b4ad73bbcdadef49cc44fcd533683fa Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 14 Feb 2023 14:44:27 +0000 Subject: [PATCH 11/29] Fmt bash --- Makefile.packaging | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.packaging b/Makefile.packaging index cf8b15bd0..9a1819c96 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -44,16 +44,16 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages # Create rpm packages - @for arch in ${RPM_ARCHS}; do \ + @for arch in $(RPM_ARCHS); do \ GOWORK=off CGO_ENABLED=0 GOARCH=$${arch} GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent; \ for distro in $(RPM_DISTROS); do \ rpm_distro=$(echo $$distro | cut -d- -f 1); \ rpm_major=$(echo $$distro | cut -d- -f 2); \ rpm_codename='na'; \ if [ "$$rpm_distro" = "centos" ] || [ "$$rpm_distro" = "redhatenterprise" ]; then rpm_codename="el$$rpm_major"; \ - elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; \ - elif [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; \ - elif [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; \ + elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; \ + elif [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; \ + elif [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; \ fi; \ if [ "$$rpm_codename" != "na" ]; then \ VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm; \ From d72bef30097a099e6df58bddda0cb675afa20f38 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 14 Feb 2023 15:33:32 +0000 Subject: [PATCH 12/29] Revert logic change --- Makefile.packaging | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.packaging b/Makefile.packaging index 9a1819c96..823b8748b 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -51,10 +51,10 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages rpm_major=$(echo $$distro | cut -d- -f 2); \ rpm_codename='na'; \ if [ "$$rpm_distro" = "centos" ] || [ "$$rpm_distro" = "redhatenterprise" ]; then rpm_codename="el$$rpm_major"; \ - elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; \ - elif [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; \ - elif [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; \ - fi; \ + elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; fi; \ + if [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; fi; \ + if [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; fi; \ + if [ "$$rpm_codename" != "na" ]; then \ VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm; \ cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm; \ From a68c1167a799fe1e21d81088e55dbec3bfef40db Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 14 Feb 2023 15:47:56 +0000 Subject: [PATCH 13/29] Split rocky packaging so only rocky gets arm64 packages --- Makefile.packaging | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/Makefile.packaging b/Makefile.packaging index 823b8748b..8436e0e9d 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -7,8 +7,9 @@ GPG_PUBLIC_KEY := .key DEB_DISTROS?=ubuntu-jammy-22.04 ubuntu-focal-20.04 ubuntu-bionic-18.04 debian-bullseye-11 debian-buster-10 DEB_ARCHS?=arm64 amd64 -RPM_DISTROS?=centos-7 redhatenterprise-7 redhatenterprise-8 redhatenterprise-9 rocky-8 rocky-9 amazon-2 amazon-latest amazon-2017.09 suse-12 suse-15 -RPM_ARCHS?=arm64 amd64 +RPM_DISTROS?=centos-7-x86_64 redhatenterprise-7-x86_64 redhatenterprise-8-x86_64 redhatenterprise-9-x86_64 amazon-2-x86_64 amazon-latest-x86_64 amazon-2017.09-x86_64 suse-12-x86_64 suse-15-x86_64 +ROCKY_DISTROS?=rocky-8 rocky-9 +ROCKY_ARCHS?=arm64 amd64 FREEBSD_DISTROS?="FreeBSD:12:amd64" "FreeBSD:13:amd64" APK_VERSIONS?=3.13 3.14 3.15 3.16 APK_ARCHS?=aarch64 x86_64 @@ -43,18 +44,31 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages done; \ # Create rpm packages + + @GOWORK=off CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent + @for distro in $(RPM_DISTROS); do \ + rpm_distro=`echo $$distro | cut -d- -f 1`; \ + rpm_major=`echo $$distro | cut -d- -f 2`; \ + rpm_codename='na'; \ + if [ "$$rpm_distro" = "centos" ] || [ "$$rpm_distro" = "redhatenterprise" ]; then rpm_codename="el$$rpm_major"; \ + elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; fi; \ + if [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; fi; \ + if [ "$$rpm_codename" != "na" ]; then \ + VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=amd64 nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(OSARCH).rpm; \ + cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(OSARCH).rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(OSARCH).rpm; \ + fi; \ + done; \ + rm -rf ./build/nginx-agent + + # Create rocky rpm packages - @for arch in $(RPM_ARCHS); do \ + @for arch in $(ROCKY_ARCHS); do \ GOWORK=off CGO_ENABLED=0 GOARCH=$${arch} GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent; \ - for distro in $(RPM_DISTROS); do \ + for distro in $(ROCKY_DISTROS); do \ rpm_distro=$(echo $$distro | cut -d- -f 1); \ rpm_major=$(echo $$distro | cut -d- -f 2); \ rpm_codename='na'; \ - if [ "$$rpm_distro" = "centos" ] || [ "$$rpm_distro" = "redhatenterprise" ]; then rpm_codename="el$$rpm_major"; \ - elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; fi; \ - if [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; fi; \ if [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; fi; \ - if [ "$$rpm_codename" != "na" ]; then \ VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm; \ cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm; \ From 63df835c3557db2c8e1dc5d4a66665767f0b3a66 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 14 Feb 2023 16:19:45 +0000 Subject: [PATCH 14/29] Fix rocky packaging --- Makefile.packaging | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile.packaging b/Makefile.packaging index 8436e0e9d..b78962b16 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -51,8 +51,9 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages rpm_major=`echo $$distro | cut -d- -f 2`; \ rpm_codename='na'; \ if [ "$$rpm_distro" = "centos" ] || [ "$$rpm_distro" = "redhatenterprise" ]; then rpm_codename="el$$rpm_major"; \ - elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; fi; \ - if [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; fi; \ + elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; \ + elif [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; \ + fi; \ if [ "$$rpm_codename" != "na" ]; then \ VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=amd64 nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(OSARCH).rpm; \ cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(OSARCH).rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(OSARCH).rpm; \ @@ -65,8 +66,8 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages @for arch in $(ROCKY_ARCHS); do \ GOWORK=off CGO_ENABLED=0 GOARCH=$${arch} GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent; \ for distro in $(ROCKY_DISTROS); do \ - rpm_distro=$(echo $$distro | cut -d- -f 1); \ - rpm_major=$(echo $$distro | cut -d- -f 2); \ + rpm_distro=`echo $$distro | cut -d- -f 1`; \ + rpm_major=`echo $$distro | cut -d- -f 2`; \ rpm_codename='na'; \ if [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; fi; \ if [ "$$rpm_codename" != "na" ]; then \ From efbabae3b0595ee1bbf01b2458e0a9d867abf846 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 14 Feb 2023 16:24:53 +0000 Subject: [PATCH 15/29] Disable amd64 matrix for now --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74b996cc5..95837efa4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,13 +65,13 @@ jobs: run: make component-test integration-tests: - runs-on: ubuntu-22.04-${{ matrix.runner.arch }} + runs-on: ubuntu-22.04 name: Integration Tests strategy: matrix: - runner: - - arch: amd64 - - arch: arm64 + # runner: + # - arch: amd64 + # - arch: arm64 container: - image: rockylinux version: 8 From 1883609b6c445a067d082e76e76db64cbe971a48 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 14 Feb 2023 16:31:16 +0000 Subject: [PATCH 16/29] Lint --- Makefile.packaging | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.packaging b/Makefile.packaging index b78962b16..de83840b9 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -8,7 +8,7 @@ GPG_PUBLIC_KEY := .key DEB_DISTROS?=ubuntu-jammy-22.04 ubuntu-focal-20.04 ubuntu-bionic-18.04 debian-bullseye-11 debian-buster-10 DEB_ARCHS?=arm64 amd64 RPM_DISTROS?=centos-7-x86_64 redhatenterprise-7-x86_64 redhatenterprise-8-x86_64 redhatenterprise-9-x86_64 amazon-2-x86_64 amazon-latest-x86_64 amazon-2017.09-x86_64 suse-12-x86_64 suse-15-x86_64 -ROCKY_DISTROS?=rocky-8 rocky-9 +ROCKY_VERSIONS?=rocky-8 rocky-9 ROCKY_ARCHS?=arm64 amd64 FREEBSD_DISTROS?="FreeBSD:12:amd64" "FreeBSD:13:amd64" APK_VERSIONS?=3.13 3.14 3.15 3.16 @@ -47,7 +47,7 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages @GOWORK=off CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent @for distro in $(RPM_DISTROS); do \ - rpm_distro=`echo $$distro | cut -d- -f 1`; \ + rpm_distro=`echo $$distro | cut -d- -f 1`; \ rpm_major=`echo $$distro | cut -d- -f 2`; \ rpm_codename='na'; \ if [ "$$rpm_distro" = "centos" ] || [ "$$rpm_distro" = "redhatenterprise" ]; then rpm_codename="el$$rpm_major"; \ @@ -65,7 +65,7 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages @for arch in $(ROCKY_ARCHS); do \ GOWORK=off CGO_ENABLED=0 GOARCH=$${arch} GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent; \ - for distro in $(ROCKY_DISTROS); do \ + for distro in $(ROCKY_VERSIONS); do \ rpm_distro=`echo $$distro | cut -d- -f 1`; \ rpm_major=`echo $$distro | cut -d- -f 2`; \ rpm_codename='na'; \ From 5f8122a50dc232fdc431478a402b8b203aab6a35 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Wed, 15 Feb 2023 12:10:28 +0000 Subject: [PATCH 17/29] Use arm runner action and detect OS arch --- .github/workflows/ci.yml | 11 ++++++++--- Makefile | 25 +++++++++++++++++-------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95837efa4..0d4e9bbfb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,9 +69,6 @@ jobs: name: Integration Tests strategy: matrix: - # runner: - # - arch: amd64 - # - arch: arm64 container: - image: rockylinux version: 8 @@ -93,6 +90,14 @@ jobs: BASE_IMAGE="docker.io/${{ matrix.container.image }}:${{ matrix.container.version }}" \ DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \ make integration-test + - name: Run Integration Tests on arm64 + uses: pguyot/arm-runner-action@v2 + with: + commands: | + go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} + BASE_IMAGE="docker.io/${{ matrix.container.image }}:${{ matrix.container.version }}" \ + DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \ + make integration-test performance-test: name: Performance Tests diff --git a/Makefile b/Makefile index bbfbdb071..4658f4718 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,16 @@ TEST_BUILD_DIR := build/test TEST_DOCKER_COMPOSE_FILE := "docker-compose-deb.yml" PACKAGE_NAME := "${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}" # override this value if you want to change the architecture. GOOS options here: https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63 -LOCAL_ARCH := amd64 +uname_m := $(shell uname -m) +ifeq ($(uname_m),aarch64) + OSARCH = arm64 +else + ifeq ($(uname_m),x86_64) + OSARCH = amd64 + else + OSARCH = $(uname_m) + endif +endif CERT_CLIENT_CA_CN := client-ca.local CERT_CLIENT_INT_CN := client-int.local @@ -115,19 +124,19 @@ launch-swagger-ui: generate-swagger ## Launch Swagger UI # Local Packaging # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # local-apk-package: ## Create local apk package - GOWORK=off CGO_ENABLED=0 GOARCH=${LOCAL_ARCH} GOOS=linux go build -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent - ARCH=${LOCAL_ARCH} VERSION=$(shell echo ${VERSION} | tr -d 'v') nfpm pkg --config ./scripts/.local-nfpm.yaml --packager apk --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.apk; + GOWORK=off CGO_ENABLED=0 GOARCH=${OS_ARCH} GOOS=linux go build -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent + ARCH=${OS_ARCH} VERSION=$(shell echo ${VERSION} | tr -d 'v') nfpm pkg --config ./scripts/.local-nfpm.yaml --packager apk --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.apk; local-deb-package: ## Create local deb package - GOWORK=off CGO_ENABLED=0 GOARCH=${LOCAL_ARCH} GOOS=linux go build -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent - ARCH=${LOCAL_ARCH} VERSION=$(shell echo ${VERSION} | tr -d 'v') nfpm pkg --config ./scripts/.local-nfpm.yaml --packager deb --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.deb; + GOWORK=off CGO_ENABLED=0 GOARCH=${OS_ARCH} GOOS=linux go build -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent + ARCH=${OS_ARCH} VERSION=$(shell echo ${VERSION} | tr -d 'v') nfpm pkg --config ./scripts/.local-nfpm.yaml --packager deb --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.deb; local-rpm-package: ## Create local rpm package - GOWORK=off CGO_ENABLED=0 GOARCH=${LOCAL_ARCH} GOOS=linux go build -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent - ARCH=${LOCAL_ARCH} VERSION=$(shell echo ${VERSION} | tr -d 'v') nfpm pkg --config ./scripts/.local-nfpm.yaml --packager rpm --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.rpm; + GOWORK=off CGO_ENABLED=0 GOARCH=${OS_ARCH} GOOS=linux go build -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent + ARCH=${OS_ARCH} VERSION=$(shell echo ${VERSION} | tr -d 'v') nfpm pkg --config ./scripts/.local-nfpm.yaml --packager rpm --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.rpm; local-txz-package: ## Create local txz package - GOWORK=off CGO_ENABLED=0 GOARCH=${LOCAL_ARCH} GOOS=freebsd go build -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent + GOWORK=off CGO_ENABLED=0 GOARCH=${OS_ARCH} GOOS=freebsd go build -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent $(CONTAINER_CLITOOL) run -v ${PWD}:/nginx-agent/$(CONTAINER_VOLUME_FLAGS) build-local-packager:1.0.0 txz-packager-image: ## Builds txz packager container image From b26a01652efd7d4c17450424155833c12a3f5333 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Wed, 15 Feb 2023 12:25:13 +0000 Subject: [PATCH 18/29] Enlarge image to allow install --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d4e9bbfb..9e2aa5ea9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,6 +93,7 @@ jobs: - name: Run Integration Tests on arm64 uses: pguyot/arm-runner-action@v2 with: + image_additional_mb: 2048 commands: | go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} BASE_IMAGE="docker.io/${{ matrix.container.image }}:${{ matrix.container.version }}" \ From 41beae683b70abb700543818549afdf7ecb7298d Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Wed, 15 Feb 2023 14:37:13 +0000 Subject: [PATCH 19/29] Test separate arm64 stage --- .github/workflows/ci.yml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e2aa5ea9..d264d7984 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,9 +64,9 @@ jobs: - name: Run Component Tests run: make component-test - integration-tests: + integration-tests-amd64: runs-on: ubuntu-22.04 - name: Integration Tests + name: Integration Tests on AMD64 strategy: matrix: container: @@ -93,13 +93,37 @@ jobs: - name: Run Integration Tests on arm64 uses: pguyot/arm-runner-action@v2 with: - image_additional_mb: 2048 + image_additional_mb: 4096 commands: | go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} BASE_IMAGE="docker.io/${{ matrix.container.image }}:${{ matrix.container.version }}" \ DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \ make integration-test + integration-tests-arm64: + runs-on: ubuntu-22.04 + name: Integration Tests on ARM64 + strategy: + matrix: + container: + - image: "ubuntu" + version: "22.04" + compose-file: docker-compose-deb.yml + steps: + - uses: actions/checkout@v3 + - name: Run Integration Tests on arm64 + uses: pguyot/arm-runner-action@v2 + with: + image_additional_mb: 4096 + optimize_image: no + commands: | + sudo apt-get update -y --allow-releaseinfo-change + sudo apt-get install --no-install-recommends -y golang docker + go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} + BASE_IMAGE="docker.io/${{ matrix.container.image }}:${{ matrix.container.version }}" \ + DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \ + make integration-test + performance-test: name: Performance Tests if: "!github.event.pull_request.head.repo.fork" From 488f5c0741c47206489a217ae3132071bf98169d Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Wed, 15 Feb 2023 14:46:38 +0000 Subject: [PATCH 20/29] Use go get for go1.15 support --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d264d7984..7d6a0a11a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,7 +119,7 @@ jobs: commands: | sudo apt-get update -y --allow-releaseinfo-change sudo apt-get install --no-install-recommends -y golang docker - go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} + go get github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} BASE_IMAGE="docker.io/${{ matrix.container.image }}:${{ matrix.container.version }}" \ DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \ make integration-test From 116763bf0c0c4e537ac378322c14c59760bc3863 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Wed, 15 Feb 2023 15:30:27 +0000 Subject: [PATCH 21/29] Remove testing on arm64 for now --- .github/workflows/ci.yml | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d6a0a11a..bf31678ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,9 +64,9 @@ jobs: - name: Run Component Tests run: make component-test - integration-tests-amd64: + integration-tests: runs-on: ubuntu-22.04 - name: Integration Tests on AMD64 + name: Integration Tests strategy: matrix: container: @@ -90,39 +90,6 @@ jobs: BASE_IMAGE="docker.io/${{ matrix.container.image }}:${{ matrix.container.version }}" \ DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \ make integration-test - - name: Run Integration Tests on arm64 - uses: pguyot/arm-runner-action@v2 - with: - image_additional_mb: 4096 - commands: | - go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} - BASE_IMAGE="docker.io/${{ matrix.container.image }}:${{ matrix.container.version }}" \ - DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \ - make integration-test - - integration-tests-arm64: - runs-on: ubuntu-22.04 - name: Integration Tests on ARM64 - strategy: - matrix: - container: - - image: "ubuntu" - version: "22.04" - compose-file: docker-compose-deb.yml - steps: - - uses: actions/checkout@v3 - - name: Run Integration Tests on arm64 - uses: pguyot/arm-runner-action@v2 - with: - image_additional_mb: 4096 - optimize_image: no - commands: | - sudo apt-get update -y --allow-releaseinfo-change - sudo apt-get install --no-install-recommends -y golang docker - go get github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} - BASE_IMAGE="docker.io/${{ matrix.container.image }}:${{ matrix.container.version }}" \ - DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \ - make integration-test performance-test: name: Performance Tests From 2fba720116c7ca3d38b5ee5dda506dee273d9c59 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Mon, 20 Feb 2023 16:37:47 +0000 Subject: [PATCH 22/29] Fix goarch builds --- Makefile.packaging | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.packaging b/Makefile.packaging index c19c6a320..f88c78b23 100644 --- a/Makefile.packaging +++ b/Makefile.packaging @@ -11,7 +11,7 @@ DEB_DISTROS?=ubuntu-jammy-22.04 ubuntu-focal-20.04 ubuntu-bionic-18.04 debian-bu DEB_ARCHS?=arm64 amd64 RPM_DISTROS?=centos-7-x86_64 redhatenterprise-7-x86_64 redhatenterprise-8-x86_64 redhatenterprise-9-x86_64 amazon-2-x86_64 amazon-latest-x86_64 amazon-2017.09-x86_64 suse-12-x86_64 suse-15-x86_64 ROCKY_VERSIONS?=rocky-8 rocky-9 -ROCKY_ARCHS?=arm64 amd64 +ROCKY_ARCHS?=aarch64 x86_64 RPM_ARCH=x86_64 FREEBSD_DISTROS?="FreeBSD:12:amd64" "FreeBSD:13:amd64" APK_VERSIONS?=3.13 3.14 3.15 3.16 @@ -67,7 +67,9 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages # Create rocky rpm packages @for arch in $(ROCKY_ARCHS); do \ - GOWORK=off CGO_ENABLED=0 GOARCH=$${arch} GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent; \ + goarch=amd64; \ + if [ "$$arch" = "aarch64" ]; then goarch="arm64"; fi; \ + GOWORK=off CGO_ENABLED=0 GOARCH=$${goarch} GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent; \ for distro in $(ROCKY_VERSIONS); do \ rpm_distro=`echo $$distro | cut -d- -f 1`; \ rpm_major=`echo $$distro | cut -d- -f 2`; \ From d8e3303b87c127533775aca8484a516727ed841e Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Mon, 20 Feb 2023 16:41:28 +0000 Subject: [PATCH 23/29] Mv centos->rockylinux --- scripts/docker/nginx-oss/{centos => rockylinux}/Dockerfile | 0 test/integration/api/docker-compose-rpm.yml | 2 +- test/integration/install/docker-compose-rpm.yml | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename scripts/docker/nginx-oss/{centos => rockylinux}/Dockerfile (100%) diff --git a/scripts/docker/nginx-oss/centos/Dockerfile b/scripts/docker/nginx-oss/rockylinux/Dockerfile similarity index 100% rename from scripts/docker/nginx-oss/centos/Dockerfile rename to scripts/docker/nginx-oss/rockylinux/Dockerfile diff --git a/test/integration/api/docker-compose-rpm.yml b/test/integration/api/docker-compose-rpm.yml index 12c42b0fb..89787c334 100644 --- a/test/integration/api/docker-compose-rpm.yml +++ b/test/integration/api/docker-compose-rpm.yml @@ -8,7 +8,7 @@ services: agent: build: context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/centos/Dockerfile + dockerfile: ./scripts/docker/nginx-oss/rockylinux/Dockerfile target: install-agent args: PACKAGE_NAME: ${PACKAGE_NAME} diff --git a/test/integration/install/docker-compose-rpm.yml b/test/integration/install/docker-compose-rpm.yml index 8d7103e90..8bf72aafe 100644 --- a/test/integration/install/docker-compose-rpm.yml +++ b/test/integration/install/docker-compose-rpm.yml @@ -4,7 +4,7 @@ services: agent: build: context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/centos/Dockerfile + dockerfile: ./scripts/docker/nginx-oss/rockylinux/Dockerfile target: install-nginx args: PACKAGE_NAME: ${PACKAGE_NAME} From f0706878110d65b26d6a7c493f74900b4b499407 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 21 Feb 2023 16:07:23 +0000 Subject: [PATCH 24/29] Revert var declaration change --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 85ed9ff05..6e2a4ccb9 100644 --- a/Makefile +++ b/Makefile @@ -22,9 +22,9 @@ DATE = $(shell date +%F_%H-%M-%S) # | suse | sles12sp5, sle15 | | # | freebsd | | Not supported | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -OS_RELEASE := ubuntu -OS_VERSION := 22.04 -BASE_IMAGE := "docker.io/${OS_RELEASE}:${OS_VERSION}" +OS_RELEASE = ubuntu +OS_VERSION = 22.04 +BASE_IMAGE = "docker.io/${OS_RELEASE}:${OS_VERSION}" IMAGE_TAG = "agent_${OS_RELEASE}_${OS_VERSION}" From a486e2e3f6409deb875e80f2f73f39df4b94b2a2 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 21 Feb 2023 16:38:39 +0000 Subject: [PATCH 25/29] Fix setting CI args --- .github/workflows/ci.yml | 2 +- Makefile | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f7a02863..dd28929e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,7 +87,7 @@ jobs: - name: Run Integration Tests run: | go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} - BASE_IMAGE="docker.io/${{ matrix.container.image }}:${{ matrix.container.version }}" \ + OS_RELEASE="${{ matrix.container.image }}" OS_VERSION="${{ matrix.container.version }}" \ DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \ make integration-test diff --git a/Makefile b/Makefile index 6e2a4ccb9..940a82b12 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,8 @@ DATE = $(shell date +%F_%H-%M-%S) # | suse | sles12sp5, sle15 | | # | freebsd | | Not supported | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -OS_RELEASE = ubuntu -OS_VERSION = 22.04 +OS_RELEASE ?= ubuntu +OS_VERSION ?= 22.04 BASE_IMAGE = "docker.io/${OS_RELEASE}:${OS_VERSION}" IMAGE_TAG = "agent_${OS_RELEASE}_${OS_VERSION}" @@ -48,9 +48,9 @@ else endif endif -TEST_BUILD_DIR := build/test -TEST_DOCKER_COMPOSE_FILE := "docker-compose-deb.yml" -PACKAGE_NAME := "${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}" +TEST_BUILD_DIR := build/test +TEST_DOCKER_COMPOSE_FILE ?= "docker-compose-deb.yml" +PACKAGE_NAME := "${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}" CERT_CLIENT_CA_CN := client-ca.local CERT_CLIENT_INT_CN := client-int.local From 1187119a116ca7618c8f48587306d96873bbdbc9 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 21 Feb 2023 17:14:05 +0000 Subject: [PATCH 26/29] Override correct Makefile var. Quote integration test data --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd28929e2..010449c24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,15 +70,15 @@ jobs: strategy: matrix: container: - - image: rockylinux - version: 8 - compose-file: docker-compose-rpm.yml - - image: rockylinux - version: 9 - compose-file: docker-compose-rpm.yml + - image: "rockylinux" + version: "8" + compose-file: "docker-compose-rpm.yml" + - image: "rockylinux" + version: "9" + compose-file: "docker-compose-rpm.yml" - image: "ubuntu" version: "22.04" - compose-file: docker-compose-deb.yml + compose-file: "docker-compose-deb.yml" steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -88,7 +88,7 @@ jobs: run: | go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }} OS_RELEASE="${{ matrix.container.image }}" OS_VERSION="${{ matrix.container.version }}" \ - DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \ + TEST_DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \ make integration-test performance-test: From 70c68a207eb6d075a4548b15004601a9e2b4711a Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 21 Feb 2023 17:26:45 +0000 Subject: [PATCH 27/29] Fix expected uninstall log map --- test/integration/install/install_uninstall_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/install/install_uninstall_test.go b/test/integration/install/install_uninstall_test.go index b2485a8b9..da3fcc01e 100644 --- a/test/integration/install/install_uninstall_test.go +++ b/test/integration/install/install_uninstall_test.go @@ -122,7 +122,7 @@ func TestAgentManualInstallUninstall(t *testing.T) { // Check uninstall output if strings.HasSuffix(containerAgentPackagePath, "rpm") { expectedUninstallLogMsgs["UninstallAgent"] = "Removed:\n nginx-agent" - delete(expectedInstallLogMsgs, "UninstallAgentPurgingFiles") + delete(expectedUninstallLogMsgs, "UninstallAgentPurgingFiles") } for _, logMsg := range expectedUninstallLogMsgs { assert.Contains(t, uninstallLog, logMsg) From 474551084684bd12c41970be52ae346a6a3487e4 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 21 Feb 2023 17:37:51 +0000 Subject: [PATCH 28/29] Add api integration fixes --- test/integration/api/docker-compose-rpm.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration/api/docker-compose-rpm.yml b/test/integration/api/docker-compose-rpm.yml index 89787c334..31fda79e5 100644 --- a/test/integration/api/docker-compose-rpm.yml +++ b/test/integration/api/docker-compose-rpm.yml @@ -13,10 +13,11 @@ services: args: PACKAGE_NAME: ${PACKAGE_NAME} BASE_IMAGE: ${BASE_IMAGE} - AGENT_CONF: "./test/testdata/configs/integration/api/nginx-agent.conf" - NGINX_CONF: "./test/testdata/configs/integration/api/nginx.conf" ENTRY_POINT: "./scripts/docker/nginx-oss/entrypoint.sh" ports: - 9091:9091 networks: - monitoring + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + - ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf From 9ba41b4063ad018ac6c3f2aac57306922ab27807 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 21 Feb 2023 18:14:33 +0000 Subject: [PATCH 29/29] Copy over api dockerfile fixes --- scripts/docker/nginx-oss/rockylinux/Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/docker/nginx-oss/rockylinux/Dockerfile b/scripts/docker/nginx-oss/rockylinux/Dockerfile index 275e68942..5702ba6b6 100644 --- a/scripts/docker/nginx-oss/rockylinux/Dockerfile +++ b/scripts/docker/nginx-oss/rockylinux/Dockerfile @@ -32,8 +32,5 @@ ENTRYPOINT ["/agent/entrypoint.sh"] FROM install-nginx as install-agent ARG PACKAGE_NAME -ARG AGENT_CONF -COPY $AGENT_CONF /agent/nginx-agent.conf -COPY --from=install-nginx /agent/nginx-agent.conf /etc/nginx-agent/nginx-agent.conf RUN yum localinstall -y /agent/build/$PACKAGE_NAME.rpm