diff --git a/probe/kubernetes/pod.go b/probe/kubernetes/pod.go index 0031fd9275..a703f5f6e0 100644 --- a/probe/kubernetes/pod.go +++ b/probe/kubernetes/pod.go @@ -2,6 +2,7 @@ package kubernetes import ( "strconv" + "strings" "github.com/weaveworks/scope/report" @@ -29,6 +30,7 @@ type Pod interface { GetNode(probeID string) report.Node RestartCount() uint ContainerNames() []string + VolumeClaimNames() []string } type pod struct { @@ -75,15 +77,14 @@ func (p *pod) RestartCount() uint { return count } -func (p *pod) VolumeClaimName() string { - var claimName string +func (p *pod) VolumeClaimNames() []string { + var claimNames []string for _, volume := range p.Spec.Volumes { if volume.VolumeSource.PersistentVolumeClaim != nil { - claimName = volume.VolumeSource.PersistentVolumeClaim.ClaimName - break + claimNames = append(claimNames, volume.VolumeSource.PersistentVolumeClaim.ClaimName) } } - return claimName + return claimNames } func (p *pod) GetNode(probeID string) report.Node { @@ -94,8 +95,10 @@ func (p *pod) GetNode(probeID string) report.Node { RestartCount: strconv.FormatUint(uint64(p.RestartCount()), 10), } - if p.VolumeClaimName() != "" { - latests[VolumeClaim] = p.VolumeClaimName() + if len(p.VolumeClaimNames()) > 0 { + // PVC name consist of lower case alphanumeric characters, "-" or "." + // and must start and end with an alphanumeric character. + latests[VolumeClaim] = strings.Join(p.VolumeClaimNames(), report.ScopeDelim) } if p.Pod.Spec.HostNetwork { diff --git a/render/persistentvolume.go b/render/persistentvolume.go index 58b90ff202..1785fdf788 100644 --- a/render/persistentvolume.go +++ b/render/persistentvolume.go @@ -2,6 +2,7 @@ package render import ( "context" + "strings" "github.com/weaveworks/scope/probe/kubernetes" "github.com/weaveworks/scope/report" @@ -53,17 +54,21 @@ type podToVolumesRenderer struct{} func (v podToVolumesRenderer) Render(ctx context.Context, rpt report.Report) Nodes { nodes := make(report.Nodes) for podID, podNode := range rpt.Pod.Nodes { - ClaimName, found := podNode.Latest.Lookup(kubernetes.VolumeClaim) + claimNames, found := podNode.Latest.Lookup(kubernetes.VolumeClaim) if !found { continue } podNamespace, _ := podNode.Latest.Lookup(kubernetes.Namespace) - for _, pvcNode := range rpt.PersistentVolumeClaim.Nodes { - pvcName, _ := pvcNode.Latest.Lookup(kubernetes.Name) - pvcNamespace, _ := pvcNode.Latest.Lookup(kubernetes.Namespace) - if (pvcName == ClaimName) && (podNamespace == pvcNamespace) { - podNode.Adjacency = podNode.Adjacency.Add(pvcNode.ID) - podNode.Children = podNode.Children.Add(pvcNode) + claimNameList := strings.Split(claimNames, report.ScopeDelim) + for _, ClaimName := range claimNameList { + for _, pvcNode := range rpt.PersistentVolumeClaim.Nodes { + pvcName, _ := pvcNode.Latest.Lookup(kubernetes.Name) + pvcNamespace, _ := pvcNode.Latest.Lookup(kubernetes.Namespace) + if (pvcName == ClaimName) && (podNamespace == pvcNamespace) { + podNode.Adjacency = podNode.Adjacency.Add(pvcNode.ID) + podNode.Children = podNode.Children.Add(pvcNode) + break + } } } nodes[podID] = podNode