|
| 1 | +# Multi Version Custom Resources Deserialization Problem |
| 2 | + |
| 3 | +## Status |
| 4 | + |
| 5 | +accepted |
| 6 | + |
| 7 | +## Context |
| 8 | + |
| 9 | +In case there are multiple versions of a custom resource it can happen that a controller/informer tracking |
| 10 | +such a resource might run into deserialization problem as shown |
| 11 | +in [this integration test](https://github.com/java-operator-sdk/java-operator-sdk/blob/07aab1a9914d865364d7236e496ef9ba5b50699e/operator-framework/src/test/java/io/javaoperatorsdk/operator/MultiVersionCRDIT.java#L55-L55) |
| 12 | +. |
| 13 | +Such case is possible (as seen in the test) if there are no conversion hooks in place, so the two custom resources |
| 14 | +which have different version are stored in the original form (not converted) and are not compatible. |
| 15 | +In this case, if there is no further filtering (by labels) informer receives both, but naturally not able to deserialize |
| 16 | +one of them. |
| 17 | + |
| 18 | +How should the framework or the underlying informer behave? |
| 19 | + |
| 20 | +Alternatives: |
| 21 | + |
| 22 | +1. The informer should skip the resource and should continue to process the resources with the correct version. |
| 23 | +2. Informer stops and makes a notification callback. |
| 24 | + |
| 25 | +## Decision |
| 26 | + |
| 27 | +From the JOSDK perspective, it is fine if the informer stops, and the users decides if the whole operator should stop |
| 28 | +(usually the preferred way). The reason, that this is an obvious issue on platform level (not on operator/controller |
| 29 | +level). Thus, the controller should not receive such custom resources in the first place, so the problem should be |
| 30 | +addressed at the platform level. Possibly introducing conversion hooks, or labeling for the target resource. |
| 31 | + |
| 32 | +## Consequences |
| 33 | + |
| 34 | +If an Informer stops on such deserialization error, even explicitly restarting it won't solve the problem, since |
| 35 | +would fail again on the same error. |
| 36 | + |
| 37 | +## Notes |
| 38 | + |
| 39 | +- The informer implementation in fabric8 client changed in this regard, before it was not stopping on deserialization |
| 40 | + error, but as described this change in behavior is completely acceptable. |
| 41 | + |
| 42 | +- the deserializer can be set to be more lenient by configuring the Serialization Unmatched Field Type module: |
| 43 | + `Serialization.UNMATCHED_FIELD_TYPE_MODULE.setRestrictToTemplates(true);`. In general is not desired to |
| 44 | + process custom resources that are not deserialized correctly. |
0 commit comments