Skip to content
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

Fix reloading configuration from disk #545

Merged
merged 4 commits into from
Nov 27, 2023
Merged

Conversation

Vlatombe
Copy link
Member

@Vlatombe Vlatombe commented Nov 23, 2023

This makes the load() method work properly when called after startup, in case of a reload configuration from disk for example.

Functionally, the reconfigure() method needs to be called implicitly when calling load(), because it updates a snapshot state that is used by running builds. If the persisted state has changed on disk then loaded, the snapshot needs to be updated accordingly.

Without this patch, the ScriptApproval state is correct, but anything that has changed since last time it was loaded is not reflected on running builds.

Testing done

Submitter checklist

This makes the `load()` method work properly when called after startup, in
case of a reload configuration from disk for example.

Functionally, the `reconfigure()` method needs to be called implicitly when calling
`load()`, because it updates a snapshot state that is used by running builds.
If the persisted state has changed on disk then loaded, the snapshot needs to be updated accordingly.

Without this patch, the `ScriptApproval` state is correct, but anything
that has changed since last time it was loaded is not reflected on
running builds.
@Vlatombe Vlatombe requested a review from a team as a code owner November 23, 2023 08:07
@jglick jglick added the bug label Nov 27, 2023
Comment on lines +190 to +192
r.assertLogNotContains("org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: "
+ "Scripts not permitted to use staticMethod jenkins.model.Jenkins getInstance",
r.assertBuildStatus(Result.SUCCESS, p.scheduleBuild2(0).get()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps besides the point since you approved the whole script anyway, and if you had not, you would also get an error on method jenkins.model.Jenkins getLabels, but OK.

@jglick jglick merged commit 99333c0 into jenkinsci:master Nov 27, 2023
14 checks passed
@timja
Copy link
Member

timja commented Dec 16, 2023

I suspect this has caused jenkinsci/acceptance-test-harness#1444

(valid issues not just a test issue)

Comment on lines +539 to +540
LOG.log(Level.FINE, "Reconfiguring ScriptApproval after loading configuration from disk");
reconfigure();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is what is causing issues with the tests, most specifically with the hot plugin load.

@jglick jglick mentioned this pull request Dec 19, 2023
@Vlatombe Vlatombe deleted the fix-load branch December 20, 2023 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants