Cleanup CR deletion.

This commit is contained in:
Michael Lipp 2024-12-02 12:18:41 +01:00
parent 84ac4bb28c
commit db7fbe2b7c

View file

@ -119,11 +119,6 @@ public class VmMonitor extends
V1ObjectMeta metadata = response.object.getMetadata(); V1ObjectMeta metadata = response.object.getMetadata();
VmChannel channel = channelManager.channelGet(metadata.getName()); VmChannel channel = channelManager.channelGet(metadata.getName());
// Remove from channel manager if deleted
if (ResponseType.valueOf(response.type) == ResponseType.DELETED) {
channelManager.remove(metadata.getName());
}
// Get full definition and associate with channel as backup // Get full definition and associate with channel as backup
var vmModel = response.object; var vmModel = response.object;
if (vmModel.data() == null) { if (vmModel.data() == null) {
@ -151,17 +146,16 @@ public class VmMonitor extends
// Create and fire changed event. Remove channel from channel // Create and fire changed event. Remove channel from channel
// manager on completion. // manager on completion.
channel.pipeline() VmDefChanged chgEvt
.fire(Event.onCompletion( = new VmDefChanged(ResponseType.valueOf(response.type),
new VmDefChanged(ResponseType.valueOf(response.type),
channel.setGeneration(response.object.getMetadata() channel.setGeneration(response.object.getMetadata()
.getGeneration()), .getGeneration()),
vmDef), vmDef);
e -> { if (ResponseType.valueOf(response.type) == ResponseType.DELETED) {
if (e.type() == ResponseType.DELETED) { chgEvt = Event.onCompletion(chgEvt,
channelManager.remove(e.vmDefinition().name()); e -> channelManager.remove(e.vmDefinition().name()));
} }
}), channel); channel.pipeline().fire(chgEvt, channel);
} }
private VmDefinitionModel getModel(K8sClient client, private VmDefinitionModel getModel(K8sClient client,