Commit da3916d
committed
feat: support multiple update modes for resource operations (#3491)
Rework ResourceOperations into the primary API for create/update/patch
calls, giving explicit control over read-after-write cache consistency
and own-event filtering via an Options/Mode strategy plus a pluggable
Matcher framework.
Own-event filtering was previously implicit and could silently swallow
concurrent third-party writes. Options now make the tradeoff explicit
per call:
- matchAndFilter / matchAndFilterWithDefaultMatcher (default): compare
desired vs. cached state, skip the write if it already matches,
otherwise write and filter the own event.
- filterWithOptimisticLocking: filter the own event but require
optimistic locking so concurrent changes are rejected server-side
instead of silently dropped.
- cacheOnly: update the cache only, no event filtering.
- forceFilterEvents: always filter (internal use; requires correctness
guaranteed elsewhere).
Add a Matcher framework with default matchers per UpdateType (UPDATE,
SSA, JSON_PATCH, JSON_MERGE_PATCH, and their *_STATUS variants), backed
by MatcherUtils, plus GenericKubernetesResourceMatcher.matchStatus for
status-subtree comparisons.
Framework integration:
- ReconciliationDispatcher adds the finalizer with cacheOnly instead of
filter + INSTANT_RESCHEDULE, so the finalizer-add event itself drives
the next reconcile.
- Primary UpdateControl writes use cacheOnly, trading an extra
self-triggered reconcile for correctness (a concurrent spec change
during a status patch can no longer be silently absorbed).
- KubernetesDependentResource create/SSA use forceFilterEvents.
- AbstractExternalDependentResource persists state through
resourceOperations().create(...).
Add ITs covering the concurrency and read-after-write edge cases
(ResourceOperationsIT, SecondaryResourceOperationsIT,
SpecChangeDuringStatusPatchIT, OwnSsaStatusUpdateIT) and update docs
(reconciler.md, v5-5-migration.md, v5-5-release.md, read-after-write
blog post).
The Options API is marked @experimental; default matchers are
heuristics, so reconcilers should test them against concrete resources
or supply a custom Matcher.
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>1 parent 542e8d9 commit da3916d
53 files changed
Lines changed: 3566 additions & 347 deletions
File tree
- .github/workflows
- docs/content/en
- blog/news
- docs
- documentation
- migration
- operator-framework-core/src
- main/java/io/javaoperatorsdk/operator
- api/reconciler
- matcher
- processing
- dependent
- kubernetes
- event
- source/informer
- matcher
- test/java/io/javaoperatorsdk/operator
- api/reconciler
- processing
- dependent/kubernetes
- event
- source/informer
- matcher
- operator-framework/src/test/java/io/javaoperatorsdk/operator
- baseapi
- changenamespace
- latestdistinct
- manualobservedgeneration
- readcacheafterwrite
- filterpatchevent
- onrelistfilter
- ownsecondaryupdate
- ownssastatusupdate
- specchangeduringstatuspatch
- resourceoperations
- simple
- subresource
- workflow/workflowmultipleactivation
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
Lines changed: 26 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | 183 | | |
190 | 184 | | |
191 | 185 | | |
| |||
226 | 220 | | |
227 | 221 | | |
228 | 222 | | |
229 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
230 | 245 | | |
231 | | - | |
232 | | - | |
| 246 | + | |
| 247 | + | |
233 | 248 | | |
234 | 249 | | |
235 | 250 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
195 | 231 | | |
196 | 232 | | |
197 | 233 | | |
| |||
208 | 244 | | |
209 | 245 | | |
210 | 246 | | |
211 | | - | |
212 | | - | |
| 247 | + | |
213 | 248 | | |
214 | 249 | | |
215 | 250 | | |
216 | 251 | | |
217 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
218 | 260 | | |
219 | 261 | | |
220 | 262 | | |
221 | 263 | | |
222 | 264 | | |
223 | 265 | | |
224 | | - | |
| 266 | + | |
225 | 267 | | |
226 | 268 | | |
227 | 269 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 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 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
0 commit comments