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

Collect traffic levels #271

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Collect traffic levels #271

wants to merge 8 commits into from

Conversation

orishavit
Copy link
Contributor

@orishavit orishavit commented Feb 10, 2025

Description

Aggregate data collected by the Otterize node-agent, using the traffic levels eBPF programs. This data includes the number of bytes, and number of connections between the services. The mapper then calculates a moving average, and reports it to the cloud.

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR and in github.com/otterize/docs

@orishavit orishavit marked this pull request as draft February 10, 2025 15:29
@orishavit orishavit force-pushed the shavit/traffic-levels branch from 95d00a6 to 8b467c7 Compare February 10, 2025 15:45
@orishavit orishavit requested a review from otterobert February 12, 2025 13:53
@orishavit orishavit marked this pull request as ready for review February 12, 2025 21:50
sourceIdentity, err := r.resolveIPToIdentity(ctx, report.SrcIP)

if err != nil {
logrus.WithError(err).Errorf("Could not resolve source IP %s to identity", report.SrcIP)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use logrus.WithField for templated fields:

Suggested change
logrus.WithError(err).Errorf("Could not resolve source IP %s to identity", report.SrcIP)
logrus.WithError(err).WithFields("srcIP", report.SrcIP).Error("Could not resolve source IP to identity")

destinationIdentity, err := r.resolveIPToIdentity(ctx, report.DstIP)

if err != nil {
logrus.WithError(err).Errorf("Could not resolve destination IP %s to identity", report.DstIP)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -314,6 +315,33 @@ func (r *Resolver) handleAzureOperationReport(ctx context.Context, operation mod
return nil
}

func (r *Resolver) handleTrafficLevelReport(ctx context.Context, results model.TrafficLevelResults) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, resolving source and dest pods just by trying to search for the IP in kubefinder is not that reliable, due to annoying things like IP reuse or host-network pods. Please follow the flow performed by handleTCPCaptureResult to correctly resolve the local and remote identities, taking all edge cases into consideration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code in handleTCPCaptureResult also doesn't work well with traffic info, since it makes assumptions on the direction of traffic. Specifically, that traffic is always from a pod to a service, which is not true in our case. I'm not sure what's the best way to handle this generally, but I hesitate to modify the code used by handleTCPCaptureResult so to not break existing features.

@amitlicht amitlicht removed the request for review from otterobert February 18, 2025 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants