From cbfd68459e7e9eb629f926b360d5b8f37d9e4905 Mon Sep 17 00:00:00 2001 From: Chris Kim <30601846+Oats87@users.noreply.github.com> Date: Fri, 6 Aug 2021 14:34:09 -0700 Subject: [PATCH] Don't apply if resource version is incorrect (#43) Signed-off-by: Chris Kim --- pkg/k8splan/watcher.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/k8splan/watcher.go b/pkg/k8splan/watcher.go index 09e9adb2..7eddf1a3 100644 --- a/pkg/k8splan/watcher.go +++ b/pkg/k8splan/watcher.go @@ -108,6 +108,10 @@ func (w *watcher) start(ctx context.Context) { } logrus.Debugf("[K8s] Processing secret %s in namespace %s at generation %d with resource version %s", secret.Name, secret.Namespace, secret.Generation, secret.ResourceVersion) needsApplied := true + if w.lastAppliedResourceVersion > secret.ResourceVersion { + logrus.Debugf("received secret to process that was older than the last secret operated on. (%s vs %s)", secret.ResourceVersion, w.lastAppliedResourceVersion) + return secret, nil + } if w.lastAppliedResourceVersion == secret.ResourceVersion { logrus.Debugf("last applied resource version (%s) did not change. skipping apply.", w.lastAppliedResourceVersion) needsApplied = false