Skip to content

Commit 03ebfc7

Browse files
authored
docs: improve javadoc for ResourceOperation on resource cloning and matching (#3502)
Add java doc remark that the desired resource has to be clone (or fresh instance created) in order to have the maching work correctly Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent 7afafad commit 03ebfc7

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/ResourceOperations.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@
9999
* from the desired one, thus also reducing the number of requests made against the Kubernetes API
100100
* server.
101101
*
102+
* <p><strong>Matching against cached resources.</strong> When matching the actual resource (in most
103+
* cases read from the cache) against the desired one for secondary resources, the matching must be
104+
* done on a <em>cloned</em> version of the actual resource. Secondary resources are not cloned by
105+
* default when read from the cache (see {@link
106+
* io.javaoperatorsdk.operator.api.config.ConfigurationService#cloneSecondaryResourcesWhenGettingFromCache()}),
107+
* so mutating the resource obtained from the cache while matching would also mutate the copy stored
108+
* in the cache. Either clone the resource explicitly before matching, or enable {@link
109+
* io.javaoperatorsdk.operator.api.config.ConfigurationService#cloneSecondaryResourcesWhenGettingFromCache()}.
110+
*
102111
* @param <P> the primary resource type on which this object operates
103112
*/
104113
public class ResourceOperations<P extends HasMetadata> {

0 commit comments

Comments
 (0)