Description of problem:
It is not possible to configure the adminAddress value in Manage Jenkins > Configure System > Jenkins Location > System Admin e-mail address, after a pod restart, the configuration gets replaced by the string:
address not configured yet <nobody@nowhere>
Workaround
It has two possible workarounds that are not acceptable in terms of suportability, one goes by replacing /opt/ directory with a PVC and editing the files (tested) and the other goes by creating an init Groovy script that sets the value up on Jenkins JVM startup with this method I found in Jenkins Javadocs (untested)
Prerequisites (if any, like setup, operators/versions):
Jenkins deployment created from template (either persistent or ephemeral storage).
Steps to Reproduce
1. Create a Jenkins deployment from a template in the OpenShift Console.
2. Set up the admin email address in Manage Jenkins > Configure System > Jenkins Location > System Admin e-mail address.
3. Delete the pod and wait for next startup.
4. Check the admin address again.
Actual results: The value gets replaced by the string address not configured yet <nobody@nowhere>
Expected results: The value adminAddress persists on restarts
Reproducibility (Always/Intermittent/Only Once): Always.
Acceptance criteria: Get the value persisting to a pod restart.
Root cause
I have been already investigating it and found out the root cause.
The Jenkins Location is created on startup by reading a tpl file.
At first, I thought it was getting the jenkins.model.JenkinsLocationConfiguration.xml.tpl in the /var/lib/jenkins/ because the Jenkins logs are reporting that replacement:
Generating jenkins.model.JenkinsLocationConfiguration.xml using (/var/lib/jenkins/jenkins.model.JenkinsLocationConfiguration.xml.tpl) ... Jenkins URL set to: https://jenkins-parodrig-devspaces.apps.sharedocp414.sbr-shift.gsslab.brq2.redhat.com/ in file: /var/lib/jenkins/jenkins.model.JenkinsLocationConfiguration.xml
But after modifying the adminAddress on that file and restarting the pod, the adminAddress was getting the same value, so did some research to confirm the hypohesis above.
The Jenkins class used to create the Location config file seems to be properly set up and does nothing weird on Jenkins startup.
Then, I looked at the OpenShift repos looking for the tpl file that is being hardcoded into OpenShift template Jenkins on startup:
This seemed the same as the one located in /var/lib/jenkins but, I already confirmed modifying it did not do a thing so, after researching in OpenShift repositories, it seems like the repo mentions the configuration files in /opt/openshift/configuration are copied to /var/lib/jenkins directory.
But it turns out it just directly replaces the current Jenkins configuration with whatever found in the /opt/openshift/configuration directory, here it points to /opt/openshift/configuration, and here it creates the final file with the file in /opt/openshift/configuration which ends in the problematic we're having, the adminAddress is not configurable.
Possible solutions
Some ideas I got that could be fixing it (although I've not tested any) are:
1. Replace the adminAddress value in the tpl file located in /opt/openshift/configuration to a variable, like it was done with the Jenkins URL (${JENKINS_ADMIN_ADDRESS}) so it can be configured as an environment variable.
2. Making the run class to check whether a `jenkins.model.JenkinsLocationConfiguration.xml.tpl` file exists in the Jenkins directory and, if it does not, copy the one from /opt/openshift/configuration. (This does not apply for ephemeral Jenkins).