Skip to content

Fix skipped status of DAG pipelines

Furkan Ayhan requested to merge 213080-fix-skipped-status-problem-of-needs into master

What does this MR do?

Related to #213080 (closed)

We have 3 ways for a job to be skipped.

1. When the job is `when: on_success` and status of previous/needs jobs is "failure".
build:
  stage: build
  script: exit 1

test:
  stage: test
  script: exit 0

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

Result:

Screen_Shot_2020-08-11_at_13.03.31

In this example, build fails, test skips, and deploy skips. Then the pipeline fails.

Why does deploy skip? That's because the dependent job test does not run at all.

This is our main rule for "needs" here.

2. When the job is `when: on_failure` and status of previous/needs jobs is "success".
build:
  stage: build
  script: exit 0

test:
  stage: test
  when: on_failure
  script: exit 0

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

Result:

Screen_Shot_2020-08-11_at_13.19.29

In this example, build succeeds, test skips, and deploy skips. Then the pipeline succeeds.

Why does deploy skip? That's because the dependent job test does not run at all. Right?

This is our main rule for "needs" here.

3. When the job is `when: manual`.

I haven't touch it in this MR because it is discussed in the other issue.


What's the ~bug in this issue?

1. Bug 1
build_1:
  stage: build
  script: exit 0

build_2:
  stage: build
  script: exit 1

test:
  stage: test
  script: exit 0

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

Result:

Screen_Shot_2020-08-11_at_13.25.24

In this example, build_1 succeeds, build_2 fails, test skips, and deploy runs and succeeds. Then the pipeline fails.

Why does deploy run? That's the ~bug in this issue. It should not run, because one of the needs (test) does not run at all.

That was our main rule for "needs".

Result after fix with this MR:

Screen_Shot_2020-08-11_at_14.37.24

2. Bug 2
build_1:
  stage: build
  script: exit 0

build_2:
  stage: build
  script: exit 0

test:
  stage: test
  script: exit 0
  when: on_failure

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

Result:

Screen_Shot_2020-08-11_at_13.28.00

In this example, build_1 succeeds, build_2 succeeds, test skips, and deploy runs and succeeds. Then the pipeline succeeds.

Why does deploy run? That's the ~bug in this issue. It should not run, because one of the needs (test) does not run at all. Right?

That was our main rule for "needs".

Result after fix with this MR:

Screen_Shot_2020-08-11_at_14.38.13


This solution is just to fix those bugs, not touch the existing behaviors.

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 Grzegorz Bizon

Merge request reports