Skip to content

Commit

Permalink
feat: Add ignore annotation
Browse files Browse the repository at this point in the history
Fixes #30
  • Loading branch information
NoUseFreak committed Jan 17, 2023
1 parent 565e478 commit 0f0ddf9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/agent/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ const (
LedgerAnnotationLocation = "ledger.stenic.io/location"
LedgerAnnotationEnvironment = "ledger.stenic.io/environment"
LedgerAnnotationApplication = "ledger.stenic.io/application"
LedgerAnnotationIgnore = "ledger.stenic.io/ignore"
ledgerAnnotationProcessedGen = "ledger.stenic.io/processedGeneration"
)
13 changes: 13 additions & 0 deletions internal/agent/process.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package agent

import (
"strconv"
"strings"

"github.com/sirupsen/logrus"
Expand All @@ -11,6 +12,18 @@ import (
var cache = map[string]int64{}

func processObject(objectMeta metav1.ObjectMeta, podTemplate v1.PodTemplateSpec) error {
if val, ok := objectMeta.Annotations[LedgerAnnotationIgnore]; ok {
if b, _ := strconv.ParseBool(val); b {
// Skip processing if the object was processed in the last 10 seconds.
logrus.WithFields(logrus.Fields{
"namespace": objectMeta.Namespace,
"name": objectMeta.Name,
"generation": objectMeta.Generation,
}).Trace("Skipping, has ignore annotation")
return nil
}
}

val, ok := cache[string(objectMeta.UID)]
if ok && val == objectMeta.Generation {
// Skip processing if the object was processed in the last 10 seconds.
Expand Down

0 comments on commit 0f0ddf9

Please sign in to comment.