@@ -91,17 +91,23 @@ private PostExecutionControl handleCreateOrUpdate(ExecutionScope executionScope,
9191 log .debug ("Executing createOrUpdate for resource {} with version: {} with execution scope: {}" ,
9292 getUID (resource ), getVersion (resource ), executionScope );
9393 UpdateControl <? extends CustomResource > updateControl = controller .createOrUpdateResource (resource , context );
94+ CustomResource updatedCustomResource = null ;
9495 if (updateControl .isUpdateStatusSubResource ()) {
95- customResourceFacade .updateStatus (updateControl .getCustomResource ());
96+ updatedCustomResource = customResourceFacade .updateStatus (updateControl .getCustomResource ());
9697 } else if (updateControl .isUpdateCustomResource ()) {
97- updateCustomResource (updateControl .getCustomResource ());
98+ updatedCustomResource = updateCustomResource (updateControl .getCustomResource ());
9899 }
99100 markLastGenerationProcessed (resource );
101+ if (updatedCustomResource != null ) {
102+ return PostExecutionControl .customResourceUpdated (updatedCustomResource );
103+ } else {
104+ return PostExecutionControl .defaultDispatch ();
105+ }
100106 } else {
101107 log .debug ("Skipping event processing because generations: {} with version: {}" ,
102108 getUID (resource ), getVersion (resource ));
109+ return PostExecutionControl .defaultDispatch ();
103110 }
104- return PostExecutionControl .defaultDispatch ();
105111 }
106112 }
107113
@@ -128,13 +134,14 @@ private PostExecutionControl handleDelete(CustomResource resource, Context conte
128134 DeleteControl deleteControl = controller .deleteResource (resource , context );
129135 boolean hasFinalizer = ControllerUtils .hasGivenFinalizer (resource , resourceFinalizer );
130136 if (deleteControl == DeleteControl .DEFAULT_DELETE && hasFinalizer ) {
131- removeFinalizer (resource );
137+ CustomResource customResource = removeFinalizer (resource );
132138 cleanup (resource );
139+ return PostExecutionControl .customResourceUpdated (customResource );
133140 } else {
134141 log .debug ("Skipping finalizer remove for resource: {} with version: {}. delete control: {}, hasFinalizer: {} " ,
135142 getUID (resource ), getVersion (resource ), deleteControl , hasFinalizer );
143+ return PostExecutionControl .defaultDispatch ();
136144 }
137- return PostExecutionControl .defaultDispatch ();
138145 }
139146
140147 public boolean largerGenerationThenProcessedBefore (CustomResource resource ) {
@@ -165,23 +172,23 @@ private void updateCustomResourceWithFinalizer(CustomResource resource) {
165172 replace (resource );
166173 }
167174
168- private void updateCustomResource (CustomResource resource ) {
175+ private CustomResource updateCustomResource (CustomResource resource ) {
169176 log .debug ("Updating resource: {} with version: {}" , getUID (resource ),
170177 getVersion (resource ));
171178 log .trace ("Resource before update: {}" , resource );
172- replace (resource );
179+ return replace (resource );
173180 }
174181
175182
176- private void removeFinalizer (CustomResource resource ) {
183+ private CustomResource removeFinalizer (CustomResource resource ) {
177184 log .debug ("Removing finalizer on resource: {} with version: {}" , getUID (resource ), getVersion (resource ));
178185 resource .getMetadata ().getFinalizers ().remove (resourceFinalizer );
179- customResourceFacade .replaceWithLock (resource );
186+ return customResourceFacade .replaceWithLock (resource );
180187 }
181188
182- private void replace (CustomResource resource ) {
189+ private CustomResource replace (CustomResource resource ) {
183190 log .debug ("Trying to replace resource {}, version: {}" , resource .getMetadata ().getName (), resource .getMetadata ().getResourceVersion ());
184- customResourceFacade .replaceWithLock (resource );
191+ return customResourceFacade .replaceWithLock (resource );
185192 }
186193
187194 private void addFinalizerIfNotPresent (CustomResource resource ) {
@@ -207,9 +214,9 @@ public CustomResourceFacade(MixedOperation<?, ?, ?, Resource<CustomResource, ?>>
207214 this .resourceOperation = resourceOperation ;
208215 }
209216
210- public void updateStatus (CustomResource resource ) {
217+ public CustomResource updateStatus (CustomResource resource ) {
211218 log .trace ("Updating status for resource: {}" , resource );
212- resourceOperation .inNamespace (resource .getMetadata ().getNamespace ())
219+ return resourceOperation .inNamespace (resource .getMetadata ().getNamespace ())
213220 .withName (resource .getMetadata ().getName ())
214221 .updateStatus (resource );
215222 }
0 commit comments