Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(discovery): port kubeApi discovery to v3 #325

Merged
merged 30 commits into from
Apr 24, 2024
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4d11b8a
feat(discovery): port kubeApi discovery to v3
tthvo Jan 26, 2024
f28fe85
chore(discovery): clean up unused codes and address reviews
tthvo Feb 8, 2024
0661f47
build(deps): remove unused mvn deps
tthvo Mar 22, 2024
ca24b07
feat(discovery): implement discovery logic for FOUND events
tthvo Mar 22, 2024
d29a798
feat(discovery): clean up and implement LOST events
tthvo Mar 27, 2024
f262aa8
chore(typo): fix typo
tthvo Mar 27, 2024
b7a68a7
chore(license): add missing license headers
tthvo Mar 27, 2024
aba6f8a
fix(orm): fix unwrap exception when using enum
tthvo Mar 27, 2024
0f63fa3
chore(logs): fix broken logs format
tthvo Mar 27, 2024
e678a3c
fix(discovery): ignore when target does not exist in db
tthvo Mar 27, 2024
06ee05b
fix(discovery): fix DELETE event handler
tthvo Apr 2, 2024
0adbc41
chore(spotless): add missing spotless fix
tthvo Apr 2, 2024
010909e
chore(k8s): correct labels
tthvo Apr 4, 2024
8ff1804
fixup(k8s): add missing changes for watch namespaces from Andrew
tthvo Apr 9, 2024
2fc59af
fix(k8s): fix string comparison
tthvo Apr 9, 2024
e3fc083
fix(k8s): fix duplicate namespace nodes
tthvo Apr 9, 2024
8746ff5
fix(k8s): fix realm node not found and deletion constraint violation
tthvo Apr 9, 2024
24bf1b5
fix(k8s): rebuild tree on endpoint events
tthvo Apr 22, 2024
4bddb2a
feat(discovery): define parent reference for discovery node
tthvo Apr 22, 2024
a1ea98a
feat(discovery): cache discovery queries
tthvo Apr 22, 2024
3029fe3
fix(discovery): fix bugs causing infinite loop in worker thread
tthvo Apr 22, 2024
4252166
fix(discovery): ensure cascade remove when removing nodes
tthvo Apr 22, 2024
2d4a4cf
fix(discovery): ensure all nodes have parent ref
tthvo Apr 22, 2024
543e103
fix(discovery): properly delete nodes when targets disappear
tthvo Apr 22, 2024
4221626
fix(discovery): only fetch target in namespace of interest
tthvo Apr 22, 2024
559a53d
chore(discovery): clean up and address reviews
tthvo Apr 24, 2024
fea4391
fixup(discovery): use optional for injected list
tthvo Apr 24, 2024
5f1d89e
fixup(transaction): run handler in correct transaction context
tthvo Apr 24, 2024
eddd41e
test(integration): fix broken integration tests
tthvo Apr 24, 2024
978cc5a
fix(spotbugs): remove unused equals override
tthvo Apr 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup(k8s): add missing changes for watch namespaces from Andrew
  • Loading branch information
tthvo committed Apr 24, 2024
commit 8ff1804ceafdbb62b48f2b253cf964813c2432e7
25 changes: 19 additions & 6 deletions src/main/java/io/cryostat/discovery/KubeApiDiscovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import io.fabric8.kubernetes.api.model.EndpointSubset;
import io.fabric8.kubernetes.api.model.Endpoints;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.api.model.ObjectReference;
import io.fabric8.kubernetes.api.model.OwnerReference;
import io.fabric8.kubernetes.client.KubernetesClient;
Expand Down Expand Up @@ -378,6 +379,8 @@ static final class KubeConfig {
public static final String KUBERNETES_NAMESPACE_PATH =
"/var/run/secrets/kubernetes.io/serviceaccount/namespace";
tthvo marked this conversation as resolved.
Show resolved Hide resolved

private static final String OWN_NAMESPACE = ".";

@Inject Logger logger;
@Inject FileSystem fs;

Expand All @@ -389,8 +392,17 @@ static final class KubeConfig {

private KubernetesClient kubeClient;

List<String> getWatchNamespaces() {
return watchNamespaces.orElse(List.of());
Collection<String> getWatchNamespaces() {
return watchNamespaces.orElse(List.of()).stream()
.map(
n -> {
if (OWN_NAMESPACE.equals(n)) {
return getOwnNamespace();
}
return n;
})
.filter(Objects::nonNull)
.collect(Collectors.toSet());
}

String getOwnNamespace() {
Expand Down Expand Up @@ -485,10 +497,11 @@ public Target toTarget() {
queryForNode(objRef.getNamespace(), objRef.getName(), objRef.getKind());
HasMetadata obj = pair.getLeft();
try {
String targetName = objRef.getName();
ObjectMeta metadata = obj.getMetadata();
String targetName = metadata.getName();

String ip = addr.getIp().replaceAll("\\.", "-");
String namespace = obj.getMetadata().getNamespace();
String namespace = metadata.getNamespace();

boolean isPod = obj.getKind().equals(KubeDiscoveryNodeType.POD.getKind());

Expand All @@ -508,9 +521,9 @@ public Target toTarget() {
target.activeRecordings = new ArrayList<>();
target.connectUrl = URI.create(jmxUrl.toString());
target.alias = targetName;
target.labels = obj.getMetadata().getLabels();
target.labels = metadata.getLabels();
target.annotations = new Annotations();
target.annotations.platform().putAll(obj.getMetadata().getAnnotations());
target.annotations.platform().putAll(metadata.getAnnotations());
target.annotations
.cryostat()
.putAll(
Expand Down