-
Notifications
You must be signed in to change notification settings - Fork 187
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
Make ephemeral resource creation optional #751
base: master
Are you sure you want to change the base?
Make ephemeral resource creation optional #751
Conversation
@ayoubbergaoui Did this change fixed #651 ?? |
@mPokornyETM yes! it's the same need (even if I haven't seen that there have been other people who need this) |
Test Results: Non-Existing Resource/Label with Ephemeral Resources DisabledJust sharing the results of the tests I ran locally. When ephemeral resources are disabled and we specify a resource name that does not exist in the list of lockable resources, this is what happens: Similarly, when specifying a label name that does not exist, we get: |
@mPokornyETM can you review / validate the PR please? |
I mean automated tests. Sorry, I am very strict in this plugin, because it is used in many instances. It is complex and all touches are dangerous. Therefory I propose autimated tests for every code change, when possible |
035b229
to
26a3b65
Compare
- Introduce a new option "Allow Ephemeral Resources" in the plugin configuration - By default, this option is enabled (keeping previous behavior) - If disabled, jobs referencing missing resources/labels will not be launched waiting creation of the correct resources/labels. Signed-off-by: Ayoub Bergaoui <[email protected]>
26a3b65
to
2ca2c85
Compare
@mPokornyETM I just updated my commit with a set of tests that cover all my changes. So all the lines I added are covered now by a test! If you have time, can you validate the PR please? Thanks in advance, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi all,
Small change in documentation is needed (see review comment).
I feel like there are some cases that are not handled completely/correctly:
src/main/java/org/jenkins/plugins/lockableresources/LockableResourcesManager.java
private boolean proceedNextContext() {
...
List<LockableResource> requiredResourceForNextContext =
this.fromNames(nextContext.candidates, /*create un-existent resources */ true);
I don't know what this proceedNextContext method is, but the true
is ignored due to the check for the option in createResource. It feels confusing.
Same here:
public List<LockableResource> getAvailableResources(
...
available = fromNames(
getResourcesNames(requiredResources.required), /*create un-existent resources */ true);
These inconsistencies make me think that some tests are missing:
src/test/java/org/jenkins/plugins/lockableresources/LockStepWithRestartTest.java
public void chaosOnRestart() throws Throwable {
...
+ " lock('ephemeral_' + env.BUILD_NUMBER + '_' + resourceName) {\n"
+ " lock(resourceName) {semaphore semId}\n"
src/test/java/org/jenkins/plugins/lockableresources/PressureTest.java
public void pressure(final int resourcesCount) throws Exception {
...
+ " lock('resource_ephemeral_' + stageName) {\n"
// + " echo \"*** locked resource_ephemeral_\" + stageName\n"
+ " }\n"
The tests passed with current code because the ephemeral option is enabled by default.
Same idea with Configuration-as-Code: shouldn't the value of allowEphemeralResources be checked when false?
I'll let the maintainers way in on this.
Otherwise, LGTM (Disclaimer: I'm biased)
name (or label) that does not exist, the plugin creates a temporary resource | ||
for the duration of the build. | ||
- **If ephemeral resources are disabled**, referencing a resource name or label | ||
that doesn’t exist will cause the job to fail (or block) immediately, with a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to your screenshots, the job will not actually fail and always block.
Make ephemeral resource creation optional
Description
This pull request introduces a new configuration option in the Lockable Resources Plugin to control the creation of ephemeral resources. The goal is to give administrators more control over resource management by allowing them to prevent automatic creation of ephemeral resources.
Changes
allowEphemeralResources
inLockableResourcesManager
(default: true)Implementation Details
The changes span across several files:
LockableResourcesManager.java
: Core logic for the new featureLockableResourcesStruct.java
: Enhanced validation for resources and labelsLockableResourcesQueueTaskDispatcher.java
: Improved error messagesconfig.jelly
andconfig.properties
: UI changesREADME.md
: Documentation updatesTesting done
Proposed upgrade guidelines
N/A - This change is backward compatible. The feature is enabled by default, maintaining existing behavior.
Localizations
New strings added in
config.properties
:Notes
This change improves the plugin's flexibility by making ephemeral resource creation optional while maintaining backward compatibility.