Skip to content

Commit

Permalink
Support debugging for init container (#15)
Browse files Browse the repository at this point in the history
* Support debugging for init container

Signed-off-by: Yeh-lei Wu <[email protected]>

* Correct comments

Signed-off-by: Yeh-lei Wu <[email protected]>
  • Loading branch information
aylei authored Feb 25, 2019
1 parent 84ba4a6 commit 16e8ddb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/plugin/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,22 @@ func (o *DebugOptions) getContainerIdByName(pod *corev1.Pod, containerName strin
continue
}
if !containerStatus.Ready {
return "", fmt.Errorf("container %s id not ready", containerName)
return "", fmt.Errorf("container [%s] not ready", containerName)
}
return containerStatus.ContainerID, nil
}

// #14 otherwise we should search for running init containers
for _, initContainerStatus := range pod.Status.InitContainerStatuses {
if initContainerStatus.Name != containerName {
continue
}
if initContainerStatus.State.Running == nil {
return "", fmt.Errorf("init container [%s] is not running", containerName)
}
return initContainerStatus.ContainerID, nil
}

return "", fmt.Errorf("cannot find specified container %s", containerName)
}

Expand Down

0 comments on commit 16e8ddb

Please sign in to comment.