Преглед на файлове

handling the cmdline change in `runsc`

Nikolay Sivko преди 3 години
родител
ревизия
0d0cdda853
променени са 1 файла, в които са добавени 5 реда и са изтрити 1 реда
  1. 5 1
      containers/registry.go

+ 5 - 1
containers/registry.go

@@ -246,8 +246,9 @@ func (r *Registry) getOrCreateContainer(pid uint32) *Container {
 		cmdline := proc.GetCmdline(pid)
 		parts := bytes.Split(cmdline, []byte{0})
 		if len(parts) > 0 {
+			cmd := parts[0]
 			lastArg := parts[len(parts)-1]
-			if bytes.HasSuffix(parts[0], []byte("runsc-sandbox")) && containerIdRegexp.Match(lastArg) {
+			if (bytes.HasSuffix(cmd, []byte("runsc-sandbox")) || bytes.HasSuffix(cmd, []byte("runsc"))) && containerIdRegexp.Match(lastArg) {
 				cg.ContainerId = string(lastArg)
 			}
 		}
@@ -309,6 +310,9 @@ func calcId(cg *cgroup.Cgroup, md *ContainerMetadata) ContainerID {
 	default:
 		return ""
 	}
+	if cg.ContainerId == "" {
+		return ""
+	}
 	if md.labels["io.kubernetes.pod.name"] != "" {
 		pod := md.labels["io.kubernetes.pod.name"]
 		namespace := md.labels["io.kubernetes.pod.namespace"]