-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backup/Restore issue with Multibranch plugin #104
Comments
Hi @blucas How you create your BitBucket jobs? Do you run groovy scripts or Configuration as Code? Cheers |
Hi @tomaszsek We create a single job using JobDSL via the seed-job agent. The DSL is below with some sections omitted. I am aware of the reload functionality. I did issue that command, but it still didn't display the folders/jobs under my team/organization folder.
|
I suggest:
|
Hi, @blucas I apologize for late response, but I have a fix for your problem. Please put this to your groovy scripts, and everything should work.
If this will solve your problem, please close issue. Cheers |
I haven't had time to test this out, but I don't see how this will solve the problem. The nextBuildNumber, in theory, will still be reset to 1. |
Hi @blucas
Cheers |
I still don't see how this will help, not to mention it feels more like a hack than a solution (the
|
I've hit a different issue with restore and the multibranch jobs, the "Build with parameters" button no longer appears. And scanning/reindexing doesn't help like it used to. In general I've hit multiple problems with incompatibility of multibranch plugin with configuration as code and job dsl plugins. If at all possible, I would advice to reconsider using multibranch plugin at all. |
After I excluded And now I can confirm @blucas 's issue, I was able to reproduce it. #104 (comment) wont work because the jobs won't be loaded, in a best case scenario it will cause a race condition. |
On the other hand if we start to include I wonder are there any documented issues regarding job dsl plugin and job state backups... |
I've been experimenting with a custom backup/restore provider: Maybe you could just overwrite the backup script in similar fashion like I did in the above example? Also I've talked about this issue with @tomaszsek and he came up with this nice workaround of trying to detect if there is the This would limit any problems with stale state to the Multibranch Jobs (that are already problematic) and not cause any additional damage to other types of jobs. |
I've got it to work:
I also have a job like this, just in case I need to re-index all:
|
To wait for scan to complete
https://javadoc.jenkins-ci.org/hudson/model/AbstractProject.html#scheduleBuild2-int- |
thank you @llibicpep for a hint re-indexing pipeline after those changes: import jenkins.branch.*
pipeline {
agent none // master
stages {
stage('Reindex') {
steps {
script {
for (project in Jenkins.instance.getAllItems(jenkins.branch.MultiBranchProject.class)) {
stage(project.getName()) {
def scan = project.scheduleBuild2(0 /* quiet period */) // force reindexing
scan.getFuture().get()
project.doReload()
}
}
}
}
}
}
} also you need script approvals for:
|
As reported in #210, when restoring a multibranch backup, the build info is missing and Jenkins job "run" silently fails with an exception in logs:
The Further investigation on how we can work around multi-branch issues with the operator itself is necessary. |
The #211 as is right now has implications for every job not only multi-branch and it breaks immutability in some ways we cannot easily predict. TBH we won't probably have enough bandwidth to make a proper PR for this backups issue with multi-branch before Jenkins World, so if there is some bash haxor out there a hint on how to approach it would be nice :) |
Hi, @blucas did you solved your problem? |
Have been trying to give this a shot. Builds not getting scheduled after every deploy (until I push "build now" to get the current build up past the last history build number) is kind of a deal breaker- I can't imagine there is anyone actually NOT using multibranch builds with Jenkins? Is there a workaround that I am just missing? |
Fixed in |
This issue should be re-opened. this 'fix' does not work for me for the most basic example of a multi-branch pipeline job. in specific the job doesn't show up after restoring. furthermore the assumption the fix is based on is that multi-branch pipeline jobs are the only thing that has a top-level config.xml. This is not the case at all. folders and org folders fall into this category as well and this approach will exclude backup and restore of these things as well. |
I have a work-around:
this approach has problems around credentials, and needing a (user initiated) reload after the Jenkins pod is restored. I would much rather use a more reliable mechanism external to Jenkins for backup and restore. My thoughts here are to look at the source of thinbackup and copy the method of backup directly into the backup script you guys have started. |
I am not sure what the difference is, but this did fix it for us using GitHub organization folders. We have had quite a bit of pain from the persistence options in this syst, but our jobs do come back after restore now. |
i came to a realization last night that Jenkins operator on purpose does NOT restore the job configs, rather it depends on having Jenkins seed jobs in place to fully restore all the jobs configurations back to the original state. i believe this is what i'm missing from my setup. Is this a correct thought? is everyone else utilizing seed jobs on startup to fully restore job configs? |
Yes, this system is designed to provide basically immutable configuration- the whole thing is reverted to the state from the CRD on every restart. I create my jobs with config like this (tons of detail left out!)
Everything is in my CRD. Secrets, org-folder jobs, RBAC, ldap, global libraries... everything. Whether that is a good thing I am still open on- getting the manifests working right is frequently painful, and it means your instance will just not start up after a reboot some percentage of the time when some plugin that you didn't have pinned to a specific version breaks. But having the manifest get out of sync isn't the best either... |
okay, then your backup / restore pod is really only meant to restore the job history for example. which is why you exclude all job config.xml files. it is mean to be re-seeded from scripts called from operator after a new pod is created. i think I missed this point in the architecture description of how this is supposed to work. I am pretty new to the operational side of Jenkins, but it might help to spell this point out a little better in the documentation website for how all of this is meant to work. Thanks for the clarification! |
I'm using Jenkins Operator v0.2.0 and backup-pvc v0.0.6
When restoring a Bitbucket Team job (Organization Folder) using the
cloudbees-bitbucket-branch-source:2.4.6
plugin, the operator fails to "fully" restore the folder and jobs. After the restore completes and when you navigate to the Bitbucket Team job in the Jenkins UI, it displays as if it has yet to scan the Bitbucket Team and all of that team's repositories / branches.I checked the backup file. It does contain the builds for each repository/branch and did successfully restore them on disk. The only way to get the builds to display after restore is to issue a new "Scan Organization Folder Now" operation on the Organization Folder. But this creates further issues as that scan assumes it's the first and so resets
nextBuildNumber
to1
.The issue is that the plugin or framework expects that the job's
config.xml
file is also restored. If I remove--exclude jobs/*/config.xml
from backup.sh and trigger a restore, then everything displays as expected in the UI. Jenkins knows what thenextBuildNumber
should be for all jobs under the Organization Folder.I would like to suggest that exclusion of the
config.xml
file become a configurable setting. For example add an env_varEXCLUDE_CONFIG_XML=true|false
whereby the default istrue
and one can disable that functionality on thebackup
container by providing afalse
value when configuring the container's environment variablesThe text was updated successfully, but these errors were encountered: