From 5b033abaa46149c1f20d8cdff58799edc9ccebfc Mon Sep 17 00:00:00 2001 From: cmeng Date: Fri, 4 Aug 2023 15:16:55 +1200 Subject: [PATCH] fix(registry): registry login failure for regular stack EE-5832 (#9986) --- api/exec/swarm_stack.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/api/exec/swarm_stack.go b/api/exec/swarm_stack.go index 3dcdbec2c..f8b031976 100644 --- a/api/exec/swarm_stack.go +++ b/api/exec/swarm_stack.go @@ -15,6 +15,7 @@ import ( "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/registryutils" "github.com/portainer/portainer/api/stacks/stackutils" + "github.com/rs/zerolog/log" ) // SwarmStackManager represents a service for managing stacks. @@ -64,16 +65,35 @@ func (manager *SwarmStackManager) Login(registries []portainer.Registry, endpoin if registry.Authentication { err = registryutils.EnsureRegTokenValid(manager.dataStore, ®istry) if err != nil { - return err + log. + Warn(). + Err(err). + Str("RegistryName", registry.Name). + Msg("Failed to validate registry token. Skip logging with this registry.") + + continue } username, password, err := registryutils.GetRegEffectiveCredential(®istry) if err != nil { - return err + log. + Warn(). + Err(err). + Str("RegistryName", registry.Name). + Msg("Failed to get effective credential. Skip logging with this registry.") + + continue } registryArgs := append(args, "login", "--username", username, "--password", password, registry.URL) - runCommandAndCaptureStdErr(command, registryArgs, nil, "") + err = runCommandAndCaptureStdErr(command, registryArgs, nil, "") + if err != nil { + log. + Warn(). + Err(err). + Str("RegistryName", registry.Name). + Msg("Failed to login.") + } } }