Commit e786eb5
committed
refactor how the syncagent integrates with multicluster-runtime
Since the mcprovider now watches the APIExportEndpointSlice itself, it does not make sense anymore
to start it dynamically on demand. There is no point in having the syncmanager watch an APIExport or
EndpointSlice itself, since the mcprovider does not take any URLs as input values anymore, it relies
solely on watching the EndpointSlice itself.
To accomodate this, I moved the manager and its provider up into the main(). Since the syncmanager
controller however not just simply starts an mcmanager/provider, but also deals with dynamically
started controllers, I decided to move that behaviour into a new DynamicMultiClusterManager (DMCM).
The DMCM is capable of keeping track of all engaged clusters and allows you to add and start
controllers at any time. It will automatically pre-seed new controller instances with the known
clusters.
There is one downside: Right now, if the controller fails to start, the syncmanager controller will
not notice, re-reconcile and restore it. There's no back channel for that error from the sync
controller's goroutine yet.
---
Since the syncagent by design dynamically fills APIExports with resource schemas, when the DMCM is
started, there are most likely (at least in cold start situations) no resource schemas yet in the
APIExport. Even though the syncmanager waits for the apiresourceschema controller to be done, it
currently does not wait for the apiexport controller to be done (in adding that ResourceSchema to
the APIExport) (there is no condition or anything to tell when that controller has finished).
This means the syncmanager will start new sync controllers at the same time as the apiexport
controller is still filling the APIExport. However when the resources are not present yet, these
sync controllers fail to boot up, and since there is currently no channel to report this back to the
syncmanager, they do not get quickly restarted.
To handle this (it might have been simpler to wait for the APIExport to be ready, but alas... I
realized my oversight too late), I added an explicit API discovery step, where the sync controllers
are only started if and when the primary resource is actually available.
---
One major side effect of this whole refactoring is of course: the agent does not longer support
watching APIExports for their deprecated virtual workspace URLs. When this is merged, you must
provide an APIExportEndpointSlice.
On-behalf-of: @SAP [email protected]1 parent 0dfa0e5 commit e786eb5
File tree
8 files changed
+478
-396
lines changed- cmd/api-syncagent
- internal
- controller
- syncmanager
- sync
- discovery
- kcp
- projection
8 files changed
+478
-396
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | | - | |
40 | | - | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
150 | 165 | | |
151 | 166 | | |
152 | 167 | | |
| |||
177 | 192 | | |
178 | 193 | | |
179 | 194 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
192 | 198 | | |
193 | | - | |
| 199 | + | |
194 | 200 | | |
195 | 201 | | |
196 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| |||
0 commit comments