argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
18.04k stars 5.51k forks source link

Improve git webhook handling: prevent missing/dropping commits #9427

Open pietervincken opened 2 years ago

pietervincken commented 2 years ago

Summary

A race condition exists in the handling of webhooks together with kustomize builds. When a git webhook comes in a kustomize build get triggered. If a seconds git webhook arrives within the time it takes the repository controller to build kustomize, the second git webhook gets dropped / skipped.

Discussed in Slack

Motivation

Scenario:

  1. Webhook for commit 1 comes in -> start building kustomize
  2. Webhook for commit 2 comes in -> skipped as there is already a build in progress
  3. Build for webhook 1 completes -> changes are applied
  4. ArgoCD markes the environment as "in-sync" while it's on commit 1 and not on commit 2

This causes changes to be executed once the timeout exceeds. Unfortunately, due to the long kustomize builds, users are inclined to extend that timeout to prevent the repository server from constantly being heavily loaded.

Proposal

Multiple scenarios are possible:

nanoq66 commented 2 years ago

@pietervincken THX for your investigation. I think we experienced the same problem here...