Skip to content

Conversation

@JesperTerkelsen
Copy link
Member

Summary

FIX: Treat bundled deployments as success instead of failure when ArgoCD deploys a newer commit that includes your changes.

Problem

Supersede detection was causing false negatives in fast-moving environments where multiple deployments happen in quick succession.

Error Example: https://github.com/monta-app/service-vehicle/actions/runs/21033832041/job/60476819578

Logs:

[32/300s] Sync: Synced, Health: Healthy, Rev: d005b7f
  Waiting for ArgoCD to detect new revision (current: d005b7f, expected: 2f3a661)
  Running supersede detection check...
  Comparison result: 2f3a661...d005b7f = behind

[39/300s] Sync: OutOfSync, Health: Healthy, Rev: a12cba3
  Waiting for ArgoCD to detect new revision (current: a12cba3, expected: 2f3a661)
  Running supersede detection check...
  Comparison result: 2f3a661...a12cba3 = ahead

Error: Deployment superseded - ArgoCD moved to a newer commit
Error: Expected revision: 2f3a661
Error: Current revision: a12cba3
Error: Your changes are still in the manifest, but were deployed as part of the newer commit.
Error: Process completed with exit code 1.

Root Cause: When comparison status is ahead, it means the current revision IS ahead of the expected revision - i.e., the expected commit is an ancestor of the current commit. This means the changes ARE deployed, just bundled with other changes in the newer commit.

The script was treating this as a failure (exit 1), but it should be treated as success with a warning about bundling.

Solution

Change the supersede detection logic:

Before:

  • ahead status → FAIL (exit 1)
  • diverged status → FAIL (exit 1)

After:

  • ahead status → SUCCESS with warning (changes ARE deployed in newer commit)
  • diverged status → FAIL (branches have no common ancestry, changes might not be deployed)

Changes

wait-sync.sh (lines 201-225)

New logic for ahead status:

if [ "$COMPARE_STATUS" = "ahead" ]; then
    # Current revision is ahead of expected - expected commit is an ancestor
    # This means our changes ARE deployed, just bundled with other changes
    echo "::warning::Deployment bundled - ArgoCD deployed a newer commit that includes your changes"
    echo "::warning::Expected revision: ${EXPECTED_REVISION:0:7}"
    echo "::warning::Deployed revision: ${CURRENT_REVISION:0:7}"
    echo "::warning::Your changes were deployed as part of the newer commit (git ancestry confirmed)"
    
    # Treat this as successful - capture current revision and mark as deployed
    DEPLOYMENT_STARTED=true
    VERIFIED_REVISION="$CURRENT_REVISION"
    
    # Check if already healthy
    if [ "$SYNC_STATUS" = "Synced" ] && [ "$HEALTH_STATUS" = "Healthy" ]; then
        HEALTH_ACHIEVED=true
        HEALTH_TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
        MISSED_DEPLOYMENT=true
        break
    fi
fi

Still fail on diverged status:

elif [ "$COMPARE_STATUS" = "diverged" ]; then
    # Branches have diverged - expected commit might not be in current
    echo "::error::Deployment diverged - branches have no common ancestry"
    exit 1
fi

Git Comparison Status Reference

From GitHub's compare API (base...head):

  • ahead: head is ahead of base → base IS an ancestor of head
  • behind: head is behind base → base is NOT an ancestor of head
  • identical: same commit → exact match
  • diverged: branches diverged → no common ancestry

In our case (EXPECTED...CURRENT):

  • ahead = Current ahead of Expected = Expected IS deployed in Current
  • behind = Current behind Expected = Keep waiting for ArgoCD to catch up
  • diverged = Expected might NOT be in Current

Impact

Fixes false negatives - Bundled deployments now succeed instead of failing
Better warnings - Clear indication when deployment was bundled
Correct behavior - Only fail when changes truly aren't deployed (diverged)
Fast environments - Works correctly when multiple deployments happen quickly

Testing

After merge, workflows will:

  • ✅ Succeed with warning when deployment is bundled (ahead status)
  • ✅ Provide accurate deployment revision (the newer commit that includes changes)
  • ❌ Still fail when branches diverge (changes not deployed)

🤖 Generated with Claude Code

When the comparison status is 'ahead', it means the current revision is ahead
of the expected revision - i.e., the expected commit IS an ancestor of the
current commit. This means our changes ARE deployed, just bundled with other
changes in a newer commit.

Previous behavior:
- Failed with exit 1 on 'ahead' status
- Treated bundled deployments as errors

New behavior:
- Issue warning on 'ahead' status (deployment bundled)
- Mark deployment as successful with the newer revision
- Continue monitoring for health status
- Only fail on 'diverged' status (branches have no common ancestry)

This fixes false negatives in fast-moving environments where multiple
deployments happen in quick succession and ArgoCD bundles changes together.
@JesperTerkelsen JesperTerkelsen merged commit 9e9f856 into main Jan 15, 2026
1 check passed
@JesperTerkelsen JesperTerkelsen deleted the fix/treat-bundled-deployments-as-success branch January 15, 2026 14:10
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