Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
omris94 committed Dec 10, 2024
1 parent b011696 commit 53f247b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/mapper/pkg/resolvers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (r *Resolver) discoverInternalSrcIdentity(ctx context.Context, src *model.R
if err != nil {
return model.OtterizeServiceIdentity{}, errors.Wrap(err)
}
svcIdentity.ResolutionData.ProcfsHostname = lo.ToPtr(src.SrcHostname)
svcIdentity.ResolutionData.ProcfsHostname = lo.Ternary(src.SrcHostname != "", lo.ToPtr(src.SrcHostname), nil)
return svcIdentity, nil
}

Expand Down
12 changes: 11 additions & 1 deletion src/mapper/pkg/resolvers/schema.helpers.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ func (r *Resolver) handleDNSCaptureResultsAsKubernetesPods(ctx context.Context,

func (r *Resolver) resolveOtterizeIdentityForDestinationAddress(ctx context.Context, dest model.Destination) (*model.OtterizeServiceIdentity, bool, error) {
destAddress := dest.Destination
resolutionData := model.IdentityResolutionData{
Host: lo.ToPtr(destAddress),
LastSeen: lo.ToPtr(dest.LastSeen.String()),
IsService: lo.ToPtr(true),
ExtraInfo: lo.ToPtr("resolveOtterizeIdentityForDestinationAddress"),
}
pods, serviceName, err := r.kubeFinder.ResolveServiceAddressToPods(ctx, destAddress)
if err != nil {
logrus.WithError(err).Warningf("Could not resolve service address %s", destAddress)
Expand All @@ -331,6 +337,7 @@ func (r *Resolver) resolveOtterizeIdentityForDestinationAddress(ctx context.Cont
Name: serviceName.Name,
Namespace: serviceName.Namespace,
KubernetesService: &serviceName.Name,
ResolutionData: &resolutionData,
}, true, nil
}

Expand All @@ -354,13 +361,16 @@ func (r *Resolver) resolveOtterizeIdentityForDestinationAddress(ctx context.Cont

destPod := &filteredPods[0]

resolutionData.PodHostname = lo.ToPtr(destPod.Name)
resolutionData.Uptime = lo.ToPtr(time.Since(destPod.CreationTimestamp.Time).String())

dstService, err := r.serviceIdResolver.ResolvePodToServiceIdentity(ctx, destPod)
if err != nil {
logrus.WithError(err).Debugf("Could not resolve pod %s to identity", destPod.Name)
return nil, false, nil
}

dstSvcIdentity := &model.OtterizeServiceIdentity{Name: dstService.Name, Namespace: destPod.Namespace, Labels: kubefinder.PodLabelsToOtterizeLabels(destPod)}
dstSvcIdentity := &model.OtterizeServiceIdentity{Name: dstService.Name, Namespace: destPod.Namespace, Labels: kubefinder.PodLabelsToOtterizeLabels(destPod), ResolutionData: &resolutionData}
if dstService.OwnerObject != nil {
dstSvcIdentity.PodOwnerKind = model.GroupVersionKindFromKubeGVK(dstService.OwnerObject.GetObjectKind().GroupVersionKind())
}
Expand Down

0 comments on commit 53f247b

Please sign in to comment.