From f98b0bc5eeb9edb8d277f5d36d3d2ce0c68a6497 Mon Sep 17 00:00:00 2001 From: Evgenii Date: Sat, 22 Jun 2024 09:47:24 +0200 Subject: [PATCH 1/2] fix(backup): find race and disable search in subdir, always test latest backup image in e2e, bump backup to 0.3.x (#1011) Co-authored-by: brokenpip3 --- Makefile | 15 +++- backup/pvc/Makefile | 8 ++- backup/pvc/VERSION.txt | 2 +- backup/pvc/bin/get-latest.sh | 33 ++++++++- backup/pvc/bin/run.sh | 69 +++++++++++++++++-- backup/pvc/config.env | 1 + backup/pvc/e2e/get-latest/test.sh | 17 +++++ backup/pvc/e2e/limit_backup_count/test.sh | 13 ++-- .../e2e/limit_backup_count_no_backups/test.sh | 14 +++- .../test.sh | 6 +- test/e2e/restorebackup_test.go | 2 +- 11 files changed, 160 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 10c3e0475..bdd8d4e37 100644 --- a/Makefile +++ b/Makefile @@ -89,11 +89,18 @@ test: ## Runs the go tests @RUNNING_TESTS=1 go test -tags "$(BUILDTAGS) cgo" $(PACKAGES_FOR_UNIT_TESTS) .PHONY: e2e -e2e: deepcopy-gen manifests ## Runs e2e tests, you can use EXTRA_ARGS +e2e: deepcopy-gen manifests backup-kind-load ## Runs e2e tests, you can use EXTRA_ARGS @echo "+ $@" RUNNING_TESTS=1 go test -parallel=1 "./test/e2e/" -ginkgo.v -tags "$(BUILDTAGS) cgo" -v -timeout 60m -run "$(E2E_TEST_SELECTOR)" \ -jenkins-api-hostname=$(JENKINS_API_HOSTNAME) -jenkins-api-port=$(JENKINS_API_PORT) -jenkins-api-use-nodeport=$(JENKINS_API_USE_NODEPORT) $(E2E_TEST_ARGS) +## Backup Section + +.PHONY: backup-kind-load +backup-kind-load: ## Load latest backup image in the cluster + @echo "+ $@" + make -C backup/pvc backup-kind-load + ## HELM Section .PHONY: helm @@ -370,6 +377,12 @@ kind-clean: ## Delete kind cluster @echo "+ $@" kind delete cluster --name $(KIND_CLUSTER_NAME) +.PHONY: kind-load-backup +kind-load-backup: + @echo "+ $@" + make -C + kind delete cluster --name $(KIND_CLUSTER_NAME) + .PHONY: bats-tests IMAGE_NAME := quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY):$(GITCOMMIT)-amd64 BUILD_PRESENT := $(shell docker images |grep -q ${IMAGE_NAME}) diff --git a/backup/pvc/Makefile b/backup/pvc/Makefile index d8ec544fb..4999ae7a4 100644 --- a/backup/pvc/Makefile +++ b/backup/pvc/Makefile @@ -118,6 +118,12 @@ docker-release-latest: docker-build ## Release image with latest tags (in additi docker-release: docker-release-version docker-release-latest ## Release image with version and latest tags (in addition to build tag) @echo "+ $@" +.PHONY: backup-kind-load +backup-kind-load: docker-build ## Build and load backup img in kind with e2e-test tag + @echo "+ $@" + docker tag quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY)-$(NAME):$(GITCOMMIT) quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY)-$(NAME):e2e-test + kind load docker-image quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY)-$(NAME):e2e-test --name $(KIND_CLUSTER_NAME) + # if this session isn't interactive, then we don't want to allocate a # TTY, which would fail, but if it is interactive, we do want to attach # so that the user can send e.g. ^C through. @@ -127,7 +133,7 @@ ifeq ($(INTERACTIVE), 1) endif .PHONY: docker-run -docker-run: docker-build ## Run the container in docker, you can use EXTRA_ARGS +docker-run: docker-build @echo "+ $@" docker run --rm -i $(DOCKER_FLAGS) \ quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY)-$(NAME):$(GITCOMMIT) $(ARGS) diff --git a/backup/pvc/VERSION.txt b/backup/pvc/VERSION.txt index b88fb90fb..268b0334e 100644 --- a/backup/pvc/VERSION.txt +++ b/backup/pvc/VERSION.txt @@ -1 +1 @@ -v0.2.5 +v0.3.0 diff --git a/backup/pvc/bin/get-latest.sh b/backup/pvc/bin/get-latest.sh index 519a4c6e9..da8055f4e 100644 --- a/backup/pvc/bin/get-latest.sh +++ b/backup/pvc/bin/get-latest.sh @@ -2,9 +2,38 @@ set -eo pipefail -[[ -z "${BACKUP_DIR}" ]] && echo "Required 'BACKUP_DIR' env not set" && exit 1 +is_backup_not_exist() { + local backup_dir="$1" + # Save the current value of 'set -e' + local previous_e + previous_e=$(set +e; :; echo $?) + + # Temporarily turn off 'set -e' + set +e + + # Run ls command to check if any files matching the pattern exist + ls "${backup_dir}"/*.tar.* 1> /dev/null 2>&1 + + # Store the exit status of the ls command + local ls_exit_status=$? + + # Restore the previous value of 'set -e' + [ "$previous_e" = "0" ] && set -e + + # Return true if ls command succeeded (no files found), otherwise return false + [ $ls_exit_status -ne 0 ] +} + +[[ -z "${BACKUP_DIR}" ]] && { echo "Required 'BACKUP_DIR' env not set"; exit 1; } + +# Check if we have any backup +if is_backup_not_exist "${BACKUP_DIR}"; then + echo "-1" + exit 0 +fi + # Search for all the tar.* inside the backup dir to support the migration between gzip vs zstd -latest=$(find ${BACKUP_DIR} -name '*.tar.*' -exec basename {} \; | sort -g | tail -n 1) +latest=$(find "${BACKUP_DIR}"/*.tar.* -maxdepth 0 -exec basename {} \; | sort -g | tail -n 1) if [[ "${latest}" == "" ]]; then echo "-1" diff --git a/backup/pvc/bin/run.sh b/backup/pvc/bin/run.sh index 50123d5e2..4b6052019 100644 --- a/backup/pvc/bin/run.sh +++ b/backup/pvc/bin/run.sh @@ -2,15 +2,70 @@ set -eo pipefail -[[ -z "${BACKUP_DIR}" ]] && echo "Required 'BACKUP_DIR' env not set" && exit 1; -[[ -z "${JENKINS_HOME}" ]] && echo "Required 'JENKINS_HOME' env not set" && exit 1; +# Use 60 as default in case BACKUP_CLEANUP_INTERVAL did not set +BACKUP_CLEANUP_INTERVAL=${BACKUP_CLEANUP_INTERVAL:=60} + +# Ensure required environment variables are set +check_env_var() { + if [[ -z "${!1}" ]]; then + echo "Required '$1' environment variable is not set" + exit 1 + fi +} + +is_backup_not_exist() { + local backup_dir="$1" + # Save the current value of 'set -e' + local previous_e + previous_e=$(set +e; :; echo $?) + + # Temporarily turn off 'set -e' + set +e + + # Run ls command to check if any files matching the pattern exist + ls "${backup_dir}"/*.tar.* 1> /dev/null 2>&1 + + # Store the exit status of the ls command + local ls_exit_status=$? + + # Restore the previous value of 'set -e' + [ "$previous_e" = "0" ] && set -e + + # Return true if ls command succeeded (no files found), otherwise return false + [ $ls_exit_status -ne 0 ] +} + +# Function to find exceeding backups +find_exceeding_backups() { + local backup_dir="$1" + local backup_count="$2" + # Check if we have any backup + if is_backup_not_exist "${backup_dir}"; then + echo "backups not found in ${backup_dir}" >&2 + return + fi + find "${backup_dir}"/*.tar.zstd -maxdepth 0 -exec basename {} \; | sort -gr | tail -n +$((backup_count +1)) +} + +check_env_var "BACKUP_DIR" +check_env_var "JENKINS_HOME" + +if [[ -z "${BACKUP_COUNT}" ]]; then + echo "ATTENTION! No BACKUP_COUNT set, it means you MUST delete old backups manually or by custom script" +else + echo "Retaining only the ${BACKUP_COUNT} most recent backups, cleanup occurs every ${BACKUP_CLEANUP_INTERVAL} seconds" +fi while true; do - sleep 10 - if [[ ! -z "${BACKUP_COUNT}" ]]; then - echo "Trimming to only ${BACKUP_COUNT} recent backups in preparation for new backup" - #TODO: add the list of exceeding backup before delete - find ${BACKUP_DIR} -maxdepth 1 -name '*.tar.zstd' -exec basename {} \; | sort -gr | tail -n +$((BACKUP_COUNT +1)) | xargs -I '{}' rm ${BACKUP_DIR}/'{}' + sleep "$BACKUP_CLEANUP_INTERVAL" + if [[ -n "${BACKUP_COUNT}" ]]; then + exceeding_backups=$(find_exceeding_backups "${BACKUP_DIR}" "${BACKUP_COUNT}") + if [[ -n "$exceeding_backups" ]]; then + echo "Removing backups: $(echo "$exceeding_backups" | tr '\n' ', ' | sed 's/,$//')" + echo "$exceeding_backups" | while read -r file; do + rm "${BACKUP_DIR}/${file}" + done + fi fi done diff --git a/backup/pvc/config.env b/backup/pvc/config.env index 64a407549..e2b892251 100644 --- a/backup/pvc/config.env +++ b/backup/pvc/config.env @@ -4,3 +4,4 @@ QUAY_ORGANIZATION=jenkins-kubernetes-operator QUAY_REGISTRY=backup UID=1000 GID=1000 +KIND_CLUSTER_NAME=jenkins diff --git a/backup/pvc/e2e/get-latest/test.sh b/backup/pvc/e2e/get-latest/test.sh index a0aabe9a2..e8b4eb480 100755 --- a/backup/pvc/e2e/get-latest/test.sh +++ b/backup/pvc/e2e/get-latest/test.sh @@ -30,6 +30,9 @@ touch ${BACKUP_DIR}/8.tar.zstd touch ${BACKUP_DIR}/9.tar.zstd touch ${BACKUP_DIR}/10.tar.zstd touch ${BACKUP_DIR}/11.tar.zstd +# Emulate backup creation +BACKUP_TMP_DIR=$(mktemp -d --tmpdir="${BACKUP_DIR}") +touch ${BACKUP_TMP_DIR}/12.tar.zstd # Create an instance of the container under testing cid="$(docker run -e JENKINS_HOME=${JENKINS_HOME} -v ${JENKINS_HOME}:${JENKINS_HOME}:ro -e BACKUP_DIR=${BACKUP_DIR} -v ${BACKUP_DIR}:${BACKUP_DIR}:rw -d ${docker_image})" @@ -38,10 +41,20 @@ echo "Docker container ID '${cid}'" # Remove test directory and container afterwards trap "docker rm -vf $cid > /dev/null;rm -rf ${BACKUP_DIR};rm -rf ${JENKINS_HOME}" EXIT +echo "Try to get latest against 11 backups and one in progress" latest=$(docker exec ${cid} /bin/bash -c "JENKINS_HOME=${RESTORE_FOLDER};/home/user/bin/get-latest.sh") + rm ${BACKUP_DIR}/*.tar.zstd +echo "Try to get latest against one in progress" empty_latest=$(docker exec ${cid} /bin/bash -c "JENKINS_HOME=${RESTORE_FOLDER};/home/user/bin/get-latest.sh") +rmdir ${BACKUP_DIR}/lost+found +rm ${BACKUP_TMP_DIR}/*.tar.zstd +rmdir ${BACKUP_TMP_DIR} +echo "Try to get latest against empty dir" +empty_dir_latest=$(docker exec ${cid} /bin/bash -c "JENKINS_HOME=${RESTORE_FOLDER};/home/user/bin/get-latest.sh") + + if [[ "${DEBUG}" ]]; then docker logs ${cid} ls -la ${BACKUP_DIR} @@ -55,5 +68,9 @@ if [[ ! "${empty_latest}" == "-1" ]]; then echo "Latest backup number should be '-1' but is '${empty_latest}'" exit 1 fi +if [[ ! "${empty_dir_latest}" == "-1" ]]; then + echo "Latest backup number should be '-1' but is '${empty_dir_latest}'" + exit 1 +fi echo PASS diff --git a/backup/pvc/e2e/limit_backup_count/test.sh b/backup/pvc/e2e/limit_backup_count/test.sh index 469b3e44c..cbe1ecd41 100755 --- a/backup/pvc/e2e/limit_backup_count/test.sh +++ b/backup/pvc/e2e/limit_backup_count/test.sh @@ -1,6 +1,8 @@ #!/bin/bash set -eo pipefail +echo "Running limit_backup_count e2e test..." + [[ "${DEBUG}" ]] && set -x # set current working directory to the directory of the script @@ -30,17 +32,20 @@ touch ${BACKUP_DIR}/8.tar.zstd touch ${BACKUP_DIR}/9.tar.zstd touch ${BACKUP_DIR}/10.tar.zstd touch ${BACKUP_DIR}/11.tar.zstd +# Emulate backup creation +BACKUP_TMP_DIR=$(mktemp -d --tmpdir="${BACKUP_DIR}") +touch ${BACKUP_TMP_DIR}/12.tar.zstd # Create an instance of the container under testing -cid="$(docker run -e BACKUP_COUNT=2 -e JENKINS_HOME=${JENKINS_HOME} -v ${JENKINS_HOME}:${JENKINS_HOME}:ro -e BACKUP_DIR=${BACKUP_DIR} -v ${BACKUP_DIR}:${BACKUP_DIR}:rw -d ${docker_image})" +cid="$(docker run -e BACKUP_CLEANUP_INTERVAL=1 -e BACKUP_COUNT=2 -e JENKINS_HOME=${JENKINS_HOME} -v ${JENKINS_HOME}:${JENKINS_HOME}:ro -e BACKUP_DIR=${BACKUP_DIR} -v ${BACKUP_DIR}:${BACKUP_DIR}:rw -d ${docker_image})" echo "Docker container ID '${cid}'" # Remove test directory and container afterwards trap "docker rm -vf $cid > /dev/null;rm -rf ${BACKUP_DIR};rm -rf ${JENKINS_HOME}" EXIT -sleep 11 -touch ${BACKUP_DIR}/12.tar.zstd -sleep 11 +sleep 2 +mv ${BACKUP_TMP_DIR}/12.tar.zstd ${BACKUP_DIR}/ +sleep 2 if [[ "${DEBUG}" ]]; then docker logs ${cid} diff --git a/backup/pvc/e2e/limit_backup_count_no_backups/test.sh b/backup/pvc/e2e/limit_backup_count_no_backups/test.sh index 531ac3da2..1b90acd82 100755 --- a/backup/pvc/e2e/limit_backup_count_no_backups/test.sh +++ b/backup/pvc/e2e/limit_backup_count_no_backups/test.sh @@ -1,6 +1,8 @@ #!/bin/bash set -eo pipefail +echo "Running limit_backup_count_no_backups e2e test..." + [[ "${DEBUG}" ]] && set -x # set current working directory to the directory of the script @@ -19,7 +21,7 @@ mkdir -p ${BACKUP_DIR} mkdir -p ${JENKINS_HOME} # Create an instance of the container under testing -cid="$(docker run -e BACKUP_COUNT=2 -e JENKINS_HOME=${JENKINS_HOME} -v ${JENKINS_HOME}:${JENKINS_HOME}:ro -e BACKUP_DIR=${BACKUP_DIR} -v ${BACKUP_DIR}:${BACKUP_DIR}:rw -d ${docker_image})" +cid="$(docker run -e BACKUP_CLEANUP_INTERVAL=1 -e BACKUP_COUNT=2 -e JENKINS_HOME=${JENKINS_HOME} -v ${JENKINS_HOME}:${JENKINS_HOME}:ro -e BACKUP_DIR=${BACKUP_DIR} -v ${BACKUP_DIR}:${BACKUP_DIR}:rw -d ${docker_image})" echo "Docker container ID '${cid}'" # Remove test directory and container afterwards @@ -27,8 +29,16 @@ trap "docker rm -vf $cid > /dev/null;rm -rf ${BACKUP_DIR};rm -rf ${JENKINS_HOME} # container should be running echo 'Checking if container is running' -sleep 11 +sleep 3 +set +e docker exec ${cid} echo +exit_code=$? +set -e +if [ $exit_code -ne 0 ]; then + echo "container terminated with following logs:" + docker logs "${cid}" + exit 1 +fi echo 'Container is running' echo PASS diff --git a/backup/pvc/e2e/tmp_dir_clean_after_backup_creation/test.sh b/backup/pvc/e2e/tmp_dir_clean_after_backup_creation/test.sh index 662809c89..f373543c8 100755 --- a/backup/pvc/e2e/tmp_dir_clean_after_backup_creation/test.sh +++ b/backup/pvc/e2e/tmp_dir_clean_after_backup_creation/test.sh @@ -1,6 +1,8 @@ #!/bin/bash set -eo pipefail +echo "Running tmp_dir_clean_after_backup_creation e2e test..." + [[ "${DEBUG}" ]] && set -x # set current working directory to the directory of the script @@ -18,7 +20,7 @@ BACKUP_DIR="$(pwd)/backup" mkdir -p ${BACKUP_DIR} # Create an instance of the container under testing -cid="$(docker run -e JENKINS_HOME=${JENKINS_HOME} -v ${JENKINS_HOME}:${JENKINS_HOME}:ro -e BACKUP_DIR=${BACKUP_DIR} -v ${BACKUP_DIR}:${BACKUP_DIR}:rw -d ${docker_image})" +cid="$(docker run -e BACKUP_CLEANUP_INTERVAL=1 -e JENKINS_HOME=${JENKINS_HOME} -v ${JENKINS_HOME}:${JENKINS_HOME}:ro -e BACKUP_DIR=${BACKUP_DIR} -v ${BACKUP_DIR}:${BACKUP_DIR}:rw -d ${docker_image})" echo "Docker container ID '${cid}'" # Remove test directory and container afterwards @@ -28,6 +30,8 @@ backup_number=1 docker exec ${cid} /home/user/bin/backup.sh ${backup_number} [ "$(docker exec ${cid} ls /tmp | grep 'tmp')" ] && echo "tmp directory not empty" && exit 1; +# We should also check backup directory, since after #1000 we create temp directory at backup filesystem +[ "$(docker exec ${cid} ls ${BACKUP_DIR} | grep 'tmp')" ] && echo "backup dir consists temp directory" && exit 1; backup_file="${BACKUP_DIR}/${backup_number}.tar.zstd" [[ ! -f ${backup_file} ]] && echo "Backup file ${backup_file} not found" && exit 1; diff --git a/test/e2e/restorebackup_test.go b/test/e2e/restorebackup_test.go index aa90f6ae5..43f2f5b46 100644 --- a/test/e2e/restorebackup_test.go +++ b/test/e2e/restorebackup_test.go @@ -157,7 +157,7 @@ func createJenkinsWithBackupAndRestoreConfigured(name, namespace string) *v1alph }, { Name: containerName, - Image: "virtuslab/jenkins-operator-backup-pvc:v0.1.1", + Image: "quay.io/jenkins-kubernetes-operator/backup-pvc:e2e-test", ImagePullPolicy: corev1.PullIfNotPresent, Env: []corev1.EnvVar{ { From e0f52b5bdf02104b31ec1627143032510803622a Mon Sep 17 00:00:00 2001 From: Luigi Operoso <40476330+brokenpip3@users.noreply.github.com> Date: Sat, 22 Jun 2024 16:27:38 +0200 Subject: [PATCH 2/2] chore(operator): update jenkins latest img and plugins, use latest backup in bats tests (#1022) --- Makefile | 10 ++-------- chart/jenkins-operator/README.md | 2 +- chart/jenkins-operator/values.yaml | 6 +++--- config.base.env | 2 +- pkg/configuration/user/seedjobs/seedjobs.go | 2 +- pkg/configuration/user/seedjobs/seedjobs_test.go | 2 +- pkg/constants/constants.go | 2 +- pkg/plugins/base_plugins.go | 2 +- test/bats/1-deploy.bats | 14 +++++++++----- test/bats/2-deploy-with-more-options.bats | 6 ++++-- test/bats/3-deploy-with-webhook.bats | 10 ++++++---- test/e2e/configuration_test.go | 2 +- test/e2e/test_utility.go | 2 +- test/helm/helm_test.go | 2 +- 14 files changed, 33 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index bdd8d4e37..e4ef73b29 100644 --- a/Makefile +++ b/Makefile @@ -377,22 +377,16 @@ kind-clean: ## Delete kind cluster @echo "+ $@" kind delete cluster --name $(KIND_CLUSTER_NAME) -.PHONY: kind-load-backup -kind-load-backup: - @echo "+ $@" - make -C - kind delete cluster --name $(KIND_CLUSTER_NAME) - .PHONY: bats-tests IMAGE_NAME := quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY):$(GITCOMMIT)-amd64 BUILD_PRESENT := $(shell docker images |grep -q ${IMAGE_NAME}) ifndef BUILD_PRESENT -bats-tests: container-runtime-build-amd64 ## Run bats tests +bats-tests: backup-kind-load container-runtime-build-amd64 ## Run bats tests @echo "+ $@" kind load docker-image ${IMAGE_NAME} --name $(KIND_CLUSTER_NAME) OPERATOR_IMAGE="${IMAGE_NAME}" TERM=xterm bats -T -p test/bats else -bats-tests: ## Run bats tests +bats-tests: backup-kind-load @echo "+ $@" OPERATOR_IMAGE="${IMAGE_NAME}" TERM=xterm bats -T -p test/bats endif diff --git a/chart/jenkins-operator/README.md b/chart/jenkins-operator/README.md index 4ce0beb71..2c2b2fc11 100644 --- a/chart/jenkins-operator/README.md +++ b/chart/jenkins-operator/README.md @@ -54,7 +54,7 @@ Kubernetes native operator which fully manages Jenkins on Kubernetes | jenkins.enabled | bool | `true` | | | jenkins.env | list | `[]` | | | jenkins.hostAliases | object | `{}` | | -| jenkins.image | string | `"jenkins/jenkins:2.452.1-lts"` | | +| jenkins.image | string | `"jenkins/jenkins:2.452.2-lts"` | | | jenkins.imagePullPolicy | string | `"Always"` | | | jenkins.imagePullSecrets | list | `[]` | | | jenkins.labels | object | `{}` | | diff --git a/chart/jenkins-operator/values.yaml b/chart/jenkins-operator/values.yaml index f2eba788a..cc878194b 100644 --- a/chart/jenkins-operator/values.yaml +++ b/chart/jenkins-operator/values.yaml @@ -36,7 +36,7 @@ jenkins: # image is the name (and tag) of the Jenkins instance # Default: jenkins/jenkins:lts # It's recommended to use LTS (tag: "lts") version - image: jenkins/jenkins:2.452.1-lts + image: jenkins/jenkins:2.452.2-lts # env contains jenkins container environment variables env: [] @@ -94,7 +94,7 @@ jenkins: # # basePlugins: # - name: kubernetes - # version: 4238.v41b_3ef14a_5d8 + # version: 4246.v5a_12b_1fe120e # - name: workflow-job # version: 1400.v7fd111b_ec82f # - name: workflow-aggregator @@ -139,7 +139,7 @@ jenkins: # repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git seedJobs: [] - # SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:3206.vb_15dcf73f6a_9-3 will be used. + # SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:3248.v65ecb_254c298-6 will be used. seedJobAgentImage: "" # Resource limit/request for Jenkins diff --git a/config.base.env b/config.base.env index 5d6787d17..f535e8bb4 100644 --- a/config.base.env +++ b/config.base.env @@ -7,7 +7,7 @@ GO_VERSION="1.15.6" HELM_VERSION="3.12.3" IMAGE_PULL_MODE="local" KIND_CLUSTER_NAME="jenkins" -LATEST_LTS_VERSION="2.452.1" +LATEST_LTS_VERSION="2.452.2" NAME="kubernetes-operator" NAMESPACE="default" OPERATOR_SDK_VERSION="1.3.0" diff --git a/pkg/configuration/user/seedjobs/seedjobs.go b/pkg/configuration/user/seedjobs/seedjobs.go index 64b54ffa3..d6b0f5981 100644 --- a/pkg/configuration/user/seedjobs/seedjobs.go +++ b/pkg/configuration/user/seedjobs/seedjobs.go @@ -46,7 +46,7 @@ const ( AgentName = "seed-job-agent" // DefaultAgentImage is the default image used for the seed-job agent - defaultAgentImage = "jenkins/inbound-agent:3248.v65ecb_254c298-4" + defaultAgentImage = "jenkins/inbound-agent:3248.v65ecb_254c298-6" creatingGroovyScriptName = "seed-job-groovy-script.groovy" diff --git a/pkg/configuration/user/seedjobs/seedjobs_test.go b/pkg/configuration/user/seedjobs/seedjobs_test.go index 30686749f..ff517bf17 100644 --- a/pkg/configuration/user/seedjobs/seedjobs_test.go +++ b/pkg/configuration/user/seedjobs/seedjobs_test.go @@ -113,7 +113,7 @@ func TestEnsureSeedJobs(t *testing.T) { var agentDeployment appsv1.Deployment err = fakeClient.Get(ctx, types.NamespacedName{Namespace: jenkins.Namespace, Name: agentDeploymentName(*jenkins, AgentName)}, &agentDeployment) assert.NoError(t, err) - assert.Equal(t, "jenkins/inbound-agent:3248.v65ecb_254c298-4", agentDeployment.Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, "jenkins/inbound-agent:3248.v65ecb_254c298-6", agentDeployment.Spec.Template.Spec.Containers[0].Image) assert.Equal(t, "JENKINS_WEB_SOCKET", agentDeployment.Spec.Template.Spec.Containers[0].Env[0].Name) assert.Equal(t, "true", agentDeployment.Spec.Template.Spec.Containers[0].Env[0].Value) }) diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 7e26f4115..e43f87c03 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -8,7 +8,7 @@ const ( // SeedJobSuffix is a suffix added for all seed jobs SeedJobSuffix = "job-dsl-seed" // DefaultJenkinsMasterImage is the default Jenkins master docker image - DefaultJenkinsMasterImage = "jenkins/jenkins:2.452.1-lts" + DefaultJenkinsMasterImage = "jenkins/jenkins:2.452.2-lts" // DefaultHTTPPortInt32 is the default Jenkins HTTP port DefaultHTTPPortInt32 = int32(8080) // DefaultSlavePortInt32 is the default Jenkins port for slaves diff --git a/pkg/plugins/base_plugins.go b/pkg/plugins/base_plugins.go index 8f35410fe..48982e027 100644 --- a/pkg/plugins/base_plugins.go +++ b/pkg/plugins/base_plugins.go @@ -4,7 +4,7 @@ const ( configurationAsCodePlugin = "configuration-as-code:1810.v9b_c30a_249a_4c" gitPlugin = "git:5.2.2" jobDslPlugin = "job-dsl:1.87" - kubernetesPlugin = "kubernetes:4238.v41b_3ef14a_5d8" + kubernetesPlugin = "kubernetes:4246.v5a_12b_1fe120e" kubernetesCredentialsProviderPlugin = "kubernetes-credentials-provider:1.262.v2670ef7ea_0c5" workflowAggregatorPlugin = "workflow-aggregator:596.v8c21c963d92d" workflowJobPlugin = "workflow-job:1400.v7fd111b_ec82f" diff --git a/test/bats/1-deploy.bats b/test/bats/1-deploy.bats index 2155f1ac7..5a6e6d383 100644 --- a/test/bats/1-deploy.bats +++ b/test/bats/1-deploy.bats @@ -33,8 +33,9 @@ diag() { --set namespace=${DETIK_CLIENT_NAMESPACE} \ --set operator.image=${OPERATOR_IMAGE} \ --set jenkins.latestPlugins=true \ - --set jenkins.image="jenkins/jenkins:2.452.1-lts" \ + --set jenkins.image="jenkins/jenkins:2.452.2-lts" \ --set jenkins.backup.makeBackupBeforePodDeletion=false \ + --set jenkins.backup.image=quay.io/jenkins-kubernetes-operator/backup-pvc:e2e-test \ --set jenkins.seedJobs[0].id=seed-job \ --set jenkins.seedJobs[0].targets="cicd/jobs/*.jenkins" \ --set jenkins.seedJobs[0].description="jobs-from-operator-repo" \ @@ -126,16 +127,18 @@ diag() { #bats test_tags=phase:helm,scenario:vanilla @test "1.10 Helm: check Jenkins seed job status and logs" { [[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly" + run try "at most 20 times every 10s to get pods named 'seed-job-agent-jenkins-' and verify that '.status.containerStatuses[?(@.name==\"jnlp\")].ready' is 'true'" + assert_success + run verify "there is 1 deployment named 'seed-job-agent-jenkins'" assert_success run verify "there is 1 pod named 'seed-job-agent-jenkins-'" assert_success - run try "at most 20 times every 10s to get pods named 'seed-job-agent-jenkins-' and verify that '.status.containerStatuses[?(@.name==\"jnlp\")].ready' is 'true'" - assert_success + sleep 5 - run ${KUBECTL} logs -l app=seed-job-agent-selector + run ${KUBECTL} logs -l app=seed-job-agent-selector --tail=20000 assert_success assert_output --partial 'INFO: Connected' @@ -150,8 +153,9 @@ diag() { --set namespace=${DETIK_CLIENT_NAMESPACE} \ --set operator.image=${OPERATOR_IMAGE} \ --set jenkins.latestPlugins=true \ - --set jenkins.image="jenkins/jenkins:2.452.1-lts" \ + --set jenkins.image="jenkins/jenkins:2.452.2-lts" \ --set jenkins.backup.makeBackupBeforePodDeletion=false \ + --set jenkins.backup.image=quay.io/jenkins-kubernetes-operator/backup-pvc:e2e-test \ chart/jenkins-operator assert_success assert ${HELM} status default diff --git a/test/bats/2-deploy-with-more-options.bats b/test/bats/2-deploy-with-more-options.bats index d4ce27d35..c685e57ee 100644 --- a/test/bats/2-deploy-with-more-options.bats +++ b/test/bats/2-deploy-with-more-options.bats @@ -29,8 +29,9 @@ setup() { --set operator.image=${OPERATOR_IMAGE} \ --set jenkins.latestPlugins=true \ --set jenkins.nodeSelector.batstest=yep \ - --set jenkins.image="jenkins/jenkins:2.452.1-lts" \ + --set jenkins.image="jenkins/jenkins:2.452.2-lts" \ --set jenkins.backup.makeBackupBeforePodDeletion=false \ + --set jenkins.backup.image=quay.io/jenkins-kubernetes-operator/backup-pvc:e2e-test \ jenkins-operator/jenkins-operator --version=$(cat VERSION.txt | sed 's/v//') assert_success assert ${HELM} status options @@ -101,8 +102,9 @@ setup() { --set operator.image=${OPERATOR_IMAGE} \ --set jenkins.latestPlugins=true \ --set jenkins.nodeSelector.batstest=yep \ - --set jenkins.image="jenkins/jenkins:2.452.1-lts" \ + --set jenkins.image="jenkins/jenkins:2.452.2-lts" \ --set jenkins.backup.makeBackupBeforePodDeletion=false \ + --set jenkins.backup.image=quay.io/jenkins-kubernetes-operator/backup-pvc:e2e-test \ chart/jenkins-operator assert_success assert ${HELM} status options diff --git a/test/bats/3-deploy-with-webhook.bats b/test/bats/3-deploy-with-webhook.bats index c832f82fe..9e6343a89 100644 --- a/test/bats/3-deploy-with-webhook.bats +++ b/test/bats/3-deploy-with-webhook.bats @@ -29,8 +29,9 @@ setup() { --set namespace=${DETIK_CLIENT_NAMESPACE} \ --set operator.image=${OPERATOR_IMAGE} \ --set jenkins.latestPlugins=true \ - --set jenkins.image="jenkins/jenkins:2.452.1-lts" \ + --set jenkins.image="jenkins/jenkins:2.452.2-lts" \ --set jenkins.backup.makeBackupBeforePodDeletion=true \ + --set jenkins.backup.image=quay.io/jenkins-kubernetes-operator/backup-pvc:e2e-test \ --set webhook.enabled=true \ jenkins-operator/jenkins-operator --version=$(cat VERSION.txt | sed 's/v//') assert_success @@ -48,7 +49,7 @@ setup() { run verify "there is 1 pod named 'webhook-jenkins-operator-'" assert_success - run try "at most 20 times every 10s to get pods named 'webhook-jenkins-operator-' and verify that '.status.containerStatuses[?(@.name==\"jenkins-operator\")].ready' is 'true'" + run try "at most 50 times every 5s to get pod named 'webhook-jenkins-operator-' and verify that '.status.containerStatuses[?(@.name==\"jenkins-operator\")].ready' is 'true'" assert_success run ${KUBECTL} rollout restart deployment webhook-jenkins-operator @@ -59,7 +60,7 @@ setup() { @test "3.4 Helm: check Jenkins Pod status" { [[ ! -f "chart/jenkins-operator/deploy.tmp" ]] && skip "Jenkins helm chart have not been deployed correctly" - run try "at most 30 times every 10s to get pods named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"jenkins-master\")].ready' is 'true'" + run try "at most 30 times every 10s to get pod named 'jenkins-jenkins' and verify that '.status.containerStatuses[?(@.name==\"jenkins-master\")].ready' is 'true'" assert_success } @@ -86,8 +87,9 @@ setup() { --set namespace=${DETIK_CLIENT_NAMESPACE} \ --set operator.image=${OPERATOR_IMAGE} \ --set jenkins.latestPlugins=true \ - --set jenkins.image="jenkins/jenkins:2.452.1-lts" \ + --set jenkins.image="jenkins/jenkins:2.452.2-lts" \ --set jenkins.backup.makeBackupBeforePodDeletion=true \ + --set jenkins.backup.image=quay.io/jenkins-kubernetes-operator/backup-pvc:e2e-test \ --set webhook.enabled=true \ chart/jenkins-operator assert_success diff --git a/test/e2e/configuration_test.go b/test/e2e/configuration_test.go index 4bef64e04..596c8d7e8 100644 --- a/test/e2e/configuration_test.go +++ b/test/e2e/configuration_test.go @@ -26,7 +26,7 @@ const e2e = "e2e" var expectedBasePluginsList = []plugins.Plugin{ plugins.Must(plugins.New("configuration-as-code:1810.v9b_c30a_249a_4c")), plugins.Must(plugins.New("git:5.2.2")), - plugins.Must(plugins.New("kubernetes:4238.v41b_3ef14a_5d8")), + plugins.Must(plugins.New("kubernetes:4246.v5a_12b_1fe120e")), plugins.Must(plugins.New("kubernetes-credentials-provider:1.262.v2670ef7ea_0c5")), plugins.Must(plugins.New("job-dsl:1.87")), plugins.Must(plugins.New("workflow-aggregator:596.v8c21c963d92d")), diff --git a/test/e2e/test_utility.go b/test/e2e/test_utility.go index b3900e41e..fd0e08266 100644 --- a/test/e2e/test_utility.go +++ b/test/e2e/test_utility.go @@ -21,7 +21,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/envtest" ) -const JenkinsTestImage = "jenkins/jenkins:2.452.1-lts" +const JenkinsTestImage = "jenkins/jenkins:2.452.2-lts" var ( Cfg *rest.Config diff --git a/test/helm/helm_test.go b/test/helm/helm_test.go index 8fec9edbc..f9e922a50 100644 --- a/test/helm/helm_test.go +++ b/test/helm/helm_test.go @@ -47,7 +47,7 @@ var _ = Describe("Jenkins Controller", func() { cmd := exec.Command("../../bin/helm", "upgrade", "jenkins", "../../chart/jenkins-operator", "--namespace", namespace.Name, "--debug", "--set-string", fmt.Sprintf("jenkins.namespace=%s", namespace.Name), - "--set-string", fmt.Sprintf("jenkins.image=%s", "jenkins/jenkins:2.452.1-lts"), + "--set-string", fmt.Sprintf("jenkins.image=%s", "jenkins/jenkins:2.452.2-lts"), "--set-string", fmt.Sprintf("operator.image=%s", *imageName), "--install") output, err := cmd.CombinedOutput() Expect(err).NotTo(HaveOccurred(), string(output))