Skip to content

Conversation

@JesperTerkelsen
Copy link
Member

Summary

FEATURE: Trigger immediate ArgoCD refresh when monitoring starts to significantly reduce revision detection time.

Problem

ArgoCD polls Git repositories on a periodic interval (typically 3 minutes by default). This means after pushing a manifest, it can take 30+ seconds before ArgoCD detects the change and starts syncing.

Example from deployment logs:

[0/300s] Sync: Synced, Health: Healthy, Rev: 2ad755e
  Waiting for ArgoCD to detect new revision (current: 2ad755e, expected: 336e562)
[6/300s] Sync: Synced, Health: Healthy, Rev: 2ad755e
  Waiting for ArgoCD to detect new revision...
[12/300s] ...still waiting...
[18/300s] ...still waiting...
[24/300s] ...still waiting...
[30/300s] ...still waiting...
[36/300s] Sync: OutOfSync, Health: Healthy, Rev: 336e562
✓ ArgoCD detected our revision, deployment in progress

Wait time: 36 seconds before ArgoCD detected the new revision

Solution

Trigger an immediate ArgoCD refresh at the start of monitoring using argocd app get --refresh. This tells ArgoCD to check the Git repository right away instead of waiting for its next polling interval.

Changes

wait-sync.sh

New refresh trigger before monitoring loop:

# Trigger immediate refresh to hint ArgoCD about the new revision
# This reduces wait time from minutes to seconds by avoiding ArgoCD's polling interval
echo "Triggering ArgoCD refresh to detect new revision immediately..."
argocd app get "$APP_NAME" --refresh "${ARGOCD_FLAGS[@]}" &>/dev/null || true
echo ""

How It Works

argocd app get --refresh:

  • Tells ArgoCD to check the Git repository immediately
  • Triggers comparison of desired state vs live state
  • Non-blocking - runs asynchronously
  • Safe to fail (uses || true) - won't block monitoring if it errors

Expected Impact

Before:

  • Wait time: 30-180 seconds (depends on ArgoCD polling interval)
  • ArgoCD discovers change via periodic polling

After:

  • Wait time: ~5-10 seconds (just Git fetch + comparison)
  • ArgoCD discovers change immediately via explicit refresh

Total deployment time reduction: 20-170 seconds per deployment

Testing

After merge:

  • ✅ Monitoring starts with immediate refresh trigger
  • ✅ ArgoCD detects new revisions within seconds
  • ✅ Faster feedback for deployments
  • ✅ No impact if refresh fails (monitoring continues normally)

🤖 Generated with Claude Code

Before monitoring starts, trigger an ArgoCD refresh to hint that a new
revision is available. This forces ArgoCD to check Git immediately instead
of waiting for its periodic polling interval (typically 3 minutes).

Before:
- ArgoCD polls Git on interval (default: 3 minutes)
- Wait time: 30+ seconds before detecting new revision

After:
- Immediate refresh triggered at monitoring start
- ArgoCD checks Git right away
- Wait time: Reduced to seconds

The refresh is non-blocking (runs in background) and won't delay the
monitoring loop if it fails.
@JesperTerkelsen JesperTerkelsen merged commit 38f40f6 into main Jan 15, 2026
1 check passed
@JesperTerkelsen JesperTerkelsen deleted the feat/trigger-argocd-refresh-on-monitor-start branch January 15, 2026 16:21
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.

4 participants