Skip to content

Commit 7893979

Browse files
Merge pull request from GHSA-9m6p-x4h2-6frq
* feat: limit jq.Run with timeout Signed-off-by: pashakostohrys <[email protected]> * feat: ignore normalizer jq execution timeout as env variable Signed-off-by: pashakostohrys <[email protected]> * feat: customize error message and add doc section Signed-off-by: pashakostohrys <[email protected]> * feat: improve log and change a way how to get variable Signed-off-by: pashakostohrys <[email protected]> * feat: reorganize imports Signed-off-by: pashakostohrys <[email protected]> * chore: fix import`s order Signed-off-by: pashakostohrys <[email protected]> --------- Signed-off-by: pashakostohrys <[email protected]>
1 parent a64649d commit 7893979

File tree

22 files changed

+161
-46
lines changed

22 files changed

+161
-46
lines changed

applicationset/controllers/applicationset_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242
"github.com/argoproj/argo-cd/v2/applicationset/generators"
4343
"github.com/argoproj/argo-cd/v2/applicationset/utils"
4444
"github.com/argoproj/argo-cd/v2/common"
45+
"github.com/argoproj/argo-cd/v2/util/argo/normalizers"
4546
"github.com/argoproj/argo-cd/v2/util/db"
4647
"github.com/argoproj/argo-cd/v2/util/glob"
4748

@@ -609,7 +610,7 @@ func (r *ApplicationSetReconciler) createOrUpdateInCluster(ctx context.Context,
609610
},
610611
}
611612

612-
action, err := utils.CreateOrUpdate(ctx, r.Client, found, func() error {
613+
action, err := utils.CreateOrUpdate(ctx, r.Client, found, normalizers.IgnoreNormalizerOpts{}, func() error {
613614
// Copy only the Application/ObjectMeta fields that are significant, from the generatedApp
614615
found.Spec = generatedApp.Spec
615616

applicationset/utils/createOrUpdate.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
1515

1616
argov1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
17+
"github.com/argoproj/argo-cd/v2/util/argo/normalizers"
1718
)
1819

1920
// CreateOrUpdate overrides "sigs.k8s.io/controller-runtime" function
@@ -29,7 +30,7 @@ import (
2930
// The MutateFn is called regardless of creating or updating an object.
3031
//
3132
// It returns the executed operation and an error.
32-
func CreateOrUpdate(ctx context.Context, c client.Client, obj client.Object, f controllerutil.MutateFn) (controllerutil.OperationResult, error) {
33+
func CreateOrUpdate(ctx context.Context, c client.Client, obj client.Object, ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts, f controllerutil.MutateFn) (controllerutil.OperationResult, error) {
3334

3435
key := client.ObjectKeyFromObject(obj)
3536
if err := c.Get(ctx, key, obj); err != nil {
@@ -94,4 +95,4 @@ func mutate(f controllerutil.MutateFn, key client.ObjectKey, obj client.Object)
9495
return fmt.Errorf("MutateFn cannot mutate object name and/or object namespace")
9596
}
9697
return nil
97-
}
98+
}

cmd/argocd-application-controller/commands/argocd_application_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
2121
appclientset "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned"
2222
"github.com/argoproj/argo-cd/v2/reposerver/apiclient"
23+
"github.com/argoproj/argo-cd/v2/util/argo/normalizers"
2324
cacheutil "github.com/argoproj/argo-cd/v2/util/cache"
2425
appstatecache "github.com/argoproj/argo-cd/v2/util/cache/appstate"
2526
"github.com/argoproj/argo-cd/v2/util/cli"
@@ -64,6 +65,7 @@ func NewCommand() *cobra.Command {
6465
applicationNamespaces []string
6566
persistResourceHealth bool
6667
shardingAlgorithm string
68+
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
6769
)
6870
var command = cobra.Command{
6971
Use: cliName,
@@ -155,6 +157,7 @@ func NewCommand() *cobra.Command {
155157
persistResourceHealth,
156158
clusterFilter,
157159
applicationNamespaces,
160+
ignoreNormalizerOpts,
158161
)
159162
errors.CheckError(err)
160163
cacheutil.CollectMetrics(redisClient, appController.GetMetricsServer())
@@ -199,6 +202,7 @@ func NewCommand() *cobra.Command {
199202
command.Flags().StringSliceVar(&applicationNamespaces, "application-namespaces", env.StringsFromEnv("ARGOCD_APPLICATION_NAMESPACES", []string{}, ","), "List of additional namespaces that applications are allowed to be reconciled from")
200203
command.Flags().BoolVar(&persistResourceHealth, "persist-resource-health", env.ParseBoolFromEnv("ARGOCD_APPLICATION_CONTROLLER_PERSIST_RESOURCE_HEALTH", true), "Enables storing the managed resources health in the Application CRD")
201204
command.Flags().StringVar(&shardingAlgorithm, "sharding-method", env.StringFromEnv(common.EnvControllerShardingAlgorithm, common.DefaultShardingAlgorithm), "Enables choice of sharding method. Supported sharding methods are : [legacy, round-robin] ")
205+
command.Flags().DurationVar(&ignoreNormalizerOpts.JQExecutionTimeout, "", env.ParseDurationFromEnv("ARGOCD_IGNORE_NORMALIZER_JQ_TIMEOUT", 0*time.Second, 0, math.MaxInt64), "Set ignore normalizer JQ execution timeout")
202206
cacheSrc = appstatecache.AddCacheFlagsToCmd(&command, func(client *redis.Client) {
203207
redisClient = client
204208
})

cmd/argocd/commands/admin/app.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
appinformers "github.com/argoproj/argo-cd/v2/pkg/client/informers/externalversions"
2929
argocdclient "github.com/argoproj/argo-cd/v2/reposerver/apiclient"
3030
"github.com/argoproj/argo-cd/v2/util/argo"
31+
"github.com/argoproj/argo-cd/v2/util/argo/normalizers"
3132
cacheutil "github.com/argoproj/argo-cd/v2/util/cache"
3233
appstatecache "github.com/argoproj/argo-cd/v2/util/cache/appstate"
3334
"github.com/argoproj/argo-cd/v2/util/cli"
@@ -231,6 +232,7 @@ func NewReconcileCommand() *cobra.Command {
231232
repoServerAddress string
232233
outputFormat string
233234
refresh bool
235+
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
234236
)
235237

236238
var command = &cobra.Command{
@@ -267,7 +269,7 @@ func NewReconcileCommand() *cobra.Command {
267269

268270
appClientset := appclientset.NewForConfigOrDie(cfg)
269271
kubeClientset := kubernetes.NewForConfigOrDie(cfg)
270-
result, err = reconcileApplications(ctx, kubeClientset, appClientset, namespace, repoServerClient, selector, newLiveStateCache)
272+
result, err = reconcileApplications(ctx, kubeClientset, appClientset, namespace, repoServerClient, selector, newLiveStateCache, ignoreNormalizerOpts)
271273
errors.CheckError(err)
272274
} else {
273275
appClientset := appclientset.NewForConfigOrDie(cfg)
@@ -282,7 +284,7 @@ func NewReconcileCommand() *cobra.Command {
282284
command.Flags().StringVar(&selector, "l", "", "Label selector")
283285
command.Flags().StringVar(&outputFormat, "o", "yaml", "Output format (yaml|json)")
284286
command.Flags().BoolVar(&refresh, "refresh", false, "If set to true then recalculates apps reconciliation")
285-
287+
command.Flags().DurationVar(&ignoreNormalizerOpts.JQExecutionTimeout, "ignore-normalizer-jq-execution-timeout", normalizers.DefaultJQExecutionTimeout, "Set ignore normalizer JQ execution timeout")
286288
return command
287289
}
288290

@@ -331,6 +333,7 @@ func reconcileApplications(
331333
repoServerClient argocdclient.Clientset,
332334
selector string,
333335
createLiveStateCache func(argoDB db.ArgoDB, appInformer kubecache.SharedIndexInformer, settingsMgr *settings.SettingsManager, server *metrics.MetricsServer) cache.LiveStateCache,
336+
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts,
334337
) ([]appReconcileResult, error) {
335338
settingsMgr := settings.NewSettingsManager(ctx, kubeClientset, namespace)
336339
argoDB := db.NewDB(namespace, settingsMgr, kubeClientset)
@@ -371,7 +374,7 @@ func reconcileApplications(
371374
)
372375

373376
appStateManager := controller.NewAppStateManager(
374-
argoDB, appClientset, repoServerClient, namespace, kubeutil.NewKubectl(), settingsMgr, stateCache, projInformer, server, cache, time.Second, argo.NewResourceTracking(), false)
377+
argoDB, appClientset, repoServerClient, namespace, kubeutil.NewKubectl(), settingsMgr, stateCache, projInformer, server, cache, time.Second, argo.NewResourceTracking(), false, ignoreNormalizerOpts)
375378

376379
appsList, err := appClientset.ArgoprojV1alpha1().Applications(namespace).List(ctx, v1.ListOptions{LabelSelector: selector})
377380
if err != nil {

cmd/argocd/commands/admin/app_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
argocdclient "github.com/argoproj/argo-cd/v2/reposerver/apiclient"
2424
"github.com/argoproj/argo-cd/v2/reposerver/apiclient/mocks"
2525
"github.com/argoproj/argo-cd/v2/test"
26+
"github.com/argoproj/argo-cd/v2/util/argo/normalizers"
2627
"github.com/argoproj/argo-cd/v2/util/db"
2728
"github.com/argoproj/argo-cd/v2/util/settings"
2829
)
@@ -113,6 +114,7 @@ func TestGetReconcileResults_Refresh(t *testing.T) {
113114
func(argoDB db.ArgoDB, appInformer cache.SharedIndexInformer, settingsMgr *settings.SettingsManager, server *metrics.MetricsServer) statecache.LiveStateCache {
114115
return &liveStateCache
115116
},
117+
normalizers.IgnoreNormalizerOpts{},
116118
)
117119

118120
if !assert.NoError(t, err) {

cmd/argocd/commands/admin/settings.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ argocd admin settings resource-overrides ignore-differences ./deploy.yaml --argo
432432
// configurations. This requires access to live resources which is not the
433433
// purpose of this command. This will just apply jsonPointers and
434434
// jqPathExpressions configurations.
435-
normalizer, err := normalizers.NewIgnoreNormalizer(nil, overrides)
435+
normalizer, err := normalizers.NewIgnoreNormalizer(nil, overrides, normalizers.IgnoreNormalizerOpts{})
436436
errors.CheckError(err)
437437

438438
normalizedRes := res.DeepCopy()
@@ -457,6 +457,9 @@ argocd admin settings resource-overrides ignore-differences ./deploy.yaml --argo
457457
}
458458

459459
func NewResourceIgnoreResourceUpdatesCommand(cmdCtx commandContext) *cobra.Command {
460+
var (
461+
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
462+
)
460463
var command = &cobra.Command{
461464
Use: "ignore-resource-updates RESOURCE_YAML_PATH",
462465
Short: "Renders fields excluded from resource updates",
@@ -478,7 +481,7 @@ argocd admin settings resource-overrides ignore-resource-updates ./deploy.yaml -
478481
return
479482
}
480483

481-
normalizer, err := normalizers.NewIgnoreNormalizer(nil, overrides)
484+
normalizer, err := normalizers.NewIgnoreNormalizer(nil, overrides, ignoreNormalizerOpts)
482485
errors.CheckError(err)
483486

484487
normalizedRes := res.DeepCopy()
@@ -499,6 +502,7 @@ argocd admin settings resource-overrides ignore-resource-updates ./deploy.yaml -
499502
})
500503
},
501504
}
505+
command.Flags().DurationVar(&ignoreNormalizerOpts.JQExecutionTimeout, "ignore-normalizer-jq-execution-timeout", normalizers.DefaultJQExecutionTimeout, "Set ignore normalizer JQ execution timeout")
502506
return command
503507
}
504508

cmd/argocd/commands/app.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
"github.com/argoproj/argo-cd/v2/reposerver/repository"
4545
"github.com/argoproj/argo-cd/v2/util/argo"
4646
argodiff "github.com/argoproj/argo-cd/v2/util/argo/diff"
47+
"github.com/argoproj/argo-cd/v2/util/argo/normalizers"
4748
"github.com/argoproj/argo-cd/v2/util/cli"
4849
"github.com/argoproj/argo-cd/v2/util/errors"
4950
"github.com/argoproj/argo-cd/v2/util/git"
@@ -925,6 +926,7 @@ func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
925926
localRepoRoot string
926927
serverSideGenerate bool
927928
localIncludes []string
929+
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
928930
)
929931
shortDesc := "Perform a diff against the target and live state."
930932
var command = &cobra.Command{
@@ -989,7 +991,7 @@ func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
989991
diffOption.cluster = cluster
990992
}
991993
}
992-
foundDiffs := findandPrintDiff(ctx, app, resources, argoSettings, diffOption)
994+
foundDiffs := findandPrintDiff(ctx, app, resources, argoSettings, diffOption, ignoreNormalizerOpts)
993995
if foundDiffs && exitCode {
994996
os.Exit(1)
995997
}
@@ -1003,6 +1005,7 @@ func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
10031005
command.Flags().StringVar(&localRepoRoot, "local-repo-root", "/", "Path to the repository root. Used together with --local allows setting the repository root")
10041006
command.Flags().BoolVar(&serverSideGenerate, "server-side-generate", false, "Used with --local, this will send your manifests to the server for diffing")
10051007
command.Flags().StringArrayVar(&localIncludes, "local-include", []string{"*.yaml", "*.yml", "*.json"}, "Used with --server-side-generate, specify patterns of filenames to send. Matching is based on filename and not path.")
1008+
command.Flags().DurationVar(&ignoreNormalizerOpts.JQExecutionTimeout, "ignore-normalizer-jq-execution-timeout", normalizers.DefaultJQExecutionTimeout, "Set ignore normalizer JQ execution timeout")
10061009
return command
10071010
}
10081011

@@ -1017,7 +1020,7 @@ type DifferenceOption struct {
10171020
}
10181021

10191022
// findandPrintDiff ... Prints difference between application current state and state stored in git or locally, returns boolean as true if difference is found else returns false
1020-
func findandPrintDiff(ctx context.Context, app *argoappv1.Application, resources *application.ManagedResourcesResponse, argoSettings *settings.Settings, diffOptions *DifferenceOption) bool {
1023+
func findandPrintDiff(ctx context.Context, app *argoappv1.Application, resources *application.ManagedResourcesResponse, argoSettings *settings.Settings, diffOptions *DifferenceOption, ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts) bool {
10211024
var foundDiffs bool
10221025
liveObjs, err := cmdutil.LiveObjects(resources.Items)
10231026
errors.CheckError(err)
@@ -1072,7 +1075,7 @@ func findandPrintDiff(ctx context.Context, app *argoappv1.Application, resources
10721075
// compareOptions in the protobuf
10731076
ignoreAggregatedRoles := false
10741077
diffConfig, err := argodiff.NewDiffConfigBuilder().
1075-
WithDiffSettings(app.Spec.IgnoreDifferences, overrides, ignoreAggregatedRoles).
1078+
WithDiffSettings(app.Spec.IgnoreDifferences, overrides, ignoreAggregatedRoles, ignoreNormalizerOpts).
10761079
WithTracking(argoSettings.AppLabelKey, argoSettings.TrackingMethod).
10771080
WithNoCache().
10781081
Build()
@@ -1543,6 +1546,7 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
15431546
diffChanges bool
15441547
diffChangesConfirm bool
15451548
projects []string
1549+
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
15461550
)
15471551
var command = &cobra.Command{
15481552
Use: "sync [APPNAME... | -l selector | --project project-name]",
@@ -1764,7 +1768,7 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
17641768
foundDiffs := false
17651769
fmt.Printf("====== Previewing differences between live and desired state of application %s ======\n", appQualifiedName)
17661770

1767-
foundDiffs = findandPrintDiff(ctx, app, resources, argoSettings, diffOption)
1771+
foundDiffs = findandPrintDiff(ctx, app, resources, argoSettings, diffOption, ignoreNormalizerOpts)
17681772
if foundDiffs {
17691773
if !diffChangesConfirm {
17701774
yesno := cli.AskToProceed(fmt.Sprintf("Please review changes to application %s shown above. Do you want to continue the sync process? (y/n): ", appQualifiedName))
@@ -1820,6 +1824,7 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
18201824
command.Flags().BoolVar(&diffChangesConfirm, "assumeYes", false, "Assume yes as answer for all user queries or prompts")
18211825
command.Flags().BoolVar(&diffChanges, "preview-changes", false, "Preview difference against the target and live state before syncing app and wait for user confirmation")
18221826
command.Flags().StringArrayVar(&projects, "project", []string{}, "Sync apps that belong to the specified projects. This option may be specified repeatedly.")
1827+
command.Flags().DurationVar(&ignoreNormalizerOpts.JQExecutionTimeout, "ignore-normalizer-jq-execution-timeout", normalizers.DefaultJQExecutionTimeout, "Set ignore normalizer JQ execution timeout")
18231828
return command
18241829
}
18251830

controller/appcontroller.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import (
5151
"github.com/argoproj/argo-cd/v2/reposerver/apiclient"
5252
"github.com/argoproj/argo-cd/v2/util/argo"
5353
argodiff "github.com/argoproj/argo-cd/v2/util/argo/diff"
54+
"github.com/argoproj/argo-cd/v2/util/argo/normalizers"
5455

5556
appstatecache "github.com/argoproj/argo-cd/v2/util/cache/appstate"
5657
"github.com/argoproj/argo-cd/v2/util/db"
@@ -120,6 +121,7 @@ type ApplicationController struct {
120121
clusterFilter func(cluster *appv1.Cluster) bool
121122
projByNameCache sync.Map
122123
applicationNamespaces []string
124+
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
123125
}
124126

125127
// NewApplicationController creates new instance of ApplicationController.
@@ -141,6 +143,7 @@ func NewApplicationController(
141143
persistResourceHealth bool,
142144
clusterFilter func(cluster *appv1.Cluster) bool,
143145
applicationNamespaces []string,
146+
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts,
144147
) (*ApplicationController, error) {
145148
log.Infof("appResyncPeriod=%v, appHardResyncPeriod=%v", appResyncPeriod, appHardResyncPeriod)
146149
db := db.NewDB(namespace, settingsMgr, kubeClientset)
@@ -166,6 +169,7 @@ func NewApplicationController(
166169
clusterFilter: clusterFilter,
167170
projByNameCache: sync.Map{},
168171
applicationNamespaces: applicationNamespaces,
172+
ignoreNormalizerOpts: ignoreNormalizerOpts,
169173
}
170174
if kubectlParallelismLimit > 0 {
171175
ctrl.kubectlSemaphore = semaphore.NewWeighted(kubectlParallelismLimit)
@@ -216,7 +220,7 @@ func NewApplicationController(
216220
}
217221
}
218222
stateCache := statecache.NewLiveStateCache(db, appInformer, ctrl.settingsMgr, kubectl, ctrl.metricsServer, ctrl.handleObjectUpdated, clusterFilter, argo.NewResourceTracking())
219-
appStateManager := NewAppStateManager(db, applicationClientset, repoClientset, namespace, kubectl, ctrl.settingsMgr, stateCache, projInformer, ctrl.metricsServer, argoCache, ctrl.statusRefreshTimeout, argo.NewResourceTracking(), persistResourceHealth)
223+
appStateManager := NewAppStateManager(db, applicationClientset, repoClientset, namespace, kubectl, ctrl.settingsMgr, stateCache, projInformer, ctrl.metricsServer, argoCache, ctrl.statusRefreshTimeout, argo.NewResourceTracking(), persistResourceHealth, ignoreNormalizerOpts)
220224
ctrl.appInformer = appInformer
221225
ctrl.appLister = appLister
222226
ctrl.projInformer = projInformer
@@ -666,7 +670,7 @@ func (ctrl *ApplicationController) hideSecretData(app *appv1.Application, compar
666670
return nil, fmt.Errorf("error getting cluster cache: %s", err)
667671
}
668672
diffConfig, err := argodiff.NewDiffConfigBuilder().
669-
WithDiffSettings(app.Spec.IgnoreDifferences, resourceOverrides, compareOptions.IgnoreAggregatedRoles).
673+
WithDiffSettings(app.Spec.IgnoreDifferences, resourceOverrides, compareOptions.IgnoreAggregatedRoles, ctrl.ignoreNormalizerOpts).
670674
WithTracking(appLabelKey, trackingMethod).
671675
WithNoCache().
672676
WithLogger(logutils.NewLogrusLogger(logutils.NewWithCurrentConfig())).

controller/appcontroller_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"github.com/argoproj/argo-cd/v2/reposerver/apiclient"
3939
mockrepoclient "github.com/argoproj/argo-cd/v2/reposerver/apiclient/mocks"
4040
"github.com/argoproj/argo-cd/v2/test"
41+
"github.com/argoproj/argo-cd/v2/util/argo/normalizers"
4142
cacheutil "github.com/argoproj/argo-cd/v2/util/cache"
4243
appstatecache "github.com/argoproj/argo-cd/v2/util/cache/appstate"
4344
"github.com/argoproj/argo-cd/v2/util/settings"
@@ -123,6 +124,7 @@ func newFakeController(data *fakeData) *ApplicationController {
123124
true,
124125
nil,
125126
data.applicationNamespaces,
127+
normalizers.IgnoreNormalizerOpts{},
126128
)
127129
if err != nil {
128130
panic(err)

controller/cache/cache.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/argoproj/argo-cd/v2/pkg/apis/application"
3333
appv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
3434
"github.com/argoproj/argo-cd/v2/util/argo"
35+
"github.com/argoproj/argo-cd/v2/util/argo/normalizers"
3536
"github.com/argoproj/argo-cd/v2/util/db"
3637
"github.com/argoproj/argo-cd/v2/util/env"
3738
logutils "github.com/argoproj/argo-cd/v2/util/log"
@@ -197,6 +198,7 @@ type liveStateCache struct {
197198
metricsServer *metrics.MetricsServer
198199
clusterFilter func(cluster *appv1.Cluster) bool
199200
resourceTracking argo.ResourceTracking
201+
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
200202

201203
clusters map[string]clustercache.ClusterCache
202204
cacheSettings cacheSettings
@@ -473,7 +475,7 @@ func (c *liveStateCache) getCluster(server string) (clustercache.ClusterCache, e
473475
gvk := un.GroupVersionKind()
474476

475477
if cacheSettings.ignoreResourceUpdatesEnabled && shouldHashManifest(appName, gvk) {
476-
hash, err := generateManifestHash(un, nil, cacheSettings.resourceOverrides)
478+
hash, err := generateManifestHash(un, nil, cacheSettings.resourceOverrides, c.ignoreNormalizerOpts)
477479
if err != nil {
478480
log.Errorf("Failed to generate manifest hash: %v", err)
479481
} else {

controller/cache/info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,8 @@ func populateHostNodeInfo(un *unstructured.Unstructured, res *ResourceInfo) {
390390
}
391391
}
392392

393-
func generateManifestHash(un *unstructured.Unstructured, ignores []v1alpha1.ResourceIgnoreDifferences, overrides map[string]v1alpha1.ResourceOverride) (string, error) {
394-
normalizer, err := normalizers.NewIgnoreNormalizer(ignores, overrides)
393+
func generateManifestHash(un *unstructured.Unstructured, ignores []v1alpha1.ResourceIgnoreDifferences, overrides map[string]v1alpha1.ResourceOverride, opts normalizers.IgnoreNormalizerOpts) (string, error) {
394+
normalizer, err := normalizers.NewIgnoreNormalizer(ignores, overrides, opts)
395395
if err != nil {
396396
return "", fmt.Errorf("error creating normalizer: %w", err)
397397
}

0 commit comments

Comments
 (0)