有没有办法锁定 Concourse git-资源?
Is there a way to put a lock on Concourse git-resource?
我在 Concourse 中设置了管道,其中包含一些构建 Docker 图像的作业。
构建完成后,我将图像标签推送到 git 存储库。
问题是当构建同时结束时,一个作业推送到 git,而另一个作业刚刚拉出,当第二个作业尝试推送到 git 时出现错误。
error: failed to push some refs to 'git@github.com:*****/*****'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
那么有什么办法可以防止并发推送吗?
到目前为止,我已经尝试将 serial
和 serial_groups
应用于工作。
它有帮助,但所有的工作都排队等候,因为我们有很多构建。
我希望作业 运行 并发并在对 git 执行操作之前暂停,如果其他作业锁定了它。
resources:
- name: backend-helm-repo
type: git
source:
branch: master
paths:
- helm
uri: git@github.com:******/******
-...
jobs:
-...
- name: some-hidden-api-build
serial: true
serial_groups:
- build-alone
plan:
- get: some-hidden-api-repo
trigger: true
- get: golang
- task: build-image
file: somefile.yaml
- put: some-hidden-api-image
- get: backend-helm-repo
- task: update-helm-tag
config:
platform: linux
image_resource:
type: registry-image
source:
repository: mikefarah/yq
tag: latest
run:
path: /bin/sh
args:
- -xce
- "file manipulations && git commit"
inputs:
- name: some-hidden-api-repo
- name: backend-helm-repo
outputs:
- name: backend-helm-tag-bump
- put: backend-helm-repo
params:
repository: backend-helm-tag-bump
- put: some-hidden-api-status
params:
commit: some-hidden-api-repo
state: success
- name: some-other-build
serial: true
serial_groups:
- build-alone
plan:
- get: some-other-repo
trigger: true
- get: golang
- task: build-image
file: somefile.yaml
- put: some-other-image
- get: backend-helm-repo
- task: update-helm-tag
config:
platform: linux
image_resource:
type: registry-image
source:
repository: mikefarah/yq
tag: latest
run:
path: /bin/sh
args:
- -xce
- "file manipulations && git commit"
inputs:
- name: some-other-repo
- name: backend-helm-repo
outputs:
- name: backend-helm-tag-bump
- put: backend-helm-repo
params:
repository: backend-helm-tag-bump
- put: some-other-status
params:
commit: some-other-repo
state: success
-...
因此,如果作业同时完成映像构建并git 并行提交,则第一个推送速度比第二个快,第二个会中断。
有人可以帮忙吗?
请注意,您的描述过于模糊,无法给出详细的答案。
I expect jobs to concurrently and stop before pushing to git if some other job have a lock on git.
这还不够,如果他们在推送之前停止,他们已经在引用 git 提交,当其他作业释放锁时,提交将变得陈旧:-)
在克隆 git 存储库之前,作业必须停止,等待锁,所以在最开始。
所有这些都是我的猜测,因为再次不清楚你想做什么,对于发布 as-small-as-possible 管道图像和 as-small-as-possible 配置代码的这类问题很有帮助。
你可以考虑https://github.com/concourse/pool-resource作为锁定机制。
我在 Concourse 中设置了管道,其中包含一些构建 Docker 图像的作业。 构建完成后,我将图像标签推送到 git 存储库。 问题是当构建同时结束时,一个作业推送到 git,而另一个作业刚刚拉出,当第二个作业尝试推送到 git 时出现错误。
error: failed to push some refs to 'git@github.com:*****/*****'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
那么有什么办法可以防止并发推送吗?
到目前为止,我已经尝试将 serial
和 serial_groups
应用于工作。
它有帮助,但所有的工作都排队等候,因为我们有很多构建。
我希望作业 运行 并发并在对 git 执行操作之前暂停,如果其他作业锁定了它。
resources:
- name: backend-helm-repo
type: git
source:
branch: master
paths:
- helm
uri: git@github.com:******/******
-...
jobs:
-...
- name: some-hidden-api-build
serial: true
serial_groups:
- build-alone
plan:
- get: some-hidden-api-repo
trigger: true
- get: golang
- task: build-image
file: somefile.yaml
- put: some-hidden-api-image
- get: backend-helm-repo
- task: update-helm-tag
config:
platform: linux
image_resource:
type: registry-image
source:
repository: mikefarah/yq
tag: latest
run:
path: /bin/sh
args:
- -xce
- "file manipulations && git commit"
inputs:
- name: some-hidden-api-repo
- name: backend-helm-repo
outputs:
- name: backend-helm-tag-bump
- put: backend-helm-repo
params:
repository: backend-helm-tag-bump
- put: some-hidden-api-status
params:
commit: some-hidden-api-repo
state: success
- name: some-other-build
serial: true
serial_groups:
- build-alone
plan:
- get: some-other-repo
trigger: true
- get: golang
- task: build-image
file: somefile.yaml
- put: some-other-image
- get: backend-helm-repo
- task: update-helm-tag
config:
platform: linux
image_resource:
type: registry-image
source:
repository: mikefarah/yq
tag: latest
run:
path: /bin/sh
args:
- -xce
- "file manipulations && git commit"
inputs:
- name: some-other-repo
- name: backend-helm-repo
outputs:
- name: backend-helm-tag-bump
- put: backend-helm-repo
params:
repository: backend-helm-tag-bump
- put: some-other-status
params:
commit: some-other-repo
state: success
-...
因此,如果作业同时完成映像构建并git 并行提交,则第一个推送速度比第二个快,第二个会中断。
有人可以帮忙吗?
请注意,您的描述过于模糊,无法给出详细的答案。
I expect jobs to concurrently and stop before pushing to git if some other job have a lock on git.
这还不够,如果他们在推送之前停止,他们已经在引用 git 提交,当其他作业释放锁时,提交将变得陈旧:-)
在克隆 git 存储库之前,作业必须停止,等待锁,所以在最开始。
所有这些都是我的猜测,因为再次不清楚你想做什么,对于发布 as-small-as-possible 管道图像和 as-small-as-possible 配置代码的这类问题很有帮助。
你可以考虑https://github.com/concourse/pool-resource作为锁定机制。