Skip to content

Commit

Permalink
fix(discovery): mark plugin refresh job as Transactional (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored May 17, 2024
1 parent 4531296 commit 99735e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/cryostat/discovery/Discovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jwt.proc.BadJWTException;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.quarkus.narayana.jta.QuarkusTransaction;
import io.quarkus.runtime.ShutdownEvent;
import io.quarkus.runtime.StartupEvent;
import io.vertx.core.json.JsonObject;
Expand Down Expand Up @@ -402,6 +401,7 @@ static class RefreshPluginJob implements Job {
@Inject Logger logger;

@Override
@Transactional
public void execute(JobExecutionContext context) throws JobExecutionException {
DiscoveryPlugin plugin = null;
try {
Expand All @@ -424,7 +424,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException {
if (plugin != null) {
logger.debugv(
e, "Pruned discovery plugin: {0} @ {1}", plugin.realm, plugin.callback);
QuarkusTransaction.requiringNew().run(plugin::delete);
plugin.delete();
} else {
var ex = new JobExecutionException(e);
ex.setUnscheduleFiringTrigger(true);
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/io/cryostat/discovery/KubeApiDiscovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -295,8 +296,10 @@ private void handleObservedEndpoints(String namespace) {

Map<URI, ObjectReference> targetRefMap = new HashMap<>();

Set<Target> persistedTargets =
targetNodes.stream().map(node -> node.target).collect(Collectors.toSet());
Set<Target> persistedTargets = new HashSet<>();
for (DiscoveryNode node : targetNodes) {
persistedTargets.add(node.target);
}

Set<Target> observedTargets =
safeGetInformers().get(namespace).getStore().list().stream()
Expand Down

0 comments on commit 99735e3

Please sign in to comment.