Skip to content

WIP: Solve stuck pipeline when depending with dag on a manual job

Furkan Ayhan requested to merge 31264-solve-dag-manual-problem into master

What does this MR do?

Related to: #31264 (closed)

This MR aims to solve the problem that pipelines get stuck when a job needs a manual job.

The idea behind this MR is to make a manual job "blocker" if another job needs it, even the manual job is allow_failure:true.

Of course, legacy tests are failing...

Example 1

test:
  stage: test
  when: manual
  allow_failure: true
  script: exit 1

deploy:
  stage: deploy
  script: exit 0
  needs: [test]

# Current behavior:
# test: manual / stage: skipped
# deploy: created / stage: created
# pipeline: created

# Fixed behavior:
# test: manual / stage: manual
# deploy: created / stage: created
# pipeline: manual

Example 2

build:
  stage: build
  script: exit 0

test:
  stage: test
  when: manual
  allow_failure: true
  script: exit 1

deploy:
  stage: deploy
  script: exit 0
  needs: [test]

# Current behavior:
# build: success / stage: success
# test: manual / stage: skipped
# deploy: created / stage: created
# pipeline: running

# Fixed behavior:
# build: success / stage: success
# test: manual / stage: manual
# deploy: created / stage: created
# pipeline: manual

Screenshots

Screen_Shot_2020-02-14_at_21.12.13

Screen_Shot_2020-02-14_at_21.08.48

SQL Query Changes

From:

SELECT "ci_builds"."id",
       "ci_builds"."name",
       "ci_builds"."status",
       "ci_builds"."allow_failure",
       "ci_builds"."stage_idx",
       "ci_builds"."processed",
       "ci_builds"."lock_version"
FROM "ci_builds"
WHERE "ci_builds"."commit_id" = 150901085
  AND ("ci_builds"."retried" = FALSE
       OR "ci_builds"."retried" IS NULL)
ORDER BY "ci_builds"."stage_idx" ASC;

https://explain.depesz.com/s/NoOs

To:

SELECT "ci_builds"."id",
       "ci_builds"."name",
       "ci_builds"."status",
       "ci_builds"."allow_failure",
       "ci_builds"."stage_idx",
       "ci_builds"."processed",
       "ci_builds"."lock_version",

  (SELECT TRUE
   FROM "ci_build_needs"
   WHERE (ci_builds.name = ci_build_needs.name) LIMIT 1) AS has_dag_dependent
FROM "ci_builds"
WHERE "ci_builds"."commit_id" = 150901085
  AND ("ci_builds"."retried" = FALSE
       OR "ci_builds"."retried" IS NULL)
ORDER BY "ci_builds"."stage_idx" ASC;

https://explain.depesz.com/s/SVce

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Thao Yeager

Merge request reports

Loading