diff --git a/db/update.go b/db/update.go index 6ce411a3..2b25d278 100644 --- a/db/update.go +++ b/db/update.go @@ -351,21 +351,21 @@ func relationshipResultHandler(relationships v1.RelationshipResults) error { for _, relationship := range relationships { configID, err := FindConfigItemID(relationship.ConfigExternalID) if err != nil { - logger.Errorf("Error fetching config item id: %v", err) + logger.Errorf("error fetching config item(id=%s): %v", relationship.ConfigExternalID, err) continue } if configID == nil { - logger.Warnf("Failed to find config %s", relationship.ConfigExternalID) + logger.Warnf("failed to find config %s", relationship.ConfigExternalID) continue } relatedID, err := FindConfigItemID(relationship.RelatedExternalID) if err != nil { - logger.Errorf("Error fetching config item id: %v", err) + logger.Errorf("error fetching external config item(id=%s): %v", relationship.RelatedExternalID, err) continue } if relatedID == nil { - logger.Warnf("Relationship not found %s", relationship.RelatedExternalID) + logger.Warnf("related external config item(id=%s) not found.", relationship.RelatedExternalID) continue } diff --git a/scrapers/kubernetes/kubernetes.go b/scrapers/kubernetes/kubernetes.go index 0b492142..569a367f 100644 --- a/scrapers/kubernetes/kubernetes.go +++ b/scrapers/kubernetes/kubernetes.go @@ -102,6 +102,21 @@ func (kubernetes KubernetesScraper) Scrape(ctx api.ScrapeContext) v1.ScrapeResul } } + for _, ownerRef := range obj.GetOwnerReferences() { + rel := v1.RelationshipResult{ + ConfigExternalID: v1.ExternalID{ + ExternalID: []string{string(obj.GetUID())}, + ConfigType: ConfigTypePrefix + obj.GetKind(), + }, + RelatedExternalID: v1.ExternalID{ + ExternalID: []string{string(ownerRef.UID)}, + ConfigType: ConfigTypePrefix + ownerRef.Kind, + }, + Relationship: ownerRef.Kind + obj.GetKind(), + } + relationships = append(relationships, rel) + } + obj.SetManagedFields(nil) annotations := obj.GetAnnotations() if annotations != nil {