From d8cd4038c2142c077e379d29b1590bc16f352bcd Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Tue, 13 Oct 2020 14:48:05 +0200 Subject: [PATCH] Fix panic when invoking inspect with empty container id (ACI SDK returns status 200 but nil container group properties) Signed-off-by: Guillaume Tardif --- aci/containers.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aci/containers.go b/aci/containers.go index 93fb03eb9..3f6be0893 100644 --- a/aci/containers.go +++ b/aci/containers.go @@ -235,12 +235,15 @@ func (cs *aciContainerService) Delete(ctx context.Context, containerID string, r func (cs *aciContainerService) Inspect(ctx context.Context, containerID string) (containers.Container, error) { groupName, containerName := getGroupAndContainerName(containerID) + if containerID == "" { + return containers.Container{}, errors.New("cannot inspect empty container ID") + } cg, err := getACIContainerGroup(ctx, cs.ctx, groupName) if err != nil { return containers.Container{}, err } - if cg.StatusCode == http.StatusNoContent { + if cg.IsHTTPStatus(http.StatusNoContent) || cg.ContainerGroupProperties == nil || cg.ContainerGroupProperties.Containers == nil { return containers.Container{}, errdefs.ErrNotFound }