Skip to content

Commit 7152fc8

Browse files
committed
managed fields fix
Signed-off-by: Attila Mészáros <csviri@gmail.com>
1 parent 7ac3317 commit 7152fc8

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.javaoperatorsdk.operator.processing.event;
22

3+
import java.util.Collections;
34
import java.util.function.Function;
45

56
import org.slf4j.Logger;
@@ -424,13 +425,22 @@ public R patchStatus(R resource, R originalResource, Context<?> context) {
424425
originalResource.getMetadata().setResourceVersion(null);
425426
resource.getMetadata().setResourceVersion(null);
426427
try {
427-
var res = resource(originalResource);
428428
if (useSSA) {
429-
return res.subresource("status").patch(new PatchContext.Builder()
430-
.withFieldManager(context.getControllerConfiguration().fieldManager())
431-
.withPatchType(PatchType.SERVER_SIDE_APPLY)
432-
.build());
429+
var managedFields = resource.getMetadata().getManagedFields();
430+
try {
431+
432+
resource.getMetadata().setManagedFields(Collections.emptyList());
433+
var res = resource(resource);
434+
return res.subresource("status").patch(new PatchContext.Builder()
435+
.withFieldManager(context.getControllerConfiguration().fieldManager())
436+
.withForce(true)
437+
.withPatchType(PatchType.SERVER_SIDE_APPLY)
438+
.build());
439+
} finally {
440+
resource.getMetadata().setManagedFields(managedFields);
441+
}
433442
} else {
443+
var res = resource(originalResource);
434444
return res.editStatus(r -> resource);
435445
}
436446
} finally {

0 commit comments

Comments
 (0)