Commit 23723d9
feat: Add sync phases and waves customizability (#537)
* move `asJSON` to utils and rename to `UnstructuredAsJSON`
* add `SyncWaveAnnotation` for resource ordering
* add `GetSyncWave` function for handling `SyncWaveAnnotation`
* move and integrate the default wave logic into the `GetSyncWave` function for resource ordering
* remove unused `GetLastProgressTimestamp` function and cleanup imports in `common.go`
* remove unused `ServiceID` function and cleanup imports in `common.go`
* add `SyncPhase` constants and `GetSyncPhase` function for handling resource apply phases
* move `const.go` contents to `annotations.go` for better file organization
* integrate wave construction into `Phase` and improve resource synchronization handling
* add skipped resource tracking and integrate skip/delete filters into phase construction
* remove `CacheFilter` from applier initialization in service reconciler
* add `WithFilter` to applier initialization in service reconciler
* commit work in progress
* feat(phase): add support for phased resource application and enhanced health evaluation
* rename `kindToDefaultSyncWave` to `kindSyncPriorities` and replace `lastDefaultWave` with `defaultSyncPriority`
* fix `DeletedCount` to use `deleteWave.Len` instead of the last wave length
* improve phase management by adding `HasWaves` method, ensuring phase initialization, and refactoring `Next` logic for better clarity
* add `sync_phase` tracking in database schema, queries, and data structures
* replace base32 with base64 for hash encoding in `utils` package to optimize output format
* add check to skip insert query execution if no values are provided in `db_store`
* feat(applier): improve logging, enhance resource filtering, and refine phase application logic
* replace `AreResourcesHealthy` with `GetResourceHealth` to improve health status tracking and error handling across store and applier components
* improve logging in `applier` to provide better visibility into phase health and failure handling
* revise `GetResourceHealth` test cases to ensure accurate tracking of pending and failed states
* fix unit tests
* fix unit tests
* add initial version of resource check function
* add tests for `HasSomeResources` to validate handling of different resource scenarios and edge cases
* feat(annotations): add Helm hook annotations and extend sync phase definitions
* handle Helm hooks
* update `defaultPhase` to accept annotations map directly instead of unstructured type
* implement `HelmFilter` to handle resource application logic based on Helm hook annotations during installs and upgrades
* fix(tests): correct resource references in db_store_test to align with updated test scenarios
* feat(sync-wave): add Helm hook weight support and enhance default sync wave determination based on resource kind
* add service warnings
* add manifest table
* add manifests query
* rename entry to component
* add SaveManifests and GetManifests functions to handle storing and retrieving service-applied manifests
* rename `component` to `manifest` in insert statement and adjust field mappings in query
* add tests for SaveManifests and GetManifests to validate manifest storage and retrieval behavior
* update docs
* add GetPhaseHookDeletePolicy function to retrieve sync phase hook delete policy from annotations
* rename manifest storage to cleanup candidates and update related functions, queries, and tests
* replace direct schema initialization with GroupVersionKind method and refactor associated code
* refactor ToUnstructured logic into Component and update usage in applier to streamline resource conversion
* simplify resource existence check in applier by combining variable declaration and conditional
* simplify resource filtering by inverting conditional check to reduce nesting
* add UID field to cleanup candidate and update related queries and functions to handle unique resource identification
* replace `NewStoreKeyFromEntry` with `ToStoreKey` method in `Component` and `CleanupCandidate`, and refactor related logic for consistency and clarity
* refactor phase deletion logic to filter resources by sync phase directly in NewPhase for improved clarity and alignment with existing patterns
* rename cleanup candidates to processed hook components and update associated methods, queries, and tests for enhanced semantic clarity
* add status field to processed hook component and update queries, functions, and conflict resolution logic to manage and persist component state
* add ExpireProcessedHookComponents method to DatabaseStore and store interface to enable removal of processed hook components by service ID
* call ExpireProcessedHookComponents during service reconciliation to remove processed components and ensure consistency
* refactor SyncPhaseHookDeletePolicy handling to use switch-case for improved clarity and extensibility
* extend processed hook component logic with status-based handling and update related applier logic for resource filtering and deletion
* improve comment clarity in applier logic for resource deletion policies
* remove unnecessary comment in SetAnnotations call for streamlined code readability
* simplify applier logic by consolidating deletion policy checks and optimizing resource filtering and deletion handling
* clarify error log message in component saving logic to improve debugging
* refactor processed hook component saving logic to optimize checks, simplify queries, and enhance error handling
* extend processed hook component saving logic with status-based delete policy checks and update related error handling
* clarify log messages in processed hook saving logic for improved traceability and debugging
* extend `maybeSaveProcessedHookComponent` with state and serviceID parameters to refine delete policy checks and enhance logging accuracy
* refactor delete policy checks by introducing `HasStateDesiredByDeletePolicy` helper function and simplifying conditional logic in `maybeSaveProcessedHookComponent`
* fix import cycle
* refactor `maybeSaveProcessedHookComponent` to accept database connection as a parameter, removing redundant connection handling logic
* introduce `maybeSaveProcessedHookComponents` to handle bulk saving of processed hook components, replacing outdated TODO and improving logic readability
* remove redundant and outdated test cases for resource health and existence checks, replace with streamlined `createHookJob` utility, and refactor `TestComponentCache_ProcessedHookComponents`
* add comprehensive test cases for `GetProcessedHookComponents` to validate behavior with isolation, resource types, UIDs, and large datasets
* fix lint
* update pull request template
* support helm.sh/hook-delete-policy
* bump gql client v1.51.3
* optimize `maybeSaveProcessedHookComponents` by reducing redundant string operations and improving clarity with pre-allocated slice for value assembly
* replace fallthrough with explicit return for SyncPhaseSync in annotations
* replace fallthrough with call to defaultPhase in annotations
* recreate hooks if their manifest change
* fix cyclic dependency
* update comment
* mark service as failed only if it has errors, not warnings
* refactor
* do not sleep after last wave
* refactor
* fix query
* reformat
* fix manifest sha handling
* refactor SaveHookComponentWithManifestSHA signature and update call sites
* fix manifest sha handling
* add required checks
* support multiple phases
* fix multiple phases support
* add tests for phase recognition
* fix tests for phase recognition
* add tests for wave recognition
* fix delete filtering
* update comment
* update comment
* rename methods for consistency
* remove unused NewKeyFromEntry function
* rename methods and variables for consistency
* do not ignore helm hooks by default
* remove duplicated check
* replace `GetPhaseHookDeletePolicy` with `HasSyncPhaseHookDeletePolicy` for clarity and improve readability
* handle multiple delete policies
* support argo sync wave annotation
* skip applying hook resource if their manifest did not change
* reformat
* fix linter
* add continue
* fix multi-phase resource deletion
* fix for trivy
* fix import cycle
* fix import cycle
* improve logging
* fix install/upgrade bug
* fix install/upgrade bug
---------
Co-authored-by: Sebastian Florek <[email protected]>
Co-authored-by: Lukasz Zajaczkowski <[email protected]>1 parent 36d6db3 commit 23723d9
File tree
32 files changed
+1965
-443
lines changed- .github
- internal
- controller
- utils
- pkg
- common
- controller/service
- manifests/template
- streamline
- applier
- common
- store
32 files changed
+1965
-443
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | | - | |
10 | | - | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | | - | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
21 | 49 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | 55 | | |
71 | 56 | | |
72 | 57 | | |
| |||
228 | 213 | | |
229 | 214 | | |
230 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | | - | |
9 | 7 | | |
10 | 8 | | |
11 | | - | |
12 | 9 | | |
13 | 10 | | |
14 | 11 | | |
15 | | - | |
16 | | - | |
17 | 12 | | |
18 | 13 | | |
19 | 14 | | |
20 | | - | |
21 | | - | |
22 | | - | |
| 15 | + | |
| 16 | + | |
23 | 17 | | |
24 | 18 | | |
25 | 19 | | |
| |||
53 | 47 | | |
54 | 48 | | |
55 | 49 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | 50 | | |
99 | 51 | | |
100 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
138 | 142 | | |
139 | 143 | | |
140 | 144 | | |
| |||
429 | 433 | | |
430 | 434 | | |
431 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
432 | 441 | | |
433 | 442 | | |
434 | 443 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
0 commit comments