Skip to content

Commit

Permalink
fix(discovery): properly delete nodes when targets disappear
Browse files Browse the repository at this point in the history
  • Loading branch information
tthvo committed Apr 22, 2024
1 parent a05895c commit 4d97568
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ public void handleContainerEvent(ContainerSpec desc, EventKind evtKind) {
} else {
realm.children.remove(t.discoveryNode);
}
t.discoveryNode.parent = null;
realm.persist();
t.delete();
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/cryostat/discovery/CustomDiscovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public Response delete(@RestPath long id) throws URISyntaxException {
Target target = Target.find("id", id).singleResult();
DiscoveryNode realm = DiscoveryNode.getRealm(REALM).orElseThrow();
realm.children.remove(target.discoveryNode);
target.discoveryNode = null;
realm.persist();
target.delete();
return Response.noContent().build();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/cryostat/discovery/JDPDiscovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public synchronized void handleJdpEvent(JvmDiscoveryEvent evt) {
case LOST:
Target t = Target.getTargetByConnectUrl(connectUrl);
realm.children.remove(t.discoveryNode);
t.discoveryNode.parent = null;
realm.persist();
t.delete();
break;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/cryostat/discovery/KubeApiDiscovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ public void handleEndpointEvent(String namespace) {

if (!nsNode.hasChildren()) {
realm.children.remove(nsNode);
nsNode.parent = null;
} else if (!realm.children.contains(nsNode)) {
realm.children.add(nsNode);
nsNode.parent = realm;
Expand Down Expand Up @@ -275,6 +276,7 @@ private void pruneOwnerChain(DiscoveryNode nsNode, Target target) {
}

parent.children.remove(child);
child.parent = null;
parent.persist();

if (parent.hasChildren()
Expand Down

0 comments on commit 4d97568

Please sign in to comment.