Skip to content

Commit fcb5852

Browse files
authored
cancel-prev-pipelines: do retry on HTTP 409 (Conflict) errors (#43648)
### Motivation The python-gitlab fix (python-gitlab/python-gitlab#2326) for 409 Resource lock retries checks `result.reason`, but GitLab sends `Conflict` (standard HTTP reason phrase) while `Resource lock` is in the response body. The check never matches, so retries never happen: ``` $ dda inv -- pipeline.auto-cancel-previous-pipelines [...] gitlab.exceptions.GitlabHttpError: 409: 409 Conflict: Resource lock ^ reason ^ response body ``` Example: https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/1262109099 ### What does this PR do? This patch adds HTTP `409` to GitLab's API retriable transient error codes as a lightweight workaround, allowing all 409 errors to be retried when `retry_transient_errors=True` (our case). ### Additional Notes Will file an issue upstream. Co-authored-by: regis.desgroppes <regis.desgroppes@datadoghq.com>
1 parent 3be6fcc commit fcb5852

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

tasks/libs/ciproviders/gitlab_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
from tasks.libs.linter.gitlab_exceptions import FailureLevel, SingleGitlabLintFailure
3434
from tasks.libs.types.types import JobDependency
3535

36+
# Patch python-gitlab to retry 409 errors because the "fix" (https://github.com/python-gitlab/python-gitlab/pull/2326)
37+
# checks `result.reason` but GitLab sends `Conflict` (HTTP standard) while `Resource lock` is in the response... body!
38+
gitlab.const.RETRYABLE_TRANSIENT_ERROR_CODES.append(409)
39+
3640
BASE_URL = "https://gitlab.ddbuild.io"
3741
CONFIG_SPECIAL_OBJECTS = {
3842
"default",

0 commit comments

Comments
 (0)