Argelbargel / vault-raft-snapshot-agent

An agent which creates periodic snapshots of Vault's integrated raft storage and stores them locally or in remote storages as backup in case of system failure or user errors.
MIT License
9 stars 4 forks source link

Permission Denied (v0.11.0) #38

Open azertypwd opened 2 weeks ago

azertypwd commented 2 weeks ago

Hello !

I have some issue with v0.11.0, with approle or with userpass or directly root token i have a Permission Denied (403) image image

But the same configuration work with v0.10.18 image

Thanks

glisav commented 1 week ago

Hello @Argelbargel I am using the same version as @azertypwd and having the same issue.

Argelbargel commented 1 week ago

Hi,

could you check if vault3 is indeed the leader of your vault-cluster?

Perhaps you could attach your config-files?

I'm using 0.11.0 without leader-detection in production so the problem seems to be with that part of the code...

glisav commented 1 week ago

Hi @Argelbargel I tried to remove the autoDetectLeader field from configurations and got the following logs:

Starting agent... 2024/11/04 13:21:14 INFO Using configuration from /etc/vault.d/snapshots.yaml... 2024/11/04 13:21:14 WARN unable to refresh auth node=https://$VAULT_ADDR:8200 2024/11/04 13:21:14 ERROR Could not take snapshot of vault nextSnapshot=2024-11-04T14:21:14.236Z error="could not (re-)connect to leader: could not connect to leader"

Argelbargel commented 1 week ago

Hi @glisav

now there seems to be a problem with your config. v0.11.0 expects a list of nodes in vault.nodes.url and the elements of that list may not contain environment variables (that is something i'll be looking at if it is important).

glisav commented 1 week ago

Hi @Argelbargel I am using the following configuration:

config: vault: nodes: urls:

Argelbargel commented 1 week ago

the entry in urls should be the "real" url without the environment variable. Currently env vars are not expanded in the list or urls

glisav commented 1 week ago

Sorry for the confusion. It is the real actual value in the configuration properties, I have just used the env var only here in the comment @Argelbargel

Argelbargel commented 1 week ago

Ah. Okay. That is a bit strange.

The configuration i'm using looks like this:

config:
  vault:
    nodes:
      urls:
        - "http://vault-active:8200"
      autoDetectLeader: false

I've just built release v0.11.2 https://github.com/Argelbargel/vault-raft-snapshot-agent/releases/tag/v0.11.2 which contains additional logging. @glisav Could you try it with -l debug?

glisav commented 1 week ago

Hi @Argelbargel I replaced the image tag to the latest one v0.11.2, updated the vault > nodes > urls section, setting autoDetectLeader=true and got the following from the logs:

image

I don't know why the first attempt of making a snapshot, results in an error "403 Permission Denied"

Argelbargel commented 1 week ago

@glisav could you enable debug logging? On the command-line that should be -l debug as additional argument.

glisav commented 1 week ago

Hi @Argelbargel I enabled the debug mode and from the logs I found out that Raft can find the leader node. I solved this issue by adding the URL of the Vault active node in the config file and setting autoDetectLeader=false Thanks!

Argelbargel commented 1 week ago

@glisav: could you post your logs (of the failing leader-detection) anyway, please? I'd like to check to flow/path the code takes and what the error-messages were in yours and @azertypwd case. I'd write some tests for the leader-detection logic but it seems some of my assumptions/my understanding of what the vault-api does were wrong since it does not work in your real-world cases.

If you could at your configuration file (without credentials! ;-)) and which nodes your vault-cluster has, that would be really great!