gocd / gocd-vault-secret-plugin

GoCD secrets plugin for HashiCorp's Vault
https://gocd.org
14 stars 7 forks source link

-Dplugin.com.thoughtworks.gocd.secretmanager.vault.log.level=debug does not increase log level #52

Open etSpark opened 3 years ago

etSpark commented 3 years ago

Troubleshooting error responses from a remote vault server is almost impossible with the provided logs.

Having a go-server running with parameter -Dplugin.com.thoughtworks.gocd.secretmanager.vault.log.level=debug doesn't seem to increase the log level.

What would be of very interest would be the body of the request made against the vault server, headers inclusive, as well as the full response with headers. This would help to understand how queries are made and if there was a wrong path provided etc.

sample stacktrace:

ERROR [110@MessageListener for WorkFinder] Executor:127 - Failed to lookup secret from vault. com.bettercloud.vault.VaultException: Vault responded with HTTP status code: 403 Response body: {"errors":["1 error occurred:\n\t* permission denied\n\n"]}

    at com.bettercloud.vault.api.Logical.read(Logical.java:98)
    at com.bettercloud.vault.api.Logical.read(Logical.java:74)
    at com.thoughtworks.gocd.secretmanager.vault.SecretConfigLookupExecutor.execute(SecretConfigLookupExecutor.java:51)
    at com.thoughtworks.gocd.secretmanager.vault.SecretConfigLookupExecutor.execute(SecretConfigLookupExecutor.java:33)
    at cd.go.plugin.base.executors.secrets.LookupExecutor.execute(LookupExecutor.java:28)
    at cd.go.plugin.base.dispatcher.RequestDispatcher.lambda$dispatch$0(RequestDispatcher.java:41)
    at java.base/java.util.Optional.map(Unknown Source)
    at cd.go.plugin.base.dispatcher.RequestDispatcher.dispatch(RequestDispatcher.java:41)
    at com.thoughtworks.gocd.secretmanager.vault.VaultPlugin.handle(VaultPlugin.java:59)
    at com.thoughtworks.go.plugin.infra.DefaultPluginManager.lambda$submitTo$0(DefaultPluginManager.java:134)
    at com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.executeActionOnTheService(FelixGoPluginOSGiFramework.java:208)
    at com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.doOn(FelixGoPluginOSGiFramework.java:164)
    at com.thoughtworks.go.plugin.infra.DefaultPluginManager.submitTo(DefaultPluginManager.java:131)
    at com.thoughtworks.go.plugin.access.PluginRequestHelper.submitRequest(PluginRequestHelper.java:49)
    at com.thoughtworks.go.plugin.access.secrets.v1.SecretsExtensionV1.lookupSecrets(SecretsExtensionV1.java:101)
    at com.thoughtworks.go.plugin.access.secrets.SecretsExtension.lookupSecrets(SecretsExtension.java:79)
    at com.thoughtworks.go.server.service.SecretParamResolver.lambda$lookupAndUpdateSecretParamsValue$0(SecretParamResolver.java:89)
    at java.base/java.util.HashMap.forEach(Unknown Source)
    at com.thoughtworks.go.server.service.SecretParamResolver.resolve(SecretParamResolver.java:80)
    at com.thoughtworks.go.server.service.SecretParamResolver.resolve(SecretParamResolver.java:66)
    at com.thoughtworks.go.server.service.BuildAssignmentService.lambda$createWork$2(BuildAssignmentService.java:298)
    at com.thoughtworks.go.server.transaction.TransactionTemplate.lambda$execute$1(TransactionTemplate.java:31)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
    at com.thoughtworks.go.server.transaction.TransactionTemplate.execute(TransactionTemplate.java:28)
    at com.thoughtworks.go.server.service.BuildAssignmentService.lambda$createWork$3(BuildAssignmentService.java:288)
    at com.thoughtworks.go.server.transaction.TransactionTemplate.transactionSurrounding(TransactionTemplate.java:60)
    at com.thoughtworks.go.server.service.BuildAssignmentService.createWork(BuildAssignmentService.java:272)
    at com.thoughtworks.go.server.service.BuildAssignmentService.assignWorkToAgent(BuildAssignmentService.java:181)
    at com.thoughtworks.go.server.service.BuildAssignmentService.assignWorkToAgent(BuildAssignmentService.java:160)
    at com.thoughtworks.go.server.messaging.scheduling.WorkFinder.onMessage(WorkFinder.java:60)
    at com.thoughtworks.go.server.messaging.scheduling.WorkFinder.onMessage(WorkFinder.java:32)
    at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.runImpl(JMSMessageListenerAdapter.java:84)
    at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.run(JMSMessageListenerAdapter.java:64)
    at java.base/java.lang.Thread.run(Unknown Source)
arvindsv commented 3 years ago

You're right. There doesn't seem to be extra logging. If you'd like to add it here and elsewhere, here is an example. Lines 10, 16 and 39 are probably going to be useful.