Skip to content

Commit

Permalink
fix: kubernetes node pod relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Oct 17, 2024
1 parent 8be764c commit ac017ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scrapers/kubernetes/hook_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (aws AWS) OnObject(ctx *KubernetesContext, obj *unstructured.Unstructured)
}
}
if obj.GetKind() == "Pod" && obj.GetLabels()["app.kubernetes.io/name"] == "aws-node" {
nodeName := getString(obj, "spec.nodeName")
nodeName := getString(obj, "spec", "nodeName")
spec := obj.Object["spec"].(map[string]interface{})
for _, ownerRef := range obj.GetOwnerReferences() {
if ownerRef.Kind == "DaemonSet" && ownerRef.Name == "aws-node" {
Expand Down
5 changes: 2 additions & 3 deletions scrapers/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ func getConfigTypePrefix(apiVersion string) string {
return ConfigTypePrefix
}

type KubernetesScraper struct {
}
type KubernetesScraper struct{}

func (kubernetes KubernetesScraper) CanScrape(configs v1.ScraperSpec) bool {
return len(configs.Kubernetes) > 0
Expand Down Expand Up @@ -298,7 +297,7 @@ func ExtractResults(ctx *KubernetesContext, objs []*unstructured.Unstructured) v
}

if obj.GetKind() == "Pod" {
nodeName := getString(obj, "spec.nodeName")
nodeName := getString(obj, "spec", "nodeName")

if nodeName != "" {
nodeID := ctx.GetID("", "Node", nodeName)
Expand Down

0 comments on commit ac017ac

Please sign in to comment.