Skip to content

Pipeline left in inconsistent state after SCM migration: scmRepo updates but scmUri/scmContext stay stale #3500

Description

@sagar1312

What happened:

When a pipeline's repository is migrated from one SCM to another (e.g. a GitHub Enterprise Server → GitHub Enterprise Cloud migration, or any change of SCM host/context), the pipeline record can end up partially updated:

  • scmRepo (and name) reflect the new SCM
  • scmUri and scmContext still point at the old SCM

The pipeline then becomes unusable — starting jobs and "Sync pipeline" fail — because the stored scmUri/scmContext no longer resolve to a valid repo. It happens intermittently, not on every migration.

Root cause:

Pipeline.update() (in screwdriver-models) re-derives scmRepo/name from (scmUri, scmContext) via scm.decorateUrl on every update. BaseModel.update() only persists dirty fields. scmContext is always dirty (it is set through the setter in the PipelineModel constructor), but scmUri is dirty only when it is explicitly reassigned. As a result, an update can persist a freshly-derived scmRepo without persisting a matching scmUri, allowing the SCM identity fields to drift out of sync at the database level.

What you expected to happen:

scmUri, scmContext, scmRepo, and name together describe a single SCM identity. They should always be persisted together and remain mutually consistent, so a migration can never leave a pipeline half-updated.

How to reproduce it:

  1. Have an active pipeline whose repository is then migrated to a different SCM host/context (so the underlying repo metadata resolves to the new SCM).
  2. Trigger a pipeline update (e.g. a webhook, event, or sync) so Pipeline.update() runs.
  3. Inspect the pipeline row: scmRepo reflects the new SCM while scmUri/scmContext still reference the old one.

Fix:

screwdriver-cd/models#674 — persist the full SCM identity unit (scmUri, scmContext, scmRepo, name) atomically in Pipeline.update().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions