Conversation
When LockingExecutorWrapper.Plan(), Apply(), or Destroy() fail to acquire a lock (locked=false), they previously returned nil error. This caused the caller run() to silently succeed, making CI builds pass even though no actual plan/apply/destroy was performed. Return a descriptive error so callers can detect and report the lock failure properly. Fixes diggerhq#1366
Author
|
Friendly ping — this PR fixes a bug where lock acquisition failures return nil instead of an error, which can lead to silent data races. Would appreciate a review when convenient. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
LockingExecutorWrapper.Plan(),Apply(), orDestroy()fail to acquire a lock (locked == false), they return anilerror. This causes the callerrun()function incli/pkg/digger/digger.goto silently succeed — theswitchcase falls through to the defaultreturn &execution.DiggerExecutorResult{}, "", nil, reporting success to CI even though no actual plan/apply/destroy was performed.This means CI builds pass even when a lock could not be acquired, giving users a false sense that their infrastructure changes were processed.
Root Cause
In
libs/execution/execution.go:Plan()returnednil, false, false, plan, "", nilwhenlocked == falseApply()returnednil, false, "couldn't lock ", nilwhenlocked == falseDestroy()returnedfalse, nilwhenlocked == falseAll three methods returned
nilerror on lock failure.Fix
Return a descriptive
fmt.Errorf("failed to acquire lock for project")error from all three methods whenlocked == false, so callers can detect and properly report the lock failure.Tests
Added 4 new unit tests:
TestLockFailurePlanReturnsError— verifies Plan returns error on lock failureTestLockFailureApplyReturnsError— verifies Apply returns error on lock failureTestLockFailureDestroyReturnsError— verifies Destroy returns error on lock failureTestLockSuccessDelegatesToExecutor— verifies all three methods delegate correctly when lock succeedsAll tests pass.
Fixes #1366