Skip to content

Commit ae1235e

Browse files
committed
Add TTLs to tainted gvks in cache
Signed-off-by: Jonathan Ogilvie <[email protected]>
1 parent ee438ec commit ae1235e

File tree

12 files changed

+733
-255
lines changed

12 files changed

+733
-255
lines changed

controller/appcontroller.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import (
6767
appstatecache "github.com/argoproj/argo-cd/v3/util/cache/appstate"
6868
"github.com/argoproj/argo-cd/v3/util/db"
6969
"github.com/argoproj/argo-cd/v3/util/errors"
70+
errorutils "github.com/argoproj/argo-cd/v3/util/errors"
7071
"github.com/argoproj/argo-cd/v3/util/glob"
7172
"github.com/argoproj/argo-cd/v3/util/helm"
7273
logutils "github.com/argoproj/argo-cd/v3/util/log"
@@ -626,7 +627,7 @@ func (ctrl *ApplicationController) getResourceTree(destCluster *appv1.Cluster, a
626627
return true
627628
})
628629
if err != nil {
629-
if !isConversionWebhookError(err) {
630+
if !errorutils.IsConversionWebhookError(err) {
630631
return nil, fmt.Errorf("failed to iterate resource hierarchy v2: %w", err)
631632
}
632633

@@ -666,7 +667,7 @@ func (ctrl *ApplicationController) getResourceTree(destCluster *appv1.Cluster, a
666667
return true
667668
})
668669
if err != nil {
669-
if !isConversionWebhookError(err) {
670+
if !errorutils.IsConversionWebhookError(err) {
670671
return nil, fmt.Errorf("failed to iterate resource hierarchy v2 for orphaned resources: %w", err)
671672
}
672673

@@ -1827,6 +1828,10 @@ func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext boo
18271828
hasCacheIssues := false
18281829
usesTaintedResources := false
18291830

1831+
// Take a snapshot of cluster taint state to ensure consistency throughout the function
1832+
clusterURL := app.Spec.Destination.Server
1833+
failedGVKs := ctrl.stateCache.GetTaintedGVKs(clusterURL)
1834+
18301835
// 1. First check if the app itself reports conversion webhook errors
18311836
hasCacheIssues = hasClusterCacheIssues(app)
18321837

@@ -1854,16 +1859,8 @@ func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext boo
18541859
}
18551860
}
18561861

1857-
// 4. Check if the app directly uses any tainted resources
1858-
clusterURL := app.Spec.Destination.Server
1859-
// Check if cluster is tainted directly using our cluster taint tracking
1860-
allTaints := statecache.GetClusterTaints()
1861-
taints, exists := allTaints[clusterURL]
1862-
1863-
// If the cluster is tainted, check if the app uses any of the affected resource types
1864-
if exists && len(taints) > 0 {
1865-
// Check if app directly uses any of the tainted GVKs
1866-
failedGVKs := statecache.GetTaintedGVKs(clusterURL)
1862+
// 4. Check if the app directly uses any tainted resources (using consistent snapshot)
1863+
if len(failedGVKs) > 0 {
18671864

18681865
resLoop:
18691866
for _, res := range app.Status.Resources {

0 commit comments

Comments
 (0)