Skip to content

Commit

Permalink
moved getHostName for typePod
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed May 4, 2022
1 parent ded3e9b commit 2a0ee75
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/pipeline/transform/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (k *KubeData) GetInfo(ip string) (*Info, error) {
Labels: pod.Labels,
OwnerReferences: pod.OwnerReferences,
HostIP: pod.Status.HostIP,
HostName: k.getHostName(pod.Status.HostIP),
}
case typeNode:
node := objs[0].(*v1.Node)
Expand All @@ -103,7 +104,6 @@ func (k *KubeData) GetInfo(ip string) (*Info, error) {
}

info.Owner = k.getOwner(info)
info.HostName = k.getHostName(info)
return info, nil
}
}
Expand Down Expand Up @@ -142,9 +142,9 @@ func (k *KubeData) getOwner(info *Info) Owner {
}
}

func (k *KubeData) getHostName(info *Info) string {
if k.ipInformers[typeNode] != nil && len(info.HostIP) > 0 {
objs, err := k.ipInformers[typeNode].GetIndexer().ByIndex(IndexIP, info.HostIP)
func (k *KubeData) getHostName(hostIP string) string {
if k.ipInformers[typeNode] != nil && len(hostIP) > 0 {
objs, err := k.ipInformers[typeNode].GetIndexer().ByIndex(IndexIP, hostIP)
if err == nil && len(objs) > 0 {
return objs[0].(*v1.Node).Name
}
Expand Down

0 comments on commit 2a0ee75

Please sign in to comment.