From 5908c11e2f1b75c8d8f656ed76ba6bb52a029e96 Mon Sep 17 00:00:00 2001 From: kkk777-7 Date: Wed, 17 Apr 2024 01:35:51 +0900 Subject: [PATCH 1/3] chore: update gitops engine version Signed-off-by: kkk777-7 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 45978fcce9ecd..e552779401875 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/TomOnTime/utfutil v0.0.0-20180511104225-09c41003ee1d github.com/alicebob/miniredis/v2 v2.30.4 github.com/antonmedv/expr v1.15.2 - github.com/argoproj/gitops-engine v0.7.1-0.20240124052710-5fd9f449e757 + github.com/argoproj/gitops-engine v0.7.1-0.20240416142647-fbecbb86e412 github.com/argoproj/notifications-engine v0.4.1-0.20240206192038-2daee6022f41 github.com/argoproj/pkg v0.13.7-0.20230626144333-d56162821bd1 github.com/aws/aws-sdk-go v1.50.8 diff --git a/go.sum b/go.sum index c2a6a79caf2dc..2660cbda83f21 100644 --- a/go.sum +++ b/go.sum @@ -694,8 +694,8 @@ github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= github.com/appscode/go v0.0.0-20191119085241-0887d8ec2ecc/go.mod h1:OawnOmAL4ZX3YaPdN+8HTNwBveT1jMsqP74moa9XUbE= -github.com/argoproj/gitops-engine v0.7.1-0.20240124052710-5fd9f449e757 h1:5fKAhTQcTBom0vin56cz/UTPx2GMuvdb+lJRAUOPbHA= -github.com/argoproj/gitops-engine v0.7.1-0.20240124052710-5fd9f449e757/go.mod h1:gWE8uROi7hIkWGNAVM+8FWkMfo0vZ03SLx/aFw/DBzg= +github.com/argoproj/gitops-engine v0.7.1-0.20240416142647-fbecbb86e412 h1:je2wJpWtaoS55mA5MBPCeDnKMeF42pkxO9Oa5KbWrdg= +github.com/argoproj/gitops-engine v0.7.1-0.20240416142647-fbecbb86e412/go.mod h1:gWE8uROi7hIkWGNAVM+8FWkMfo0vZ03SLx/aFw/DBzg= github.com/argoproj/notifications-engine v0.4.1-0.20240206192038-2daee6022f41 h1:PQE8LbcbRHdtnQzeEWwVU2QHXACKOA30yS3No5HSoTQ= github.com/argoproj/notifications-engine v0.4.1-0.20240206192038-2daee6022f41/go.mod h1:TsyusmXQWIL0ST7YMRG/ered7WlWDmbmnPpXnS2LJmM= github.com/argoproj/pkg v0.13.7-0.20230626144333-d56162821bd1 h1:qsHwwOJ21K2Ao0xPju1sNuqphyMnMYkyB3ZLoLtxWpo= From 13fb5a945a889ae21fad208070138684150c86b0 Mon Sep 17 00:00:00 2001 From: kkk777-7 Date: Wed, 17 Apr 2024 16:09:20 +0900 Subject: [PATCH 2/3] add: e2e and docs for force sync options Signed-off-by: kkk777-7 --- docs/user-guide/sync-options.md | 11 +++++++++++ test/e2e/sync_options_test.go | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/docs/user-guide/sync-options.md b/docs/user-guide/sync-options.md index a563821967d04..74a694ceadb8d 100644 --- a/docs/user-guide/sync-options.md +++ b/docs/user-guide/sync-options.md @@ -165,6 +165,17 @@ metadata: argocd.argoproj.io/sync-options: Replace=true ``` +## Force Sync + +For certain resources you might want to delete and recreate. e.g. job resources that should run every time when syncing. +In such cases you might use `Force=true` sync option in target resources annotation: + +```yaml +metadata: + annotations: + argocd.argoproj.io/sync-options: Force=true,Replace=true +``` + ## Server-Side Apply This option enables Kubernetes diff --git a/test/e2e/sync_options_test.go b/test/e2e/sync_options_test.go index 3eb7140787097..b5dc685e76c13 100644 --- a/test/e2e/sync_options_test.go +++ b/test/e2e/sync_options_test.go @@ -127,3 +127,22 @@ func TestSyncWithSkipHook(t *testing.T) { Then(). Expect(SyncStatusIs(SyncStatusCodeOutOfSync)) } + +func TestSyncWithForceReplace(t *testing.T) { + Given(t). + Path(guestbookPath). + When(). + CreateApp(). + Sync(). + Then(). + Expect(SyncStatusIs(SyncStatusCodeSynced)). + // app having `Replace=true` and `Force=true` annotation should sync succeed if change in immutable field + When(). + PatchFile("guestbook-ui-deployment.yaml", `[{ "op": "add", "path": "/metadata/annotations", "value": { "argocd.argoproj.io/sync-options": "Force=true,Replace=true" }}]`). + PatchFile("guestbook-ui-deployment.yaml", `[{ "op": "add", "path": "/spec/selector/matchLabels/env", "value": "e2e" }, { "op": "add", "path": "/spec/template/metadata/labels/env", "value": "e2e" }]`). + PatchFile("guestbook-ui-deployment.yaml", `[{ "op": "replace", "path": "/spec/replicas", "value": 1 }]`). + Refresh(RefreshTypeNormal). + Sync(). + Then(). + Expect(SyncStatusIs(SyncStatusCodeSynced)) +} From b59300c8fa3641bd9612d5845e4b12d15fd380bb Mon Sep 17 00:00:00 2001 From: kkk777-7 Date: Thu, 18 Apr 2024 00:26:43 +0900 Subject: [PATCH 3/3] docs: Add warning description of force sync options Signed-off-by: kkk777-7 --- docs/user-guide/sync-options.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/user-guide/sync-options.md b/docs/user-guide/sync-options.md index 74a694ceadb8d..99f5eba6b85de 100644 --- a/docs/user-guide/sync-options.md +++ b/docs/user-guide/sync-options.md @@ -168,8 +168,12 @@ metadata: ## Force Sync For certain resources you might want to delete and recreate. e.g. job resources that should run every time when syncing. -In such cases you might use `Force=true` sync option in target resources annotation: +!!! warning + During the sync process, the resources will be synchronized using the 'kubectl delete/create' command. + This sync option has a destructive action, which could cause an outage for your application. + +In such cases you might use `Force=true` sync option in target resources annotation: ```yaml metadata: annotations: