Skip to content

Commit

Permalink
Cleanup CR deletion.
Browse files Browse the repository at this point in the history
  • Loading branch information
mnlipp committed Dec 2, 2024
1 parent 84ac4bb commit db7fbe2
Showing 1 changed file with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ protected void handleChange(K8sClient client,
V1ObjectMeta metadata = response.object.getMetadata();
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
var vmModel = response.object;
if (vmModel.data() == null) {
Expand Down Expand Up @@ -151,17 +146,16 @@ protected void handleChange(K8sClient client,

// Create and fire changed event. Remove channel from channel
// manager on completion.
channel.pipeline()
.fire(Event.onCompletion(
new VmDefChanged(ResponseType.valueOf(response.type),
channel.setGeneration(response.object.getMetadata()
.getGeneration()),
vmDef),
e -> {
if (e.type() == ResponseType.DELETED) {
channelManager.remove(e.vmDefinition().name());
}
}), channel);
VmDefChanged chgEvt
= new VmDefChanged(ResponseType.valueOf(response.type),
channel.setGeneration(response.object.getMetadata()
.getGeneration()),
vmDef);
if (ResponseType.valueOf(response.type) == ResponseType.DELETED) {
chgEvt = Event.onCompletion(chgEvt,
e -> channelManager.remove(e.vmDefinition().name()));
}
channel.pipeline().fire(chgEvt, channel);
}

private VmDefinitionModel getModel(K8sClient client,
Expand Down

0 comments on commit db7fbe2

Please sign in to comment.