From 60b8ee56debf840f0f6bee45081f23eacd7d2068 Mon Sep 17 00:00:00 2001
From: Luigi Operoso <40476330+brokenpip3@users.noreply.github.com>
Date: Thu, 12 Jan 2023 17:29:30 +0100
Subject: [PATCH] fix(operator): Attempt to fix all the major issues present
atm against the newest jenkins lts version (#784)
* fix(seed): fix #742, workaround #698
Original fix proposal: https://github.com/jenkinsci/kubernetes-operator/issues/742#issuecomment-1304398590
* fix(install-plugin.sh): fix #758, #739
* the fix was original attempted here:
https://github.com/jenkinsci/kubernetes-operator/pull/764 but was not
working correctly due to 2-3 additional changes which needed to be
done
* removed the openshift check because the env is not mention anywhere
and also the new jenkins-plugin-cli does not a specific command for
openshift. Finally this does not make any sense in general, the only
problem in ocp will be the user id that will be mapped to a random uid
but that's another story. The command to install the plugins should
remain the same across different k8s flavours.
* fix(doc/test): fix /usr/bin/tini in any doc and validation
* fix(jenkins): remove AdminWhitelistRule to avoid jvm stack trace, see: https://www.jenkins.io/doc/book/security/controller-isolation/jep-235/#api-compatibility
* fix(seed): fix seed img built on a previous jvm, fix #761
* fix(plugin): update the base plugin to work with the newest version of
jenkins:lts
* fix(run): fix #778
* fix(backup): add a trap to remove the tmp dir if the tar fail, also fix: #770
* test(chart): update chart values for testing, will revert before merge
* fix(configmap): leftover
* fix(tests): fix seed job test
* fix(e2e)
* fix(e2e): helm
* fix(operator): update the temporary img to reflect latests changes
* Fix Helm e2e tests
* add trap in case of unwanted exit and make shellcheck happy
* chore(plugin): update git ver to 5.0.0
* fix(backup): always force delete the backup directory
* chore(operator): update the temporary img to reflect latest changes
* chore(jenkins): upgrade jenkins latest lts
---
backup/pvc/bin/backup.sh | 7 +++--
backup/pvc/bin/run.sh | 3 +-
chart/jenkins-operator/crds/jenkins-crd.yaml | 2 +-
chart/jenkins-operator/values.yaml | 31 ++++++++++---------
config.minikube.env | 4 +--
config/crd/bases/jenkins.io_jenkins.yaml | 2 +-
docs/docs/developer-guide/index.html | 4 +--
.../v0.1.x/configuration/index.html | 8 ++---
docs/docs/getting-started/v0.1.x/index.xml | 8 ++---
docs/docs/index.xml | 8 ++---
pkg/client/jenkins.go | 4 +--
.../resources/base_configuration_configmap.go | 30 +++++-------------
pkg/configuration/base/resources/pod.go | 2 +-
.../base/resources/scripts_configmap.go | 21 +++++--------
pkg/configuration/base/validate_test.go | 4 +--
pkg/configuration/user/seedjobs/seedjobs.go | 2 +-
.../user/seedjobs/seedjobs_test.go | 2 +-
pkg/plugins/base_plugins.go | 14 ++++-----
test/e2e/configuration_test.go | 14 ++++-----
test/e2e/jenkins_test.go | 8 ++---
test/e2e/restart_test.go | 2 +-
test/e2e/test_utility.go | 10 +++---
test/e2e/wait.go | 2 +-
test/helm/helm_test.go | 14 ++++-----
.../content/en/docs/Developer Guide/_index.md | 2 +-
.../Getting Started/v0.1.x/configuration.md | 8 ++---
26 files changed, 99 insertions(+), 117 deletions(-)
diff --git a/backup/pvc/bin/backup.sh b/backup/pvc/bin/backup.sh
index c24d2ad1..ff9c9f63 100644
--- a/backup/pvc/bin/backup.sh
+++ b/backup/pvc/bin/backup.sh
@@ -6,6 +6,7 @@ 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;
BACKUP_TMP_DIR=$(mktemp -d)
+trap "test -d "${BACKUP_TMP_DIR}" && rm -fr "${BACKUP_TMP_DIR}"" EXIT ERR SIGINT SIGTERM
backup_number=$1
echo "Running backup"
@@ -14,10 +15,10 @@ echo "Running backup"
# config.xml in child directores is state that should. For example-
# branches/myorg/branches/myrepo/branches/master/config.xml should be retained while
# branches/myorg/config.xml should not
-tar -C ${JENKINS_HOME} -czf "${BACKUP_TMP_DIR}/${backup_number}.tar.gz" --exclude jobs/*/workspace* --no-wildcards-match-slash --anchored --exclude jobs/*/config.xml -c jobs && \
-mv ${BACKUP_TMP_DIR}/${backup_number}.tar.gz ${BACKUP_DIR}/${backup_number}.tar.gz
+tar -C "${JENKINS_HOME}" -czf "${BACKUP_TMP_DIR}/${backup_number}.tar.gz" --exclude jobs/*/workspace* --no-wildcards-match-slash --anchored --exclude jobs/*/config.xml -c jobs && \
+mv "${BACKUP_TMP_DIR}/${backup_number}.tar.gz" "${BACKUP_DIR}/${backup_number}.tar.gz"
-rm -r ${BACKUP_TMP_DIR}
+rm -rf "${BACKUP_TMP_DIR}"
[[ ! -s ${BACKUP_DIR}/${backup_number}.tar.gz ]] && echo "backup file '${BACKUP_DIR}/${backup_number}.tar.gz' is empty" && exit 1;
diff --git a/backup/pvc/bin/run.sh b/backup/pvc/bin/run.sh
index e4649fb3..8d83d111 100644
--- a/backup/pvc/bin/run.sh
+++ b/backup/pvc/bin/run.sh
@@ -10,6 +10,7 @@ do
sleep 10
if [[ ! -z "${BACKUP_COUNT}" ]]; then
echo "Trimming to only ${BACKUP_COUNT} recent backups in preparation for new backup"
- find ${BACKUP_DIR} -name '*.tar.gz' -exec basename {} \; | sort -gr | tail -n +$((BACKUP_COUNT +1)) | xargs -I '{}' rm ${BACKUP_DIR}/'{}'
+ #TODO: add the list of exceding backup before delete
+ find ${BACKUP_DIR} -maxdepth 1 -name '*.tar.gz' -exec basename {} \; | sort -gr | tail -n +$((BACKUP_COUNT +1)) | xargs -I '{}' rm ${BACKUP_DIR}/'{}'
fi
done
diff --git a/chart/jenkins-operator/crds/jenkins-crd.yaml b/chart/jenkins-operator/crds/jenkins-crd.yaml
index 0567683e..8823ac22 100644
--- a/chart/jenkins-operator/crds/jenkins-crd.yaml
+++ b/chart/jenkins-operator/crds/jenkins-crd.yaml
@@ -3120,7 +3120,7 @@ spec:
type: array
seedJobAgentImage:
type: string
- description: 'SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:4.9-1 will be used.'
+ description: 'SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:4.10-3 will be used.'
seedJobs:
description: 'SeedJobs defines list of Jenkins Seed Job configurations
More info: https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration#configure-seed-jobs-and-pipelines'
diff --git a/chart/jenkins-operator/values.yaml b/chart/jenkins-operator/values.yaml
index 7d473db2..08373afb 100644
--- a/chart/jenkins-operator/values.yaml
+++ b/chart/jenkins-operator/values.yaml
@@ -33,7 +33,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.319.3-lts
+ image: jenkins/jenkins:2.375.2-lts
# env contains jenkins container environment variables
env: []
@@ -86,20 +86,21 @@ jenkins:
# Example:
#
# basePlugins:
- # - name: configuration-as-code
- # version: "1346.ve8cfa_3473c94"
- # - name: git
- # version: 4.11.3
- # - name: job-dsl
- # version: "1.78.1"
# - name: kubernetes
- # version: 1.31.3
- # - name: kubernetes-credentials-provider
- # version: 0.20
- # - name: workflow-aggregator
- # version: "2.6"
+ # version: 3802.vb_b_600831fcb_3
# - name: workflow-job
- # version: "1145.v7f2433caa07f"
+ # version: 1254.v3f64639b_11dd
+ # - name: workflow-aggregator
+ # version: 590.v6a_d052e5a_a_b_5
+ # - name: git
+ # version: 5.0.0
+ # - name: job-dsl
+ # version: "1.81"
+ # - name: configuration-as-code
+ # version: 1569.vb_72405b_80249
+ # - name: kubernetes-credentials-provider
+ # version: 1.208.v128ee9800c04
+
basePlugins: []
# plugins are plugins required by the user
@@ -125,7 +126,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:4.9-1 will be used.
+ # SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:4.10-3 will be used.
seedJobAgentImage: ""
# Resource limit/request for Jenkins
@@ -284,7 +285,7 @@ operator:
replicaCount: 1
# image is the name (and tag) of the Jenkins Operator image
- image: virtuslab/jenkins-operator:v0.7.1
+ image: quay.io/brokenpip3/jenkins-kubernetes-operator:a86b738a
# imagePullPolicy defines policy for pulling images
imagePullPolicy: IfNotPresent
diff --git a/config.minikube.env b/config.minikube.env
index aab3d5b2..944978fc 100644
--- a/config.minikube.env
+++ b/config.minikube.env
@@ -1,8 +1,8 @@
KUBERNETES_PROVIDER=minikube
-MINIKUBE_KUBERNETES_VERSION=v1.21.1
+MINIKUBE_KUBERNETES_VERSION=v1.24.8
MINIKUBE_DRIVER=virtualbox
-MINIKUBE_VERSION=1.21.0
+MINIKUBE_VERSION=1.28.0
KUBECTL_CONTEXT=minikube
JENKINS_API_HOSTNAME_COMMAND=bin/minikube ip
diff --git a/config/crd/bases/jenkins.io_jenkins.yaml b/config/crd/bases/jenkins.io_jenkins.yaml
index 76e1c0e7..e94f6036 100644
--- a/config/crd/bases/jenkins.io_jenkins.yaml
+++ b/config/crd/bases/jenkins.io_jenkins.yaml
@@ -3120,7 +3120,7 @@ spec:
type: array
seedJobAgentImage:
type: string
- description: SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:4.9-1 will be used.
+ description: SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:4.10-3 will be used.
seedJobs:
description: 'SeedJobs defines list of Jenkins Seed Job configurations
More info: https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration#configure-seed-jobs-and-pipelines'
diff --git a/docs/docs/developer-guide/index.html b/docs/docs/developer-guide/index.html
index aee8313b..4de2275e 100644
--- a/docs/docs/developer-guide/index.html
+++ b/docs/docs/developer-guide/index.html
@@ -1043,7 +1043,7 @@ items:
- command:
- bash
- -c
- - /var/jenkins/scripts/init.sh && exec /sbin/tini -s -- /usr/local/bin/jenkins.sh
+ - /var/jenkins/scripts/init.sh && exec /usr/bin/tini -s -- /usr/local/bin/jenkins.sh
env:
- name: JAVA_OPTS
value: -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
@@ -1408,4 +1408,4 @@ make deploy-webhook