Pipelines cannot be created when there are duplicate environment names in .gitlab-ci.yml

Latest status

Update: 16:20:50

The patch has been deployed on production.

Update: 10:48:35 UTC

The patch has been deployed on canary. RM will promote it to production in about an hour.

A patch has been merged !18833 (merged) and currently deployed on staging.com. It's waiting for being promoted to canaray/production, which should happen somewhere on Monday.

Problem

This happens when the duplicate environment:name defined in the same pipeline.

For example, in the following .gitlab-ci.yml, this error is raised and results in pipeline creation failure.

deploy:
  environment: production

deploy-2:
  environment: production

This behavior was reproduced on staging. https://staging.gitlab.com/dosuken123/deployment-iid-test/merge_requests/3/diffs => https://sentry.gitlab.net/gitlab/staginggitlabcom/issues/1022739/?query=is:unresolved.

On the other hand, if there are no duplicate environment:names in .gitlab-ci.yml, it doesn't have a problem. Also, review app workflow is also not affected, as stop-review job doesn't create environment object (because of action: stop). See the following example.

review:
  environment:
    name: review/$CI_COMMIT_REF_NAME
    on_stop: stop-review

stop-review:
  environment:
    name: review/$CI_COMMIT_REF_NAME
    action: stop

Sentry

https://sentry.gitlab.net/gitlab/gitlabcom/issues/1020788/

ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR: null value in column "environment_id" violates not-null constraint

PG::NotNullViolation: ERROR:  null value in column "environment_id" violates not-null constraint
DETAIL:  Failing row contains (35369740, 276, 14871334, null, feature/automation-v3, f, b015dbf4683afff49c369812cb8b644a7784dfc3, 3741117, 325324154, CommitStatus, 2019-10-18 19:58:49.78891, 2019-10-18 19:58:49.78891, stop_review, null, 0, 74723).

  active_record/connection_adapters/postgresql_adapter.rb:611:in `async_exec_params'
    @connection.exec_params(sql, type_casted_binds)
  active_record/connection_adapters/postgresql_adapter.rb:611:in `block (2 levels) in exec_no_cache'
    @connection.exec_params(sql, type_casted_binds)
  active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    yield
  active_support/concurrency/share_lock.rb:187:in `yield_shares'
    yield
  active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    @lock.yield_shares(compatible: [:load]) do
...
(347 additional frame(s) were not displayed)

ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR:  null value in column "environment_id" violates not-null constraint
DETAIL:  Failing row contains (35369740, 276, 14871334, null, feature/automation-v3, f, b015dbf4683afff49c369812cb8b644a7784dfc3, 3741117, 325324154, CommitStatus, 2019-10-18 19:58:49.78891, 2019-10-18 19:58:49.78891, stop_review, null, 0, 74723).
: INSERT INTO "deployments" ("iid", "project_id", "ref", "tag", "sha", "user_id", "deployable_id", "deployable_type", "created_at", "updated_at", "on_stop", "status", "cluster_id") VALUES (276, 14871334, 'feature/automation-v3', FALSE, 'b015dbf4683afff49c369812cb8b644a7784dfc3', 3741117, 325324154, 'CommitStatus', '2019-10-18 19:58:49.788910', '2019-10-18 19:58:49.788910', 'stop_review', 0, 74723) RETURNING "id"

ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR:  null value in column "environment_id" violates not-null constraint
DETAIL:  Failing row contains (35369740, 276, 14871334, null, feature/automation-v3, f, b015dbf4683afff49c369812cb8b644a7784dfc3, 3741117, 325324154, CommitStatus, 2019-10-18 19:58:49.78891, 2019-10-18 19:58:49.78891, stop_review, null, 0, 74723).
: INSERT INTO "deployments" ("iid", "project_id", "ref", "tag", "sha", "user_id", "deployable_id", "deployable_type", "created_at", "updated_at", "on_stop", "status", "cluster_id") VALUES (276, 14871334, 'feature/automation-v3', FALSE, 'b015dbf4683afff49c369812cb8b644a7784dfc3', 3741117, 325324154, 'CommitStatus', '2019-10-18 19:58:49.788910', '2019-10-18 19:58:49.788910', 'stop_review', 0, 74723) RETURNING "id"

Steps to reproduce

  • Fork this project https://gitlab.com/ali-gitlab/serverless-ruby
  • Try to run the CI pipeline
Edited Oct 21, 2019 by Shinya Maeda
Assignee Loading
Time tracking Loading