High Availability of Jenkins Masters: Can We Share the Same JENKINS_HOME?
Introduction
High availability of Jenkins masters is a persistent problem. Many of us have considered sharing the same JENKINS_HOME directory between multiple Jenkins masters, but we’ve often thought it’s not feasible. In this article, we’ll experiment with sharing the same JENKINS_HOME directory between two separate Jenkins masters to see if it’s indeed possible.
Experimental Environment
We started by creating two separate Jenkins masters using Docker Compose, respectively jenkins-a and jenkins-b. Both masters shared the same directory JENKINS_HOME. We linked the corresponding code repository at the bottom of this article.
After cloning the code repository, we entered the directory and implemented docker-compose up -d to start our laboratory environment. Once the environment was up and running, we accessed jenkins-a at http://localhost:7088 and jenkins-b at http://localhost:7089. We noticed that the interfaces were not the same, and jenkins-b displayed an error message when we tried to access the jenkins-a log with the unlock password.
Experiment 1: Create a Task
We created a task on jenkins-a and refreshed the page on jenkins-b. However, the task was not visible on jenkins-b. After restarting jenkins-b, the task appeared in the task list.
Experiment 2: Visibility of Task Results
We executed a task on jenkins-a and tried to see the results on jenkins-b. However, the results were not visible on jenkins-b. After restarting jenkins-b, we saw the recording of the task execution.
Experiment 3: Two Masters Simultaneously Performing the Same Task
We started a task on both jenkins-a and jenkins-b. However, only one of the tasks was updated with a new build number, while the other task was not. When we tried to start a separate task on jenkins-b, we saw an error message indicating that the build number already existed.
Experiment 4: Edit Task
We provided a timing task execution on jenkins-a and refreshed the page on jenkins-b. However, the task was not updated on jenkins-b. After restarting jenkins-b, we saw the updated task.
Experiment 5: What is the Result of Regular Tasks?
We timed two tasks on jenkins-a and jenkins-b and ran them simultaneously. We noticed that only one task could run and write the result to disk. From the log, we confirmed that jenkins-a performed the task before jenkins-b.
Conclusion
Our experiments confirm that when two processes share the same JENKINS_HOME directory, one process updating the contents of JENKINS_HOME is not reflected in real-time by the other process. Therefore, sharing the same JENKINS_HOME directory between multiple Jenkins masters is not feasible for high availability.
We cannot simply switch traffic from jenkins-a to jenkins-b because jenkins-b must be restarted. Our final conclusion is that sharing the same JENKINS_HOME directory between multiple Jenkins masters cannot be used for high-availability Jenkins masters.
Appendix
Our experimental environment is available at: GitHub - zacker330/jenkins-standby-experiment