Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating database object: invalid database version #1

Closed
Michal-Kucera opened this issue Mar 24, 2022 · 5 comments · Fixed by #2
Closed

Error creating database object: invalid database version #1

Michal-Kucera opened this issue Mar 24, 2022 · 5 comments · Fixed by #2

Comments

@Michal-Kucera
Copy link

Michal-Kucera commented Mar 24, 2022

Hello.

I'd love to use your plugin side by side with Redis in version 6-alpine, Vault in version 1.9.4 with Postgres as data storage, and spring-cloud-vault with Multiple Databases approach.

Yet, I've made it only until plugin initialization, which returns 400 HTTP error code and the following response:

michal@michal:~/code/monitoring/vault/plugin$  docker exec -it monitoring_vault_1 vault write database/config/transaction-service \
  plugin_name="redis-database-plugin" \
  host="redis" \
  port=6379 \
  username="redis" \
  password="changeit" \
  allowed_roles="transaction-service"
Error writing data to database/config/transaction-service: Error making API request.

URL: PUT http://vault:8200/v1/database/config/transaction-service
Code: 400. Errors:

* error creating database object: invalid database version: 2 errors occurred:
        * fork/exec /config/plugin/redis-database-plugin: no such file or directory
        * fork/exec /config/plugin/redis-database-plugin: no such file or directory

Vault docker log:

2022-03-24T15:39:32.705Z [INFO]  secrets.database.database_4ffbc22d.redis-database-plugin: configuring client automatic mTLS

The aforementioned file is accessible from my docker environment:

michal@michal:~/code/monitoring/vault/plugin$ docker exec -it monitoring_vault_1 ls -l /config/plugin/redis-database-plugin
-rwxrwxr-x    1 1000     vault     14686652 Mar 24 15:49 /config/plugin/redis-database-plugin

Thus I'm wondering if this is happening due to an issue on my side or perhaps this plugin is not compatible with either Vault 1.9.4 or Redis 6.

Cheers!
Michal

@fhitchen
Copy link
Contributor

fhitchen commented Mar 24, 2022 via email

@fhitchen
Copy link
Contributor

fhitchen commented Mar 24, 2022 via email

@fhitchen
Copy link
Contributor

Michal,
I pulled the docker image you used vault:1.9.4 and copied the plugin to it and ran the ldd command.

tmp # ldd redis-database-plugin 
        /lib64/ld-linux-x86-64.so.2 (0x7f0f12bc8000)
        libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f0f12bc8000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f0f12bc8000)
Error relocating redis-database-plugin: __vfprintf_chk: symbol not found
Error relocating redis-database-plugin: __fprintf_chk: symbol not found

The two errors for missing symbols are because the vault image is using alpine linux which uses a different glibc implementation I think.

Try linking the plugin statically like so
$ CGO_ENABLED=0 go build -ldflags='-extldflags=-static' -o ./cmd/redis-database-plugin/redis-database-plugin ./cmd/redis-database-plugin/
This should produce a statically linked plugin which will run in an Alpine container.
To check that it is statically linked $ ldd cmd/redis-database-plugin/redis-database-plugin not a dynamic executable

@Michal-Kucera
Copy link
Author

Hi Francis,

Indeed it was an issue with symbol not found:

michal@michal:~/code/monitoring/vault/plugin$ docker exec -it monitoring_vault_1  ldd /config/plugin/redis-database-plugin
        /lib64/ld-linux-x86-64.so.2 (0x7f9ff8a71000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f9ff8a71000)
Error relocating /config/plugin/redis-database-plugin: __vfprintf_chk: symbol not found
Error relocating /config/plugin/redis-database-plugin: __fprintf_chk: symbol not found

After re-building the plugin with CGO_ENABLED=0 go build -ldflags='-extldflags=-static' -o redis-database-plugin ./cmd/redis-database-plugin/ these errors have disappeared:

michal@michal:~/code/monitoring/vault/plugin$ docker exec -it monitoring_vault_1  ldd /config/plugin/redis-database-plugin
/lib/ld-musl-x86_64.so.1: /config/plugin/redis-database-plugin: Not a valid dynamic program

On top of this, I was able to use Dynamic Role Creation side by side with Spring Cloud Vault.

Thanks so much for your guidance, if you don't mind, I'd like to push a PR with spring-cloud-vault integration section in README.md, so it could help others as well.

Regards,
Michal

@fhitchen
Copy link
Contributor

fhitchen commented Mar 25, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants