From 53f247b2d8a86e081c1c42cad4f6cd0098fa2777 Mon Sep 17 00:00:00 2001 From: "omri.s" Date: Tue, 10 Dec 2024 19:00:50 +0200 Subject: [PATCH] fixup --- src/mapper/pkg/resolvers/helpers.go | 2 +- src/mapper/pkg/resolvers/schema.helpers.resolvers.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mapper/pkg/resolvers/helpers.go b/src/mapper/pkg/resolvers/helpers.go index b5db375c..0934ceb1 100644 --- a/src/mapper/pkg/resolvers/helpers.go +++ b/src/mapper/pkg/resolvers/helpers.go @@ -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 } diff --git a/src/mapper/pkg/resolvers/schema.helpers.resolvers.go b/src/mapper/pkg/resolvers/schema.helpers.resolvers.go index a0c38e99..4f6c1beb 100644 --- a/src/mapper/pkg/resolvers/schema.helpers.resolvers.go +++ b/src/mapper/pkg/resolvers/schema.helpers.resolvers.go @@ -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) @@ -331,6 +337,7 @@ func (r *Resolver) resolveOtterizeIdentityForDestinationAddress(ctx context.Cont Name: serviceName.Name, Namespace: serviceName.Namespace, KubernetesService: &serviceName.Name, + ResolutionData: &resolutionData, }, true, nil } @@ -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()) }