1
1
package io .javaoperatorsdk .operator .processing ;
2
2
3
3
import static io .javaoperatorsdk .operator .EventListUtils .containsCustomResourceDeletedEvent ;
4
+ import static io .javaoperatorsdk .operator .processing .KubernetesResourceUtils .getName ;
4
5
import static io .javaoperatorsdk .operator .processing .KubernetesResourceUtils .getUID ;
5
6
import static io .javaoperatorsdk .operator .processing .KubernetesResourceUtils .getVersion ;
6
7
@@ -62,13 +63,12 @@ public PostExecutionControl handleExecution(ExecutionScope<R> executionScope) {
62
63
63
64
private PostExecutionControl handleDispatch (ExecutionScope <R > executionScope ) {
64
65
R resource = executionScope .getCustomResource ();
65
- log .debug (
66
- "Handling events: {} for resource {}" , executionScope .getEvents (), resource .getMetadata ());
66
+ log .debug ("Handling events: {} for resource {}" , executionScope .getEvents (), getName (resource ));
67
67
68
68
if (containsCustomResourceDeletedEvent (executionScope .getEvents ())) {
69
69
log .debug (
70
70
"Skipping dispatch processing because of a Delete event: {} with version: {}" ,
71
- getUID (resource ),
71
+ getName (resource ),
72
72
getVersion (resource ));
73
73
return PostExecutionControl .defaultDispatch ();
74
74
}
@@ -77,7 +77,7 @@ private PostExecutionControl handleDispatch(ExecutionScope<R> executionScope) {
77
77
if (markedForDeletion && shouldNotDispatchToDelete (resource )) {
78
78
log .debug (
79
79
"Skipping delete of resource {} because finalizer(s) {} don't allow processing yet" ,
80
- resource . getMetadata (). getName (),
80
+ getName (resource ),
81
81
resource .getMetadata ().getFinalizers ());
82
82
return PostExecutionControl .defaultDispatch ();
83
83
}
@@ -119,7 +119,7 @@ private PostExecutionControl handleCreateOrUpdate(
119
119
} else {
120
120
log .debug (
121
121
"Executing createOrUpdate for resource {} with version: {} with execution scope: {}" ,
122
- getUID (resource ),
122
+ getName (resource ),
123
123
getVersion (resource ),
124
124
executionScope );
125
125
UpdateControl <R > updateControl = controller .createOrUpdateResource (resource , context );
@@ -150,7 +150,7 @@ private PostExecutionControl handleCreateOrUpdate(
150
150
private PostExecutionControl handleDelete (R resource , Context <R > context ) {
151
151
log .debug (
152
152
"Executing delete for resource: {} with version: {}" ,
153
- getUID (resource ),
153
+ getName (resource ),
154
154
getVersion (resource ));
155
155
// todo: this is be executed in a try-catch statement, in case this fails
156
156
DeleteControl deleteControl = controller .deleteResource (resource , context );
@@ -197,7 +197,7 @@ private R removeFinalizer(R resource) {
197
197
private R replace (R resource ) {
198
198
log .debug (
199
199
"Trying to replace resource {}, version: {}" ,
200
- resource . getMetadata (). getName (),
200
+ getName (resource ),
201
201
resource .getMetadata ().getResourceVersion ());
202
202
return customResourceFacade .replaceWithLock (resource );
203
203
}
@@ -216,14 +216,14 @@ public R updateStatus(R resource) {
216
216
log .trace ("Updating status for resource: {}" , resource );
217
217
return resourceOperation
218
218
.inNamespace (resource .getMetadata ().getNamespace ())
219
- .withName (resource . getMetadata (). getName ())
219
+ .withName (getName (resource ))
220
220
.updateStatus (resource );
221
221
}
222
222
223
223
public R replaceWithLock (R resource ) {
224
224
return resourceOperation
225
225
.inNamespace (resource .getMetadata ().getNamespace ())
226
- .withName (resource . getMetadata (). getName ())
226
+ .withName (getName (resource ))
227
227
.lockResourceVersion (resource .getMetadata ().getResourceVersion ())
228
228
.replace (resource );
229
229
}
0 commit comments