Skip to content

fix: clear stale workspace lock tags and improve lock error messages (CLOUD-933)#55

Closed
MeNsaaH wants to merge 4 commits intomainfrom
feat/cloud-933-workspace-lock-fixes
Closed

fix: clear stale workspace lock tags and improve lock error messages (CLOUD-933)#55
MeNsaaH wants to merge 4 commits intomainfrom
feat/cloud-933-workspace-lock-fixes

Conversation

@MeNsaaH
Copy link
Copy Markdown
Collaborator

@MeNsaaH MeNsaaH commented Apr 15, 2026

Summary

  • Export TFLockTagPrefix from tfc_trigger so other packages can reference the tag name without duplication
  • Fix lock error messages: when a TFC workspace is locked by TFBuddy, the error now includes a full clickable MR URL (derived from the current MR's web URL) instead of a bare IID; when locked by TFC natively with no tag, the message directs users to the TFC UI
  • Auto-release stale lock tags: after an apply-triggered run reaches a terminal state (applied, errored, canceled, discarded), releaseWorkspaceLockTag removes the tfbuddylock-<MR_IID> workspace tag, preventing it from blocking future applies while the MR stays open

Test Plan

  • go test ./pkg/tfc_trigger/... — 3 new tests covering TFC-lock + tag, TFC-lock + no tag, and tag-only lock scenarios
  • go test ./pkg/vcs/gitlab/... — 3 new tests: tag removed on RunApplied, tag removed on RunErrored, tag not removed for plan action
  • Trigger an apply via TFBuddy on a GitLab MR; after the run completes, confirm the tfbuddylock-<IID> tag is gone from the TFC workspace
  • With a locked workspace, trigger an apply and verify the error comment contains a full MR URL

Fixes CLOUD-933

🤖 Generated with Claude Code

MeNsaaH and others added 4 commits April 15, 2026 16:47
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…OUD-933)

Add releaseWorkspaceLockTag method to RunStatusUpdater that removes the
tfbuddylock-<MR_IID> tag from the TFC workspace when an apply run
reaches a terminal state (applied, errored, canceled, discarded),
preventing stale tags from blocking future applies while the MR stays open.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GetRun always includes tfe.RunWorkspace, so run.Workspace is guaranteed
to be populated at this call site. The nil guard created false confidence
without protecting the actual risk point.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MeNsaaH MeNsaaH closed this Apr 16, 2026
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.

1 participant