Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pkg/tracejob/selected_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func resolvePodToTarget(podClient corev1.PodInterface, resourceID, container, ta
target.Node = pod.Spec.NodeName
target.PodUID = string(pod.UID)

if len(pod.Spec.Containers) == 1 {
if len(pod.Spec.Containers) == 1 && len(pod.Spec.InitContainers) == 0 {
targetContainer = pod.Spec.Containers[0].Name
} else {
// FIXME verify container is not empty
Expand All @@ -284,6 +284,15 @@ func resolvePodToTarget(podClient corev1.PodInterface, resourceID, container, ta
}
}

for _, s := range pod.Status.InitContainerStatuses {
if s.Name == targetContainer {
containerID := strings.TrimPrefix(s.ContainerID, "docker://")
containerID = strings.TrimPrefix(containerID, "containerd://")
target.ContainerID = containerID
break
}
}

if target.ContainerID == "" {
return fmt.Errorf("no containers found for the provided pod %s and container %s combination", pod.Name, targetContainer)
}
Expand Down