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

Empty ressource is not allowed anymore #619

Open
ylacaute opened this issue Jan 22, 2024 · 11 comments
Open

Empty ressource is not allowed anymore #619

ylacaute opened this issue Jan 22, 2024 · 11 comments
Labels

Comments

@ylacaute
Copy link

ylacaute commented Jan 22, 2024

Jenkins and plugins versions report

Environment
Jenkins: 2.426.2
OS: Linux - 3.10.0-1160.80.1.el7.x86_64
Java: 17.0.9 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
---
extended-choice-parameter:376.v2e02857547b_a_

(not all plugins are listed for security reasons)

What Operating System are you using (both controller, and any agents involved in the problem)?

This is not the problem

Reproduction steps

In a declarative pipeline, use lock resource with an empty string (to say 'do not lock') :

options {
 lock resource: ""
}

Alternative : use null.

Expected Results

Should be valid and lock nothing.

Actual Results

Generate an error as the label must not be empty :

Also:   org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 14a16d57-dc65-4219-9880-8c910ae45d91
java.lang.IllegalArgumentException: Either resource label or resource name must be specified.
  at org.jenkins.plugins.lockableresources.LockStepResource.validate(LockStepResource.java:108)

Anything else?

We cannot set empty, we cannot set null, so in a declarative pipeline we cannot choose dynamically if we want a lock or not.
We should be able to define the lock with a function depending on the context :

option {
  lock resource: getLockResourceName(...)
}

Was working with version 1102.vde5663d777cf : we could set an empty string to not lock at all.

Are you interested in contributing a fix?

Maybe

@ylacaute ylacaute added the bug label Jan 22, 2024
@mPokornyETM
Copy link
Contributor

Ok, I see. That make sense.

@mPokornyETM mPokornyETM added this to the Feature committed milestone Jan 22, 2024
@jepio
Copy link

jepio commented Jan 23, 2024

We have a similar usecase that used to work but doesn't any more.

def extra = []
if (params.platform == "openstack") {
    extra = [[resource: "openstack_cluster"]]
} else if ....
    // more branches
}

lock(extra: extra, variable: "RESOURCE") {
    sh '''./job.sh "${platform}"'''
}

we use extra because some platforms don't lock anything, some use [[label: ..., quantity: ...], others use [[resource: ...]].

@ZyanKLee
Copy link

Seems like this issue has been introduced by d4e51cc#diff-643ee7a8c516946248ee3aaa251d25acd9b0fa035a45e654be76eecda7906403R104-R106
So a downgrade to version 1185.v0c528656ce04 could solve the issue in the meantime.

@jwillemsen
Copy link
Contributor

Similar to #615

@johannesacco
Copy link

A workaround is to add a random string if the list is empty. E.g.

def extra = [[resource: UUID.randomUUID().toString()]]

@mPokornyETM
Copy link
Contributor

As there is applicable work arround, I will close this issue now. @johannesacco thx

@mPokornyETM mPokornyETM closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2024
@jwillemsen
Copy link
Contributor

Seems to work as workaround, don't like all Ephemeral resources created now, when a job normally asks for a resource which isn't there it should block to my idea. At the moment someone adds support for an empty extra block to indicate that no resource should be locked, it would be good to also have a setting to prevent the creation of ephemeral resources

@proguy23
Copy link

Please fix this. The author went on an ego trip and pushed this commit without any review, and now we see multiple tickets asking why this feature was broken without providing any alternative solution. The example in the issue is obviously simplistic to push a narrative without understanding why devs are using it. This needs to be fixed for labels.

@jwillemsen
Copy link
Contributor

Introduced by #579

@mPokornyETM
Copy link
Contributor

Seems to work as workaround, don't like all Ephemeral resources created now, when a job normally asks for a resource which isn't there it should block to my idea. At the moment someone adds support for an empty extra block to indicate that no resource should be locked, it would be good to also have a setting to prevent the creation of ephemeral resources

Ephemeral resources are really bad think. So I will reopen it, and hopefully somebody will take time and fix it in proeper way.

@mPokornyETM
Copy link
Contributor

Please fix this. The author went on an ego trip and pushed this commit without any review, and now we see multiple tickets asking why this feature was broken without providing any alternative solution. The example in the issue is obviously simplistic to push a narrative without understanding why devs are using it. This needs to be fixed for labels.

FYI: When I provide PR, I wat for longer time for review (~ fe days) In the past 2 yers I became only few reviews, because no body interseted. Therefor pls, do not use wording like "The author went on an ego trip" Without my ego trip, you will still have all the concurent modification excpetions .... . When you want, you can participate on this plugin too. Provide a fix, and I will review the changes as well. All kind of contributions are welcome. But pls be respectfull. thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants