fix(api): ignore Docker login errors during stack deployment (#1635)

pull/1648/head
Anthony Lapenna 2018-02-07 08:37:01 +01:00 committed by GitHub
parent 1c67db0c70
commit 1de0619fd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 18 deletions

View File

@ -23,27 +23,19 @@ func NewStackManager(binaryPath string) *StackManager {
} }
// Login executes the docker login command against a list of registries (including DockerHub). // Login executes the docker login command against a list of registries (including DockerHub).
func (manager *StackManager) Login(dockerhub *portainer.DockerHub, registries []portainer.Registry, endpoint *portainer.Endpoint) error { func (manager *StackManager) Login(dockerhub *portainer.DockerHub, registries []portainer.Registry, endpoint *portainer.Endpoint) {
command, args := prepareDockerCommandAndArgs(manager.binaryPath, endpoint) command, args := prepareDockerCommandAndArgs(manager.binaryPath, endpoint)
for _, registry := range registries { for _, registry := range registries {
if registry.Authentication { if registry.Authentication {
registryArgs := append(args, "login", "--username", registry.Username, "--password", registry.Password, registry.URL) registryArgs := append(args, "login", "--username", registry.Username, "--password", registry.Password, registry.URL)
err := runCommandAndCaptureStdErr(command, registryArgs, nil) runCommandAndCaptureStdErr(command, registryArgs, nil)
if err != nil {
return err
}
} }
} }
if dockerhub.Authentication { if dockerhub.Authentication {
dockerhubArgs := append(args, "login", "--username", dockerhub.Username, "--password", dockerhub.Password) dockerhubArgs := append(args, "login", "--username", dockerhub.Username, "--password", dockerhub.Password)
err := runCommandAndCaptureStdErr(command, dockerhubArgs, nil) runCommandAndCaptureStdErr(command, dockerhubArgs, nil)
if err != nil {
return err
}
} }
return nil
} }
// Logout executes the docker logout command. // Logout executes the docker logout command.

View File

@ -772,13 +772,9 @@ func (handler *StackHandler) handleDeleteStack(w http.ResponseWriter, r *http.Re
func (handler *StackHandler) deployStack(config *stackDeploymentConfig) error { func (handler *StackHandler) deployStack(config *stackDeploymentConfig) error {
handler.stackCreationMutex.Lock() handler.stackCreationMutex.Lock()
err := handler.StackManager.Login(config.dockerhub, config.registries, config.endpoint) handler.StackManager.Login(config.dockerhub, config.registries, config.endpoint)
if err != nil {
handler.stackCreationMutex.Unlock()
return err
}
err = handler.StackManager.Deploy(config.stack, config.prune, config.endpoint) err := handler.StackManager.Deploy(config.stack, config.prune, config.endpoint)
if err != nil { if err != nil {
handler.stackCreationMutex.Unlock() handler.stackCreationMutex.Unlock()
return err return err

View File

@ -380,7 +380,7 @@ type (
// StackManager represents a service to manage stacks. // StackManager represents a service to manage stacks.
StackManager interface { StackManager interface {
Login(dockerhub *DockerHub, registries []Registry, endpoint *Endpoint) error Login(dockerhub *DockerHub, registries []Registry, endpoint *Endpoint)
Logout(endpoint *Endpoint) error Logout(endpoint *Endpoint) error
Deploy(stack *Stack, prune bool, endpoint *Endpoint) error Deploy(stack *Stack, prune bool, endpoint *Endpoint) error
Remove(stack *Stack, endpoint *Endpoint) error Remove(stack *Stack, endpoint *Endpoint) error