Identify kubernetes pause containers more broadly

This commit is contained in:
Alfonso Acosta
2016-08-08 14:15:29 +00:00
parent 9740fcca40
commit b64686ffc3
2 changed files with 18 additions and 15 deletions

View File

@@ -142,6 +142,13 @@ func (r *Reporter) podEvent(e Event, pod Pod) {
}
}
// IsPauseImageName indicates whether an image name corresponds to a
// kubernetes pause container image.
func IsPauseImageName(imageName string) bool {
return strings.Contains(imageName, "google_containers/pause")
}
func isPauseContainer(n report.Node, rpt report.Report) bool {
containerImageIDs, ok := n.Parents.Lookup(report.ContainerImage)
if !ok {
@@ -156,9 +163,7 @@ func isPauseContainer(n report.Node, rpt report.Report) bool {
if !ok {
continue
}
if docker.ImageNameWithoutVersion(imageName) == "google_containers/pause" {
return true
}
return IsPauseImageName(imageName)
}
return false
}

View File

@@ -219,7 +219,7 @@ func IsApplication(n report.Node) bool {
}
imageName, _ := n.Latest.Lookup(docker.ImageName)
imagePrefix := strings.SplitN(imageName, ":", 2)[0] // :(
if _, ok := systemImagePrefixes[imagePrefix]; ok {
if _, ok := systemImagePrefixes[imagePrefix]; ok || kubernetes.IsPauseImageName(imagePrefix) {
return false
}
roleLabel, _ := n.Latest.Lookup(docker.LabelPrefix + "works.weave.role")
@@ -268,15 +268,13 @@ var systemContainerNames = map[string]struct{}{
}
var systemImagePrefixes = map[string]struct{}{
"swarm": {},
"weaveworks/scope": {},
"weaveworks/weavedns": {},
"weaveworks/weave": {},
"weaveworks/weaveproxy": {},
"weaveworks/weaveexec": {},
"amazon/amazon-ecs-agent": {},
"beta.gcr.io/google_containers/pause": {},
"gcr.io/google_containers/pause": {},
"openshift/origin-pod": {},
"docker.io/openshift/origin-pod": {},
"swarm": {},
"weaveworks/scope": {},
"weaveworks/weavedns": {},
"weaveworks/weave": {},
"weaveworks/weaveproxy": {},
"weaveworks/weaveexec": {},
"amazon/amazon-ecs-agent": {},
"openshift/origin-pod": {},
"docker.io/openshift/origin-pod": {},
}