Giter Club home page Giter Club logo

Comments (7)

AaronDMarasco-VSI avatar AaronDMarasco-VSI commented on August 14, 2024 4

I tweaked https://gist.github.com/odavid/76b6874ed2b421b3eeb838aec0e9e040 and have a Jenkins job run every evening (not sandboxed) to remove locks with certain patterns:

def manager = org.jenkins.plugins.lockableresources.LockableResourcesManager.get()
def resources = manager.getResources().findAll {
    (!it.locked) && (
        it.name.startsWith("docker_rpminstalled") ||
        it.name.startsWith("docker-rpmbuild") ||
        it.name.startsWith("rpm-deploy")
    )
}   
resources.each {
    println "Removing ${it.name}"   
    manager.getResources().remove(it)
}
manager.save()

from lockable-resources-plugin.

AaronDMarasco-VSI avatar AaronDMarasco-VSI commented on August 14, 2024 1

@Constantin07 I never have, but others have warned me - see the comments on JIRA bug JENKINS-38906. As I noted there, my situation has very little chance of concurrency issues. Sorry I couldn't help more. In the second loop where the remove is being called, maybe it can be locked?

from lockable-resources-plugin.

witokondoria avatar witokondoria commented on August 14, 2024

You could setup a nightly job as described on a relevant Jira ticket or you could also apply the same resources modification as a pipeline cleanup stage. Just control the resource is already unlocked and noone is queued to use it (even then, concurrency problems might happen, treat this comment as a workaround)

from lockable-resources-plugin.

Constantin07 avatar Constantin07 commented on August 14, 2024

@AaronDMarasco-VSI Thanks for sharing. I'm getting java.util.ConcurrentModificationException exception when calling remove method with the latest Jenkins (2.164). Do you have the same ?

from lockable-resources-plugin.

Constantin07 avatar Constantin07 commented on August 14, 2024

It looks like it doesn't allow to remove items from resource list while looping through it.

I just created another list to capture what to delete and then remove them in this loop.
Thanks for reply.

from lockable-resources-plugin.

medianick avatar medianick commented on August 14, 2024

The original issue should be resolved by the ephemeral locks behavior released in https://github.com/jenkinsci/lockable-resources-plugin/releases/tag/lockable-resources-2.6

from lockable-resources-plugin.

TobiX avatar TobiX commented on August 14, 2024

Seems @medianick was faster spotting this then I was working through the open issues after the release 👍

Closing as fixed. Please reopen if there is something I didn't consider.

from lockable-resources-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.