如何解锁汇集池资源?

How do I unlock a concourse pool resource?

我们正在尝试使用大厅池来锁定。它锁定得很好,但是当我们尝试释放锁定时,我们收到此错误 error releasing lock: open /tmp/build/put/maleficent-env/name: no such file or directory

这就是我们池存储库中目录树的样子

.
├── README.md
└── maleficent
    ├── claimed
    │   └── maleficent-env
    └── unclaimed

这是我们的资源:

 - name: 1.12-env
   type: pool
   source:
     uri: git@github.com:<repo>
     branch: master
     pool: maleficent
     private_key: {{key}}

本次获取锁:

- put: 1.12-env params: {acquire: true}

这是我们认为应该发布的作业 yml:

- name: run-1.12-errand
plan:
- aggregate:
  - get: 1.12-env
    passed: [the-job-that-got-the-lock]
  - get: ci
  on_failure:
    put: 1.12-env
    params: {release: maleficent-env}
- task: run-errand
  file: ci/run-errand/task.yml
  params:
    BOSH_DIRECTOR_URL: {{url}}
    BOSH_CLIENT_SECRET: {{secret}}
    ENV_NAME: maleficent
  ensure:
    put: 1.12-env
    params: {release: maleficent-env}

我们注意到的一件事是,当我们获取资源时,它似乎是 Cloning into '/tmp/build/get'…,它与解锁步骤查找文件的目录不同。我们做错了什么?

我认为问题出在 release: maleficent-env 部分。

release 需要您提供锁文件在容器中的路径。

在您的情况下,请尝试将发布块更新为:

ensure: put: 1.12-env params: {release: 1.12-env}

如果可行,请告诉我。如果它不起作用,您可以尝试 fly hijack 放置容器并查看锁所在的路径。然后您将提供该路径作为 release 值。

以下job.yml将成功释放你的环境

- name: run-1.12-errand
  plan:
  - aggregate:
    - get: 1.12-env
      passed: [the-job-that-got-the-lock]
    - get: ci
    on_failure:
      put: 1.12-env
      params: {release: 1.12-env}
  - task: run-errand
    file: ci/run-errand/task.yml
    params:
      BOSH_DIRECTOR_URL: {{url}}
      BOSH_CLIENT_SECRET: {{secret}}
      ENV_NAME: maleficent
    ensure:
      put: 1.12-env
      params: {release: 1.12-env}

相关行

put: 1.12-env
params: {release: 1.12-env}

实际上指的是两个不同的事物,尽管它们都使用 1.12-envput: 1.12-env 表示 "Do a put of the resource named 1.12-env",而 release: 1.12-env 表示 "Release the environment in the file that was the output of the get: 1.12-env"

希望在下面的示例中更清楚这一点

- name: run-1.12-errand
  plan:
  - aggregate:
    - get: my-environment
      resource: 1.12-env
      passed: [the-job-that-got-the-lock]
    - get: ci
    on_failure:
      put: 1.12-env
      params: {release: my-environment}
  - task: run-errand
    file: ci/run-errand/task.yml
    params:
      BOSH_DIRECTOR_URL: {{url}}
      BOSH_CLIENT_SECRET: {{secret}}
      ENV_NAME: maleficent
    ensure:
      put: 1.12-env
      params: {release: my-environment}