Skip to content

Commit

Permalink
add: e2e and docs for force sync options
Browse files Browse the repository at this point in the history
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
  • Loading branch information
kkk777-7 committed Apr 17, 2024
1 parent 5908c11 commit 3027116
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/user-guide/sync-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions test/e2e/sync_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,30 @@ 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 only having `Replace=true` annotation should not sync if change in immutable field
When().
PatchFile("guestbook-ui-deployment.yaml", `[{ "op": "add", "path": "/metadata/annotations", "value": { "argocd.argoproj.io/sync-options": "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(SyncStatusCodeOutOfSync)).
// app having `Replace=true` and `Force=true` annotation should sync if change in immutable field
When().
TerminateOp().
PatchFile("guestbook-ui-deployment.yaml", `[{ "op": "replace", "path": "/metadata/annotations", "value": { "argocd.argoproj.io/sync-options": "Force=true,Replace=true" }}]`).
Refresh(RefreshTypeNormal).
Sync().
Then().
Expect(SyncStatusIs(SyncStatusCodeSynced))
}

0 comments on commit 3027116

Please sign in to comment.