diff --git a/controller/state.go b/controller/state.go index 1443ffb11e345..db3779e3566e7 100644 --- a/controller/state.go +++ b/controller/state.go @@ -88,7 +88,8 @@ type comparisonResult struct { diffNormalizer diff.Normalizer appSourceType v1alpha1.ApplicationSourceType // timings maps phases of comparison to the duration it took to complete (for statistical purposes) - timings map[string]time.Duration + timings map[string]time.Duration + diffResultList *diff.DiffResultList } func (res *comparisonResult) GetSyncStatus() *v1alpha1.SyncStatus { @@ -632,6 +633,7 @@ func (m *appStateManager) CompareAppState(app *v1alpha1.Application, project *ap managedResources: managedResources, reconciliationResult: reconciliation, diffNormalizer: diffNormalizer, + diffResultList: diffResults, } if manifestInfo != nil { compRes.appSourceType = v1alpha1.ApplicationSourceType(manifestInfo.SourceType) diff --git a/controller/sync.go b/controller/sync.go index 33643b1e57c1c..6f975eda55634 100644 --- a/controller/sync.go +++ b/controller/sync.go @@ -135,6 +135,7 @@ func (m *appStateManager) SyncAppState(app *v1alpha1.Application, state *v1alpha Order: i + 1, }) } + syncCtx, err := sync.NewSyncContext( compareResult.syncStatus.Revision, compareResult.reconciliationResult, @@ -168,6 +169,7 @@ func (m *appStateManager) SyncAppState(app *v1alpha1.Application, state *v1alpha }), sync.WithSyncWaveHook(delayBetweenSyncWaves), sync.WithPruneLast(syncOp.SyncOptions.HasOption("PruneLast=true")), + sync.WithResourceModificationChecker(syncOp.SyncOptions.HasOption("ApplyOutOfSyncOnly=true"), compareResult.diffResultList), ) if err != nil { diff --git a/docs/user-guide/selective_sync.md b/docs/user-guide/selective_sync.md index 9e993cf285ad7..d607cc636b1a1 100644 --- a/docs/user-guide/selective_sync.md +++ b/docs/user-guide/selective_sync.md @@ -7,4 +7,11 @@ A *selective sync* is one where only some resources are sync'd. You can choose w When doing so, bear in mind: * Your sync is not recorded in the history, and so rollback is not possible. -* Hooks are not run. \ No newline at end of file +* Hooks are not run. + +## Selective Sync Option + +>v1.8 + +Turning on selective sync option which will sync only out-of-sync resources. +See [sync options](sync-options.md#selective-sync) documentation for more details. diff --git a/docs/user-guide/sync-options.md b/docs/user-guide/sync-options.md index 45c5ddc1300f3..498dff31a2ffb 100644 --- a/docs/user-guide/sync-options.md +++ b/docs/user-guide/sync-options.md @@ -57,3 +57,31 @@ metadata: ``` The dry run will still be executed if the CRD is already present in the cluster. + +## Selective Sync + +>v1.8 + +Currently when syncing using auto sync ArgoCD applies every object in the application. +For applications containing thousands of objects this takes quite a long time and puts undue pressure on the api server. +Turning on selective sync option which will sync only out-of-sync resources. + +You can add this option by following ways + +1) Add `ApplyOutOfSync=true` in manifest + +Example: + +```yaml +syncPolicy: + syncOptions: + - ApplyOutOfSyncOnly=true +``` + +2) Set sync option via argocd cli + +Example: + +```bash +$ argocd app set guestbook --sync-option ApplyOutOfSyncOnly=true +``` \ No newline at end of file diff --git a/go.mod b/go.mod index c349d8c014ab4..2c26870053106 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/TomOnTime/utfutil v0.0.0-20180511104225-09c41003ee1d github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6 // indirect github.com/alicebob/miniredis v2.5.0+incompatible - github.com/argoproj/gitops-engine v0.2.1-0.20210112204306-814d79df4954 + github.com/argoproj/gitops-engine v0.2.1-0.20210129183711-c5b7114c501f github.com/argoproj/pkg v0.2.0 github.com/bombsimon/logrusr v1.0.0 github.com/casbin/casbin v1.9.1 diff --git a/go.sum b/go.sum index de04304522124..a973f44b32e0a 100644 --- a/go.sum +++ b/go.sum @@ -86,8 +86,8 @@ github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/argoproj/gitops-engine v0.2.1-0.20210112204306-814d79df4954 h1:IJSkAuhE4DrLDJmGPa0eGCK20gjCQokkjk2Il7Pd/Sw= -github.com/argoproj/gitops-engine v0.2.1-0.20210112204306-814d79df4954/go.mod h1:dmGvluybnmaSzsJA7PnrgCoSYQ5stFUNqS46F3gma+M= +github.com/argoproj/gitops-engine v0.2.1-0.20210129183711-c5b7114c501f h1:QAf9m8jTw9TqRRNSBtygvZrrxWWUtF1F0qtVPrFogF8= +github.com/argoproj/gitops-engine v0.2.1-0.20210129183711-c5b7114c501f/go.mod h1:dmGvluybnmaSzsJA7PnrgCoSYQ5stFUNqS46F3gma+M= github.com/argoproj/pkg v0.2.0 h1:ETgC600kr8WcAi3MEVY5sA1H7H/u1/IysYOobwsZ8No= github.com/argoproj/pkg v0.2.0/go.mod h1:F4TZgInLUEjzsWFB/BTJBsewoEy0ucnKSq6vmQiD/yc= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=