Skip to content

Commit 68ca625

Browse files
committed
remove with lock versions
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent 3409053 commit 68ca625

File tree

11 files changed

+5
-266
lines changed

11 files changed

+5
-266
lines changed

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

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -11,112 +11,13 @@
1111
import io.fabric8.kubernetes.client.dsl.base.PatchContext;
1212
import io.fabric8.kubernetes.client.dsl.base.PatchType;
1313
import io.javaoperatorsdk.operator.api.reconciler.support.PrimaryResourceCache;
14-
import io.javaoperatorsdk.operator.processing.event.ResourceID;
1514

1615
public class PrimaryUpdateAndCacheUtils {
1716

1817
private PrimaryUpdateAndCacheUtils() {}
1918

2019
private static final Logger log = LoggerFactory.getLogger(PrimaryUpdateAndCacheUtils.class);
2120

22-
/**
23-
* Makes sure that the up-to-date primary resource will be present during the next reconciliation.
24-
* Using update (PUT) method.
25-
*
26-
* @param primary resource
27-
* @param context of reconciliation
28-
* @return updated resource
29-
* @param <P> primary resource type
30-
*/
31-
public static <P extends HasMetadata> P updateAndCacheStatusWithLock(
32-
P primary, Context<P> context) {
33-
return patchAndCacheStatusWithLock(
34-
primary, context, (p, c) -> c.resource(primary).updateStatus());
35-
}
36-
37-
/**
38-
* Makes sure that the up-to-date primary resource will be present during the next reconciliation.
39-
* Using JSON Merge patch.
40-
*
41-
* @param primary resource
42-
* @param context of reconciliation
43-
* @return updated resource
44-
* @param <P> primary resource type
45-
*/
46-
public static <P extends HasMetadata> P patchAndCacheStatusWithLock(
47-
P primary, Context<P> context) {
48-
return patchAndCacheStatusWithLock(
49-
primary, context, (p, c) -> c.resource(primary).patchStatus());
50-
}
51-
52-
/**
53-
* Makes sure that the up-to-date primary resource will be present during the next reconciliation.
54-
* Using JSON Patch.
55-
*
56-
* @param primary resource
57-
* @param context of reconciliation
58-
* @return updated resource
59-
* @param <P> primary resource type
60-
*/
61-
public static <P extends HasMetadata> P editAndCacheStatusWithLock(
62-
P primary, Context<P> context, UnaryOperator<P> operation) {
63-
return patchAndCacheStatusWithLock(
64-
primary, context, (p, c) -> c.resource(primary).editStatus(operation));
65-
}
66-
67-
/**
68-
* Makes sure that the up-to-date primary resource will be present during the next reconciliation.
69-
*
70-
* @param primary resource
71-
* @param context of reconciliation
72-
* @param patch free implementation of cache - make sure you use optimistic locking during the
73-
* update
74-
* @return the updated resource.
75-
* @param <P> primary resource type
76-
*/
77-
public static <P extends HasMetadata> P patchAndCacheStatusWithLock(
78-
P primary, Context<P> context, BiFunction<P, KubernetesClient, P> patch) {
79-
checkResourceVersionPresent(primary);
80-
var updatedResource = patch.apply(primary, context.getClient());
81-
context
82-
.eventSourceRetriever()
83-
.getControllerEventSource()
84-
.handleRecentResourceUpdate(ResourceID.fromResource(primary), updatedResource, primary);
85-
return updatedResource;
86-
}
87-
88-
/**
89-
* Makes sure that the up-to-date primary resource will be present during the next reconciliation.
90-
* Using Server Side Apply.
91-
*
92-
* @param primary resource
93-
* @param freshResourceWithStatus - fresh resource with target state
94-
* @param context of reconciliation
95-
* @return the updated resource.
96-
* @param <P> primary resource type
97-
*/
98-
public static <P extends HasMetadata> P ssaPatchAndCacheStatusWithLock(
99-
P primary, P freshResourceWithStatus, Context<P> context) {
100-
checkResourceVersionPresent(freshResourceWithStatus);
101-
var res =
102-
context
103-
.getClient()
104-
.resource(freshResourceWithStatus)
105-
.subresource("status")
106-
.patch(
107-
new PatchContext.Builder()
108-
.withForce(true)
109-
.withFieldManager(context.getControllerConfiguration().fieldManager())
110-
.withPatchType(PatchType.SERVER_SIDE_APPLY)
111-
.build());
112-
113-
context
114-
.eventSourceRetriever()
115-
.getControllerEventSource()
116-
.handleRecentResourceUpdate(ResourceID.fromResource(primary), res, primary);
117-
return res;
118-
}
119-
12021
/**
12122
* Patches the resource and adds it to the {@link PrimaryResourceCache} provided. Optimistic
12223
* locking is not required.

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/primarycache/StatusPatchPrimaryCacheCustomResource.java renamed to operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/StatusPatchPrimaryCacheCustomResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.javaoperatorsdk.operator.baseapi.statuscache.primarycache;
1+
package io.javaoperatorsdk.operator.baseapi.statuscache;
22

33
import io.fabric8.kubernetes.api.model.Namespaced;
44
import io.fabric8.kubernetes.client.CustomResource;

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/primarycache/StatusPatchPrimaryCacheIT.java renamed to operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/StatusPatchPrimaryCacheIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.javaoperatorsdk.operator.baseapi.statuscache.primarycache;
1+
package io.javaoperatorsdk.operator.baseapi.statuscache;
22

33
import java.time.Duration;
44

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/primarycache/StatusPatchPrimaryCacheReconciler.java renamed to operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/StatusPatchPrimaryCacheReconciler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.javaoperatorsdk.operator.baseapi.statuscache.primarycache;
1+
package io.javaoperatorsdk.operator.baseapi.statuscache;
22

33
import java.util.List;
44

@@ -12,7 +12,6 @@
1212
import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
1313
import io.javaoperatorsdk.operator.api.reconciler.UpdateControl;
1414
import io.javaoperatorsdk.operator.api.reconciler.support.PrimaryResourceCache;
15-
import io.javaoperatorsdk.operator.baseapi.statuscache.PeriodicTriggerEventSource;
1615
import io.javaoperatorsdk.operator.processing.event.source.EventSource;
1716

1817
@ControllerConfiguration

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/primarycache/StatusPatchPrimaryCacheSpec.java renamed to operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/StatusPatchPrimaryCacheSpec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.javaoperatorsdk.operator.baseapi.statuscache.primarycache;
1+
package io.javaoperatorsdk.operator.baseapi.statuscache;
22

33
public class StatusPatchPrimaryCacheSpec {
44

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/primarycache/StatusPatchPrimaryCacheStatus.java renamed to operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/StatusPatchPrimaryCacheStatus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.javaoperatorsdk.operator.baseapi.statuscache.primarycache;
1+
package io.javaoperatorsdk.operator.baseapi.statuscache;
22

33
public class StatusPatchPrimaryCacheStatus {
44

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/withlock/StatusPatchCacheWithLockCustomResource.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/withlock/StatusPatchCacheWithLockIT.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/withlock/StatusPatchCacheWithLockReconciler.java

Lines changed: 0 additions & 70 deletions
This file was deleted.

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/withlock/StatusPatchCacheWithLockSpec.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)