@@ -91,17 +91,23 @@ private PostExecutionControl handleCreateOrUpdate(ExecutionScope executionScope,
91
91
log .debug ("Executing createOrUpdate for resource {} with version: {} with execution scope: {}" ,
92
92
getUID (resource ), getVersion (resource ), executionScope );
93
93
UpdateControl <? extends CustomResource > updateControl = controller .createOrUpdateResource (resource , context );
94
+ CustomResource updatedCustomResource = null ;
94
95
if (updateControl .isUpdateStatusSubResource ()) {
95
- customResourceFacade .updateStatus (updateControl .getCustomResource ());
96
+ updatedCustomResource = customResourceFacade .updateStatus (updateControl .getCustomResource ());
96
97
} else if (updateControl .isUpdateCustomResource ()) {
97
- updateCustomResource (updateControl .getCustomResource ());
98
+ updatedCustomResource = updateCustomResource (updateControl .getCustomResource ());
98
99
}
99
100
markLastGenerationProcessed (resource );
101
+ if (updatedCustomResource != null ) {
102
+ return PostExecutionControl .customResourceUpdated (updatedCustomResource );
103
+ } else {
104
+ return PostExecutionControl .defaultDispatch ();
105
+ }
100
106
} else {
101
107
log .debug ("Skipping event processing because generations: {} with version: {}" ,
102
108
getUID (resource ), getVersion (resource ));
109
+ return PostExecutionControl .defaultDispatch ();
103
110
}
104
- return PostExecutionControl .defaultDispatch ();
105
111
}
106
112
}
107
113
@@ -128,13 +134,14 @@ private PostExecutionControl handleDelete(CustomResource resource, Context conte
128
134
DeleteControl deleteControl = controller .deleteResource (resource , context );
129
135
boolean hasFinalizer = ControllerUtils .hasGivenFinalizer (resource , resourceFinalizer );
130
136
if (deleteControl == DeleteControl .DEFAULT_DELETE && hasFinalizer ) {
131
- removeFinalizer (resource );
137
+ CustomResource customResource = removeFinalizer (resource );
132
138
cleanup (resource );
139
+ return PostExecutionControl .customResourceUpdated (customResource );
133
140
} else {
134
141
log .debug ("Skipping finalizer remove for resource: {} with version: {}. delete control: {}, hasFinalizer: {} " ,
135
142
getUID (resource ), getVersion (resource ), deleteControl , hasFinalizer );
143
+ return PostExecutionControl .defaultDispatch ();
136
144
}
137
- return PostExecutionControl .defaultDispatch ();
138
145
}
139
146
140
147
public boolean largerGenerationThenProcessedBefore (CustomResource resource ) {
@@ -165,23 +172,23 @@ private void updateCustomResourceWithFinalizer(CustomResource resource) {
165
172
replace (resource );
166
173
}
167
174
168
- private void updateCustomResource (CustomResource resource ) {
175
+ private CustomResource updateCustomResource (CustomResource resource ) {
169
176
log .debug ("Updating resource: {} with version: {}" , getUID (resource ),
170
177
getVersion (resource ));
171
178
log .trace ("Resource before update: {}" , resource );
172
- replace (resource );
179
+ return replace (resource );
173
180
}
174
181
175
182
176
- private void removeFinalizer (CustomResource resource ) {
183
+ private CustomResource removeFinalizer (CustomResource resource ) {
177
184
log .debug ("Removing finalizer on resource: {} with version: {}" , getUID (resource ), getVersion (resource ));
178
185
resource .getMetadata ().getFinalizers ().remove (resourceFinalizer );
179
- customResourceFacade .replaceWithLock (resource );
186
+ return customResourceFacade .replaceWithLock (resource );
180
187
}
181
188
182
- private void replace (CustomResource resource ) {
189
+ private CustomResource replace (CustomResource resource ) {
183
190
log .debug ("Trying to replace resource {}, version: {}" , resource .getMetadata ().getName (), resource .getMetadata ().getResourceVersion ());
184
- customResourceFacade .replaceWithLock (resource );
191
+ return customResourceFacade .replaceWithLock (resource );
185
192
}
186
193
187
194
private void addFinalizerIfNotPresent (CustomResource resource ) {
@@ -207,9 +214,9 @@ public CustomResourceFacade(MixedOperation<?, ?, ?, Resource<CustomResource, ?>>
207
214
this .resourceOperation = resourceOperation ;
208
215
}
209
216
210
- public void updateStatus (CustomResource resource ) {
217
+ public CustomResource updateStatus (CustomResource resource ) {
211
218
log .trace ("Updating status for resource: {}" , resource );
212
- resourceOperation .inNamespace (resource .getMetadata ().getNamespace ())
219
+ return resourceOperation .inNamespace (resource .getMetadata ().getNamespace ())
213
220
.withName (resource .getMetadata ().getName ())
214
221
.updateStatus (resource );
215
222
}
0 commit comments