Skip to content

fix(gitlab): pin commit statuses to the same pipeline via pipeline_id caching#2671

Open
ab-ghosh wants to merge 2 commits intotektoncd:mainfrom
ab-ghosh:fix/gitlab-commit-status-pipeline-id-caching
Open

fix(gitlab): pin commit statuses to the same pipeline via pipeline_id caching#2671
ab-ghosh wants to merge 2 commits intotektoncd:mainfrom
ab-ghosh:fix/gitlab-commit-status-pipeline-id-caching

Conversation

@ab-ghosh
Copy link
Copy Markdown
Member

@ab-ghosh ab-ghosh commented Apr 9, 2026

📝 Description of the Change

When PAC posts commit statuses to GitLab for a merge request, the status updates can get split across two different GitLab pipelines. GitLab's auto-assignment logic can abruptly change routing mid-stream, leaving the original MR pipeline permanently stuck with stale intermediate statuses.
This fix caches the pipeline_id returned by the first SetCommitStatus response for a given (project, SHA) pair and passes it on all subsequent calls, ensuring all commit statuses land in the same GitLab pipeline.

🔗 Linked GitHub Issue

Fixes #
https://redhat.atlassian.net/browse/SRVKP-11437

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

AI assistance can be used for various tasks, such as code generation,
documentation, or testing.

Please indicate whether you have used AI assistance
for this PR and provide details if applicable.

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

Important

Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project's standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Claude noreply@anthropic.com

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 9, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.93%. Comparing base (658e9d4) to head (faba1a9).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2671      +/-   ##
==========================================
+ Coverage   58.86%   58.93%   +0.06%     
==========================================
  Files         206      206              
  Lines       20329    20355      +26     
==========================================
+ Hits        11967    11996      +29     
+ Misses       7589     7587       -2     
+ Partials      773      772       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a caching mechanism for GitLab pipeline IDs to ensure that multiple commit statuses for the same project and SHA are grouped within the same pipeline. It includes logic to retrieve, store, and apply these IDs during the status creation process, along with comprehensive unit tests. A critical issue was identified in the setOptPipelineID function where a stale pipeline ID from a source project could persist when falling back to a target project, potentially causing API failures.

  When PAC posts multiple commit statuses for the same SHA, GitLab's
  auto-assignment logic can route them to different pipelines, leaving the
  MR pipeline permanently stuck with stale intermediate statuses.

  Cache the pipeline_id returned by the first SetCommitStatus response
  and pass it on subsequent calls for the same (project, SHA) pair so
  all statuses land in the same GitLab pipeline.

  Co-authored-by: Claude <noreply@anthropic.com>
  Signed-off-by: Abhishek Ghosh <abghosh@redhat.com>
@ab-ghosh ab-ghosh force-pushed the fix/gitlab-commit-status-pipeline-id-caching branch from 071640b to f57af59 Compare April 9, 2026 17:43
@pipelines-as-code
Copy link
Copy Markdown

🤖 AI Analysis - pr-complexity-rating

Based on the provided information, this PR appears to be a synchronization/maintenance operation rather than a functional feature or bug fix implementation.

📊 PR Review Complexity

Dimension Score Rationale
Size 1 This is a merge commit; no functional diffs are introduced.
Logic complexity 1 Standard git merge; no new logic introduced.
Risk 1 Very low; purely synchronization of branches.
Cross-cutting 1 Limited to repository branch synchronization.
Test coverage 5 CI pipeline passed successfully.

Overall difficulty: Easy

Summary

This PR is a merge commit synchronizing main into the fix/gitlab-commit-status-pipeline-id-caching feature branch. The reviewer should primarily ensure that the merge did not introduce any regressions or conflicts that weren't resolved during the merge process.

Suggested reviewers focus

  • Conflict resolution: Verify that the merge didn't accidentally overwrite or revert recent changes in the feature branch.
  • CI Status: Confirm that the linters and tests passed (which they currently report as successful).

Generated by Pipelines-as-Code LLM Analysis

@pipelines-as-code
Copy link
Copy Markdown

🤖 AI Analysis - pr-complexity-rating

Based on the provided context, this PR appears to be a maintenance merge (synchronizing the feature branch with main) rather than a functional feature implementation or bug fix.

📊 PR Review Complexity

Dimension Score Rationale
Size 1 This is a merge commit; no direct logic changes are being introduced.
Logic complexity 1 Standard git merge reconciliation.
Risk 1 Low risk; standard synchronization.
Cross-cutting 1 Confined to branch synchronization.
Test coverage 5 CI pipeline passed successfully on the merged state.

Overall difficulty: Easy

Summary

This PR consists of a merge commit synchronizing a feature branch (fix/gitlab-commit-status-pipeline-id-caching) with the main branch. Reviewers should verify that no unexpected merge conflicts were introduced and that the CI pipeline remains green.

Suggested reviewers focus

  • Check Merge Integrity: Ensure that the automated merge did not accidentally revert or overwrite logic in the fix/gitlab-commit-status-pipeline-id-caching branch.
  • CI Status: Confirm that the existing test suite passes on the new merge commit.

Generated by Pipelines-as-Code LLM Analysis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants