From d1738c124d2c1fbfb5becaad2a28dafcef4574fc Mon Sep 17 00:00:00 2001 From: Googlom Date: Wed, 23 Oct 2024 16:47:01 +0500 Subject: [PATCH 1/3] add some logging to Vault login --- pkg/vault/client.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/vault/client.go b/pkg/vault/client.go index 659d94c205..4e1fc842ab 100644 --- a/pkg/vault/client.go +++ b/pkg/vault/client.go @@ -90,9 +90,13 @@ func (c *Client) startTokenLifecycleManager(initialLoginDone chan struct{}) { initialLoginSucceed := false for i := 0; i < c.vaultApiClient.MaxRetries(); i++ { + if i != 0 { + log.Entry().Infof("Retrying Vault login. Attempt %d of %d", i, c.vaultApiClient.MaxRetries()) + } + vaultLoginResp, err := c.login() if err != nil { - log.Entry().Errorf("unable to authenticate to Vault: %v", err) + log.Entry().Warnf("unable to authenticate to Vault: %v", err) continue } if !initialLoginSucceed { @@ -103,7 +107,7 @@ func (c *Client) startTokenLifecycleManager(initialLoginDone chan struct{}) { tokenErr := c.manageTokenLifecycle(vaultLoginResp) if tokenErr != nil { - log.Entry().Errorf("unable to start managing token lifecycle: %v", err) + log.Entry().Warnf("unable to start managing token lifecycle: %v", err) continue } } From c1120cf59734c464f5d31319465c9110d78cc2c3 Mon Sep 17 00:00:00 2001 From: Googlom Date: Wed, 23 Oct 2024 16:49:01 +0500 Subject: [PATCH 2/3] allign groovy part of the sonar step --- vars/sonarExecuteScan.groovy | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/vars/sonarExecuteScan.groovy b/vars/sonarExecuteScan.groovy index 7265f4bbac..94d4c4fff6 100644 --- a/vars/sonarExecuteScan.groovy +++ b/vars/sonarExecuteScan.groovy @@ -65,17 +65,19 @@ void call(Map parameters = [:]) { writePipelineEnv(script: script, piperGoPath: piperGoPath) withEnv(environment) { influxWrapper(script) { - piperExecuteBin.credentialWrapper(config, credentialInfo) { - if (stepConfig.instance) { - withSonarQubeEnv(stepConfig.instance) { - echo "Instance is deprecated - please use serverUrl parameter to set URL to the Sonar backend." + try { + piperExecuteBin.credentialWrapper(config, credentialInfo) { + if (stepConfig.instance) { + withSonarQubeEnv(stepConfig.instance) { + echo "Instance is deprecated - please use serverUrl parameter to set URL to the Sonar backend." + sh "${piperGoPath} ${STEP_NAME}${customDefaultConfig}${customConfigArg}" + } + } else { sh "${piperGoPath} ${STEP_NAME}${customDefaultConfig}${customConfigArg}" - jenkinsUtils.handleStepResults(STEP_NAME, false, false) - readPipelineEnv(script: script, piperGoPath: piperGoPath) } - } else { - sh "${piperGoPath} ${STEP_NAME}${customDefaultConfig}${customConfigArg}" } + } finally { + jenkinsUtils.handleStepResults(STEP_NAME, false, false) } } } From b45d12f735a48d65e2480fab3d634930bc8f536a Mon Sep 17 00:00:00 2001 From: Googlom Date: Wed, 23 Oct 2024 17:05:11 +0500 Subject: [PATCH 3/3] Revert "add some logging to Vault login" This reverts commit d1738c124d2c1fbfb5becaad2a28dafcef4574fc. --- pkg/vault/client.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/vault/client.go b/pkg/vault/client.go index 4e1fc842ab..659d94c205 100644 --- a/pkg/vault/client.go +++ b/pkg/vault/client.go @@ -90,13 +90,9 @@ func (c *Client) startTokenLifecycleManager(initialLoginDone chan struct{}) { initialLoginSucceed := false for i := 0; i < c.vaultApiClient.MaxRetries(); i++ { - if i != 0 { - log.Entry().Infof("Retrying Vault login. Attempt %d of %d", i, c.vaultApiClient.MaxRetries()) - } - vaultLoginResp, err := c.login() if err != nil { - log.Entry().Warnf("unable to authenticate to Vault: %v", err) + log.Entry().Errorf("unable to authenticate to Vault: %v", err) continue } if !initialLoginSucceed { @@ -107,7 +103,7 @@ func (c *Client) startTokenLifecycleManager(initialLoginDone chan struct{}) { tokenErr := c.manageTokenLifecycle(vaultLoginResp) if tokenErr != nil { - log.Entry().Warnf("unable to start managing token lifecycle: %v", err) + log.Entry().Errorf("unable to start managing token lifecycle: %v", err) continue } }