From 2749bcdc28183b869d117a727d5117e7a80864a8 Mon Sep 17 00:00:00 2001 From: Jack Griffin Date: Thu, 3 Sep 2015 01:31:47 +0000 Subject: [PATCH] Skip creating swift container if already exists Signed-off-by: Jack Griffin --- registry/storage/driver/swift/swift.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/registry/storage/driver/swift/swift.go b/registry/storage/driver/swift/swift.go index 0921ccc0..5871437f 100644 --- a/registry/storage/driver/swift/swift.go +++ b/registry/storage/driver/swift/swift.go @@ -165,8 +165,12 @@ func New(params Parameters) (*Driver, error) { return nil, fmt.Errorf("Swift authentication failed: %s", err) } - if err := ct.ContainerCreate(params.Container, nil); err != nil { - return nil, fmt.Errorf("Failed to create container %s (%s)", params.Container, err) + if _, _, err := ct.Container(params.Container); err == swift.ContainerNotFound { + if err := ct.ContainerCreate(params.Container, nil); err != nil { + return nil, fmt.Errorf("Failed to create container %s (%s)", params.Container, err) + } + } else if err != nil { + return nil, fmt.Errorf("Failed to retrieve info about container %s (%s)", params.Container, err) } d := &driver{