concourse / pool-resource

atomically manages the state of the world (e.g. external environments)
Apache License 2.0
54 stars 36 forks source link

Releasing lock ignores metadata #38

Open rjosephwright opened 6 years ago

rjosephwright commented 6 years ago

I am trying to do an atomic update of metadata, and the update parameter does not help because I have to create or modify the metadata outside of the lock. Doing so would potentially cause the step to overwrite an update that happens after I get the lock to be able to modify it.

What I would like to do is this:

      - do:
          - put: environment_pool
            params:
              claim: environment-1

          - get: environment-1
            resource: environment_pool

          - task: update_metadata
            file: shared_tasks/update-metadata.yml
            input_mapping:
              environment: environment-1
              project_repo: my_application_repo
              build_version: my_application_version
            output_mapping:
              environment_out: environment_out
            params:
              APPLICATION_NAME: my_application

        ensure:
          put: environment_pool
          params:
            # This should(?) commit the metadata from environment_out
            release: environment_out

It seems like it would be a simple change to have UnclaimLock() take inDir as a parameter and do the mv command from there. However, I wonder if there are reasons for not doing it this way. Is there any other workaround I might use?