11package io .javaoperatorsdk .operator .processing ;
22
33import static io .javaoperatorsdk .operator .EventListUtils .containsCustomResourceDeletedEvent ;
4+ import static io .javaoperatorsdk .operator .processing .KubernetesResourceUtils .getName ;
45import static io .javaoperatorsdk .operator .processing .KubernetesResourceUtils .getUID ;
56import static io .javaoperatorsdk .operator .processing .KubernetesResourceUtils .getVersion ;
67
@@ -62,13 +63,12 @@ public PostExecutionControl handleExecution(ExecutionScope<R> executionScope) {
6263
6364 private PostExecutionControl handleDispatch (ExecutionScope <R > executionScope ) {
6465 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 ));
6767
6868 if (containsCustomResourceDeletedEvent (executionScope .getEvents ())) {
6969 log .debug (
7070 "Skipping dispatch processing because of a Delete event: {} with version: {}" ,
71- getUID (resource ),
71+ getName (resource ),
7272 getVersion (resource ));
7373 return PostExecutionControl .defaultDispatch ();
7474 }
@@ -77,7 +77,7 @@ private PostExecutionControl handleDispatch(ExecutionScope<R> executionScope) {
7777 if (markedForDeletion && shouldNotDispatchToDelete (resource )) {
7878 log .debug (
7979 "Skipping delete of resource {} because finalizer(s) {} don't allow processing yet" ,
80- resource . getMetadata (). getName (),
80+ getName (resource ),
8181 resource .getMetadata ().getFinalizers ());
8282 return PostExecutionControl .defaultDispatch ();
8383 }
@@ -119,7 +119,7 @@ private PostExecutionControl handleCreateOrUpdate(
119119 } else {
120120 log .debug (
121121 "Executing createOrUpdate for resource {} with version: {} with execution scope: {}" ,
122- getUID (resource ),
122+ getName (resource ),
123123 getVersion (resource ),
124124 executionScope );
125125 UpdateControl <R > updateControl = controller .createOrUpdateResource (resource , context );
@@ -150,7 +150,7 @@ private PostExecutionControl handleCreateOrUpdate(
150150 private PostExecutionControl handleDelete (R resource , Context <R > context ) {
151151 log .debug (
152152 "Executing delete for resource: {} with version: {}" ,
153- getUID (resource ),
153+ getName (resource ),
154154 getVersion (resource ));
155155 // todo: this is be executed in a try-catch statement, in case this fails
156156 DeleteControl deleteControl = controller .deleteResource (resource , context );
@@ -197,7 +197,7 @@ private R removeFinalizer(R resource) {
197197 private R replace (R resource ) {
198198 log .debug (
199199 "Trying to replace resource {}, version: {}" ,
200- resource . getMetadata (). getName (),
200+ getName (resource ),
201201 resource .getMetadata ().getResourceVersion ());
202202 return customResourceFacade .replaceWithLock (resource );
203203 }
@@ -216,14 +216,14 @@ public R updateStatus(R resource) {
216216 log .trace ("Updating status for resource: {}" , resource );
217217 return resourceOperation
218218 .inNamespace (resource .getMetadata ().getNamespace ())
219- .withName (resource . getMetadata (). getName ())
219+ .withName (getName (resource ))
220220 .updateStatus (resource );
221221 }
222222
223223 public R replaceWithLock (R resource ) {
224224 return resourceOperation
225225 .inNamespace (resource .getMetadata ().getNamespace ())
226- .withName (resource . getMetadata (). getName ())
226+ .withName (getName (resource ))
227227 .lockResourceVersion (resource .getMetadata ().getResourceVersion ())
228228 .replace (resource );
229229 }
0 commit comments