helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

Manual change gets lost after restart Jenkins pod even with `initializeOnce: true`

Open rr-nick-tan opened this issue 2 years ago • 2 comments

Describe the bug

we have Jenkins 2.346.1 deployed in EKS with helm chart 3.11.10 i noticed the manual configurations like credentials, k8s cloud are gone after restart the Jenkins pod.

Version of Helm and Kubernetes

- Helm: 3.8.1
- Kubernetes: 1.21

Chart version

3.11.10

What happened?

the manual configurations like credentials, k8s cloud are gone after restart the Jenkins pod.

What you expected to happen?

I want the Jenkins configs remains with initializeOnce: true after the Jenkins pod restart

How to reproduce it

below is the rough relevant values.yaml:

controller:
  initializeOnce: true
  JCasC:
    defaultConfig: false
      jenkins-global-init: |
        ...
      jenkins-config: |
        ...
      jenkins-creds: |
        ...
  sidecars:
    configAutoReload:
      enabled: false
...
persistence:
  enabled: true
  ...

Anything else we need to know?

if i remove the files /var/jenkins_home/casc_configs/*.yaml, my Jenkins config remains without any change even after the pod restart.

rr-nick-tan avatar Jul 18 '22 03:07 rr-nick-tan

i'm thinking of a fix at https://github.com/jenkinsci/helm-charts/blob/jenkins-3.11.10/charts/jenkins/templates/config.yaml#L16-L21

{{- if .Values.controller.initializeOnce }}
    if [ -f {{ .Values.controller.jenkinsHome }}/initialization-completed ]; then
      echo "remove configuration as code files"
      rm -rf {{ .Values.controller.jenkinsHome }}/casc_configs/*

      echo "controller was previously initialized, refusing to re-initialize"
      exit 0
    fi
{{- end }}

rr-nick-tan avatar Jul 18 '22 03:07 rr-nick-tan