`needs` and `when: manual` used in the same pipeline cause pipeline status to remain Running

Summary

Any CI pipleine configured with needs and when: manual intermixed may enter into a permanent Running state on failure or completion. All jobs will be finished, failed, or not started, but the Pipeline status will remain Running.

The issue always occurs when also hitting #31526 (closed) intermixed with when: manual.

Note in the below screenshots that no jobs are actually running

Steps to reproduce

Create a pipeline like the below, with several uses of needs and when: manual. Specifically make a needs job need a when: manual job Build it to fail on purpose. It will never enter Failed state.

Create a pipeline like the below. When the job finishes cleanly, but without running the manual steps, it will never enter the passed state.

test:airflow:
  script:
    - do the thing

build:airflow:
  script:
    - do the thing
  needs: ['test:airflow']

pillar:staging:airflow:
  script:
    - do the thing
  needs: ['build:airflow']

deploy:staging:airflow:
  script:
    - do the thing
  needs: ['pillar:staging:airflow']

pillar:production:airflow:
  script:
    - do the thing
  when: manual

deploy:production:airflow:
  script:
    - do the thing
  needs: ['pillar:production:airflow']

What is the current bug behavior?

Pipeline never enters failed or passed state

What is the expected correct behavior?

Pipeline enters failed or passed state

Relevant logs and/or screenshots

Completed pipeline that never passes:

Screen_Shot_2020-01-31_at_2.28.42_AM Screen_Shot_2020-01-31_at_2.34.43_AM

Failed Pipeline that never fails:

Screen_Shot_2020-01-31_at_2.29.03_AM Screen_Shot_2020-01-31_at_2.49.36_AM

Output of checks

This bug happens on GitLab.com