@@ -131,7 +131,7 @@ public static <P extends HasMetadata> P ssaPatchAndCacheStatus(
131
131
*/
132
132
public static <P extends HasMetadata > P ssaPatchAndCacheStatus (
133
133
P primary , P freshResourceWithStatus , Context <P > context , PrimaryResourceCache <P > cache ) {
134
- sanityChecks (freshResourceWithStatus , context );
134
+ logWarnIfResourceVersionPresent (freshResourceWithStatus );
135
135
return patchAndCacheStatus (
136
136
primary ,
137
137
cache ,
@@ -159,7 +159,7 @@ public static <P extends HasMetadata> P ssaPatchAndCacheStatus(
159
159
*/
160
160
public static <P extends HasMetadata > P editAndCacheStatus (
161
161
P primary , Context <P > context , PrimaryResourceCache <P > cache , UnaryOperator <P > operation ) {
162
- sanityChecks (primary , context );
162
+ logWarnIfResourceVersionPresent (primary );
163
163
return patchAndCacheStatus (
164
164
primary , cache , () -> context .getClient ().resource (primary ).editStatus (operation ));
165
165
}
@@ -176,7 +176,7 @@ public static <P extends HasMetadata> P editAndCacheStatus(
176
176
*/
177
177
public static <P extends HasMetadata > P patchAndCacheStatus (
178
178
P primary , Context <P > context , PrimaryResourceCache <P > cache ) {
179
- sanityChecks (primary , context );
179
+ logWarnIfResourceVersionPresent (primary );
180
180
return patchAndCacheStatus (
181
181
primary , cache , () -> context .getClient ().resource (primary ).patchStatus ());
182
182
}
@@ -192,7 +192,7 @@ public static <P extends HasMetadata> P patchAndCacheStatus(
192
192
*/
193
193
public static <P extends HasMetadata > P updateAndCacheStatus (
194
194
P primary , Context <P > context , PrimaryResourceCache <P > cache ) {
195
- sanityChecks (primary , context );
195
+ logWarnIfResourceVersionPresent (primary );
196
196
return patchAndCacheStatus (
197
197
primary , cache , () -> context .getClient ().resource (primary ).updateStatus ());
198
198
}
@@ -213,12 +213,16 @@ public static <P extends HasMetadata> P patchAndCacheStatus(
213
213
return updatedResource ;
214
214
}
215
215
216
- private static <P extends HasMetadata > void sanityChecks (P primary , Context < P > context ) {
216
+ private static <P extends HasMetadata > void logWarnIfResourceVersionPresent (P primary ) {
217
217
if (primary .getMetadata ().getResourceVersion () != null ) {
218
218
log .warn (
219
219
"The metadata.resourceVersion of primary resource is NOT null, "
220
220
+ "using optimistic locking is discouraged for this purpose. " );
221
221
}
222
+ }
223
+
224
+ private static <P extends HasMetadata > void sanityChecks (P primary , Context <P > context ) {
225
+ logWarnIfResourceVersionPresent (primary );
222
226
if (!context
223
227
.getControllerConfiguration ()
224
228
.getConfigurationService ()
0 commit comments