mirror of
https://github.com/weaveworks/scope.git
synced 2026-09-06 10:17:19 +00:00
backend changes for new option rendering
This commit is contained in:
committed by
David Kaltschmidt
parent
619c63a0a5
commit
430130c03a
@@ -1,6 +1,10 @@
|
||||
package render
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/weaveworks/scope/probe/docker"
|
||||
"github.com/weaveworks/scope/probe/kubernetes"
|
||||
"github.com/weaveworks/scope/report"
|
||||
)
|
||||
|
||||
@@ -153,6 +157,38 @@ func (rn RenderableNode) Copy() RenderableNode {
|
||||
}
|
||||
}
|
||||
|
||||
// IsStopped checks if the RenderableNode is a stopped docker container.
|
||||
func (rn RenderableNode) IsStopped() bool {
|
||||
containerState, ok := rn.Latest.Lookup(docker.ContainerState)
|
||||
return !ok || containerState != docker.StateStopped
|
||||
}
|
||||
|
||||
// IsSystem checks if the RenderableNode is a system container/pod/etc.
|
||||
func (rn RenderableNode) IsSystem() bool {
|
||||
containerName, _ := rn.Latest.Lookup(docker.ContainerName)
|
||||
if _, ok := systemContainerNames[containerName]; ok {
|
||||
return false
|
||||
}
|
||||
imageName, _ := rn.Latest.Lookup(docker.ImageName)
|
||||
imagePrefix := strings.SplitN(imageName, ":", 2)[0] // :(
|
||||
if _, ok := systemImagePrefixes[imagePrefix]; ok {
|
||||
return false
|
||||
}
|
||||
roleLabel, _ := rn.Latest.Lookup(docker.LabelPrefix + "works.weave.role")
|
||||
if roleLabel == "system" {
|
||||
return false
|
||||
}
|
||||
namespace, _ := rn.Latest.Lookup(kubernetes.Namespace)
|
||||
if namespace == "kube-system" {
|
||||
return false
|
||||
}
|
||||
podName, _ := rn.Latest.Lookup(docker.LabelPrefix + "io.kubernetes.pod.name")
|
||||
if strings.HasPrefix(podName, "kube-system/") {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Prune returns a copy of the RenderableNode with all information not
|
||||
// strictly necessary for rendering nodes and edges stripped away.
|
||||
// Specifically, that means cutting out parts of the Node.
|
||||
|
||||
Reference in New Issue
Block a user