I'm wondering what is the best way to confirm a delete operation is successful via the Java client? Just because we get a successful status after the API call does not mean the resources, in my case a pod, has been finally deleted.
Currently my approach to do a delete api call, then to do a list pods with watch waiting for a delete event. This feels a bit brittle to me.
I have a couple questions:
Below is a rough example of what I've been trying.
clientConfig.deleteCollectionNamespacedPod(entity.getNamespace(), null, null, null,
String.format(NAME_FIELD_SELECTOR, entity.getName()), null, null, null, null, null);
Call call = clientConfig.listNamespacedPodCall(entity.getNamespace(), null, null, null,
String.format(NAME_FIELD_SELECTOR, entity.getName()), null, null, null, null, Boolean.TRUE,
null, null);
Watch<V1Pod> watch = Watch.createWatch(BaseClient.newBaseClient(clientConfig), call, new TypeToken<Watch.Response<V1Pod>>() {
}.getType());
for (Watch.Response<V1Pod> item : watch) {
if (item.type == "DELETED") {
// return that the deletion of the object was successful
}
}