Skip to content

Commit

Permalink
Merge branch 'adapt-banyandb-client' of github.com:wankai123/skywalki…
Browse files Browse the repository at this point in the history
…ng into adapt-banyandb-client
  • Loading branch information
wankai123 committed Sep 14, 2024
2 parents e953318 + c4b9d4f commit 723d2bc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apm-protocol/apm-network/src/main/proto
Submodule proto updated 2 files
+4 −1 common/BUILD
+21 −0 ebpf/accesslog.proto
3 changes: 2 additions & 1 deletion docs/en/changes/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
* Fix query `getGlobalTopology` throw exception when didn't find any services by the given Layer.
* Fix the previous analysis result missing in the ALS `k8s-mesh` analyzer.
* Fix `findEndpoint` query require `keyword` when using BanyanDB.
* Adapt BanyanDB Java Client 0.7.0.
* Support to analysis the ztunnel mapped IP address in eBPF Access Log Receiver.
* Adapt BanyanDB Java Client 0.7.0-rc3.

#### UI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.skywalking.apm.network.ebpf.accesslog.v3.EBPFTimestamp;
import org.apache.skywalking.apm.network.ebpf.accesslog.v3.IPAddress;
import org.apache.skywalking.apm.network.ebpf.accesslog.v3.KubernetesProcessAddress;
import org.apache.skywalking.apm.network.ebpf.accesslog.v3.ZTunnelAttachmentEnvironment;
import org.apache.skywalking.library.kubernetes.ObjectID;
import org.apache.skywalking.oap.meter.analyzer.k8s.K8sInfoRegistry;
import org.apache.skywalking.oap.server.core.Const;
Expand Down Expand Up @@ -485,15 +486,23 @@ protected void printDropReasons() {
});
}

protected KubernetesProcessAddress buildKubernetesAddressByIP(NodeInfo nodeInfo, IPAddress ipAddress) {
final ObjectID service = K8sInfoRegistry.getInstance().findServiceByIP(ipAddress.getHost());
protected KubernetesProcessAddress buildKubernetesAddressByIP(NodeInfo nodeInfo, AccessLogConnection connection, boolean isLocal, IPAddress ipAddress) {
String host = ipAddress.getHost();
// if the resolving address is not local, and have attached ztunnel info, then using the ztunnel mapped host
if (!isLocal && connection.hasAttachment() && connection.getAttachment().hasZTunnel()) {
final ZTunnelAttachmentEnvironment ztunnel = connection.getAttachment().getZTunnel();
host = ztunnel.getRealDestinationIp();
log.debug("detected the ztunnel connection, so update the remote IP address as: {}, detect by: {}", host,
ztunnel.getBy());
}
final ObjectID service = K8sInfoRegistry.getInstance().findServiceByIP(host);
if (service != ObjectID.EMPTY) {
return buildRemoteAddress(nodeInfo, service, null);
}
final ObjectID pod = K8sInfoRegistry.getInstance().findPodByIP(ipAddress.getHost());
final ObjectID pod = K8sInfoRegistry.getInstance().findPodByIP(host);
if (pod == ObjectID.EMPTY) {
// if cannot found the address, then return the unknown address
log.debug("building unknown address by ip: {}:{}", ipAddress.getHost(), ipAddress.getPort());
log.debug("building unknown address by ip: {}:{}", host, ipAddress.getPort());
return buildUnknownAddress();
}
final ObjectID serviceName = K8sInfoRegistry.getInstance().findService(pod.namespace(), pod.name());
Expand Down Expand Up @@ -536,8 +545,8 @@ public class ConnectionInfo {
public ConnectionInfo(NamingControl namingControl, NodeInfo nodeInfo, AccessLogConnection connection) {
this.originalConnection = connection;
this.namingControl = namingControl;
this.local = buildAddress(nodeInfo, connection.getLocal());
this.remote = buildAddress(nodeInfo, connection.getRemote());
this.local = buildAddress(nodeInfo, connection, true, connection.getLocal());
this.remote = buildAddress(nodeInfo, connection, false, connection.getRemote());
this.role = connection.getRole();
this.tlsMode = connection.getTlsMode();
this.nodeInfo = nodeInfo;
Expand All @@ -549,12 +558,12 @@ public ConnectionInfo(NamingControl namingControl, NodeInfo nodeInfo, AccessLogC
}
}

private KubernetesProcessAddress buildAddress(NodeInfo nodeInfo, ConnectionAddress address) {
private KubernetesProcessAddress buildAddress(NodeInfo nodeInfo, AccessLogConnection connection, boolean local, ConnectionAddress address) {
switch (address.getAddressCase()) {
case KUBERNETES:
return address.getKubernetes();
case IP:
return buildKubernetesAddressByIP(nodeInfo, address.getIp());
return buildKubernetesAddressByIP(nodeInfo, connection, local, address.getIp());
}
return null;
}
Expand Down

0 comments on commit 723d2bc

Please sign in to comment.