dockershim: bug fixes and more unit tests

Fixing the name triming and other small bugs. Added sandbox listing unit tests.
This commit is contained in:
Yu-Ju Hong
2016-08-26 16:15:06 -07:00
parent 115855bbd2
commit a1833d1947
5 changed files with 64 additions and 27 deletions

View File

@@ -206,6 +206,9 @@ func buildContainerName(sandboxConfig *runtimeApi.PodSandboxConfig, containerCon
// parseContainerName unpacks a container name, returning the pod name, namespace, UID,
// container name and attempt.
func parseContainerName(name string) (podName, podNamespace, podUID, containerName string, attempt uint32, err error) {
// Docker adds a "/" prefix to names. so trim it.
name = strings.TrimPrefix(name, "/")
parts := strings.Split(name, "_")
if len(parts) == 0 || parts[0] != kubePrefix {
err = fmt.Errorf("failed to parse container name %q into parts", name)