Giter Site home page Giter Site logo

locker-resource's Introduction

What is Locker?

Locker is a simple web application for claiming and releasing locks. It contains a Concourse resource to help make locking various tasks and jobs in Concourse pipelines easier to manage.

This project is similar to the pool-resource, with a few key differences:

  1. It uses a webserver with file-backed persistence for the locks. This isn't terribly scalable, but since it's handling locks for Concourse pipelines, it isn't anticipated to have an enormous traffic load.
  2. Pools + lock-names do not need to be pre-defined in order to be used

How do I use it?

  1. Deploy locker along side your Concourse database node via the locker-boshrelease
  2. Use the locker-resource in your Concourse pipelines (see below for resource configuration details).

locker-resource

Source Configuration

  • locker_uri required - specifies the base URI of the locker API
  • username - specifies the username to use when authenticating to the locker API
  • password - specifies the password to use when authenticating to the locker API
  • ca_cert - specifies a PEM-encoded CA certificate for validating SSL while communicating with the locker API
  • skip_ssl_validation - determines if ssl validation is ignored while communicating with the locker API
  • lock_name - specifies the name of the lock to be acquired (either this or bosh_lock must be specified)
  • bosh_lock - a base URL to a BOSH director. locker-resource will lookup the director's name, and use that as the lock name (either this or bosh_lock must be specified)

in - Get status of a Pool

Retrieves the current status of the lock pool, creates a lock file with the name of who owns the lock currently. If no one owns the lock, the file will be empty.

Configuration

None.

out - Lock/Unlock a Pool

Allows you to lock or unlock a lock. If the pool is currently locked, even by the item requesting the lock, it will loop indefinitely, until the lock is released. Unlocking is only allowed when the key matches the key that has currently locked the lock.

  • key required - specifies the name of the item that is attempting to claim the lock.
  • lock_by - specifies the item requesting to lock/unlock the lock with the key
  • lock_op required - specifies whether you want to lock or unlock the pool

Example of exclusive locking between two jobs

resources:
- name: myLock
  type: locker
  source:
    locker_uri: http://10.10.10.10:8910
    username: test
    password: test
    lock_name: myLock

jobs:
- name: exclusive-job-1
  public: true
  serial: true
  plan:
  - put: myLock
    params:
      key: exclusive-job-1
      lock_op: lock
  - task: do_stuff
    .....
  - put: myLock
    params:
      key: exclusive-job-1
      lock_op: unlock
- name: exclusive-job-2
  public: true
  serial: true
  plan:
  - put: myLock
    params:
      key: exclusive-job-2
      lock_op: lock
  - task: do_stuff
    .....
  - put: myLock
    params:
      key: exclusive-job-2
      lock_op: unlock

Example of shared locking between some jobs that cannot co-exist with another

resources:
- name: myLock
  type: locker
  source:
    locker_uri: http://10.10.10.10:8910
    username: test
    password: test
    lock_name: myLock

jobs:
# coexisting-1 can run if coexisting-2 is running, but not exclusive-job
- name: coexisting-1
  public: true
  serial: true
  plan:
  - put: myLock
    params:
      key: can-coexist
      locked_by: coexisting-1
      lock_op: lock
  - task: do_stuf
    ...
  - put: myLock
    params:
      key: can-coexist
      locked_by: coexisting-1
      lock_op: unlock
# coexisting-2 can run if coexisting-1 is running, but not exclusive-job
- name: coexisting-2
  public: true
  serial: true
  plan:
  - put: myLock
    params:
      key: can-coexist
      locked_by: coexisting-2
      lock_op: lock
  - task: do_stuf
    ...
  - put: myLock
    params:
      key: can-coexist
      locked_by: coexisting-2
      lock_op: unlock
# exclusive-job *cannot* run if coexisting-1 or coexisting-2 are running
- name: exclusive-job
  public: true
  serial: true
  plan:
  - put: myLock
    params:
      key: cannot-coexist
      locked_by: exclusive-job
      lock_op: lock
  - task: do_stuff
    ...
  - put: myLock
    params:
      key: cannot-coexist
      locked_by: exclusive-job
      lock_op: unlock

locker-resource's People

Contributors

geofffranks avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

odidev

locker-resource's Issues

Require Linux/ARM64 docker image for cfcommunity/locker-resource

Hi Team,

I have been working on building cfcommunity/locker-resource images for both AMD64 and ARM64 platforms and facing issues. Hence, I have modified the dockerfile to resolve the issues for the amd64 platform and made it compatible with arm64 platform as well.

Successfully built and tested the nguoianphu/docker-filebeat image over AMD64 and ARM64 platforms after the changes.

May I know the release process of docker images?

Modified Dockerfile:odidev@884151b

Do you have any plans for releasing arm64 images?

It will be very helpful if an arm64 image is available. If interested, I will raise a PR.

locker_uri problem with port specification

Problem

when i try to specify the locker resource in the pipeline.yml like this:

resources:
- name: myLock
  type: locker
  source:
    locker_uri: http://10.10.10.10:8910
    username: test
    password: test
    lock_name: myLock

i receive this error message:
parse error: Invalid numeric literal at line 2, column 0

What causes the bug?

The yaml is invalid cause of the ":" inside the locker_uri string.
I already tried to specify it like this:

  • locker_uri: "http://10.10.10.10:8910"
  • locker_uri: 'http://10.10.10.10:8910'

Neither of these strings worked.

Suggestion

Introduction of a port source variable for the resource rather than passing the port number along with the locker_uri string

best,

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.