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 5987b40
Show file tree
Hide file tree
Showing 2 changed files with 36 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
25 changes: 25 additions & 0 deletions test/e2e/sync_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,28 @@ func TestSyncWithSkipHook(t *testing.T) {
Then().
Expect(SyncStatusIs(SyncStatusCodeOutOfSync))
}

func TestSyncWithForceReplace(t *testing.T) {
Given(t).
Path(guestbookPath).
When().
CreateFromFile(func(app *Application) {
app.Spec.SyncPolicy = &SyncPolicy{Automated: &SyncPolicyAutomated{SelfHeal: true}}
}).
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).
Then().
Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
// app having `Replace=true` and `Force=true` annotation should sync if change in immutable field
When().
PatchFile("guestbook-ui-deployment.yaml", `[{ "op": "replace", "path": "/metadata/annotations", "value": { "argocd.argoproj.io/sync-options": "Force=true,Replace=true" }}]`).
Refresh(RefreshTypeNormal).
Then().
Expect(SyncStatusIs(SyncStatusCodeSynced))
}

0 comments on commit 5987b40

Please sign in to comment.