Closed caddoo closed 5 years ago
After some help from https://github.com/sirlatrom on the docker community slack, he determined because the base vault docker image uses alpine which uses musl and the plugin needs glibc it failed.
I then updated my vault dockerfile to install the following: https://github.com/sgerrand/alpine-pkg-glibc
The error now is
Error enabling: Error making API request.
URL: POST http://192.168.1.60:9200/v1/sys/mounts/ethereum
Code: 400. Errors:
* plugin exited before we could connect
What does your vault config look like? Specifically, is api_addr set?
My vault config (on Darwin) looks like this. Note: I am using TLS to talk to vault:
"default_lease_ttl" = "24h"
"max_lease_ttl" = "24h"
"backend" "file" {
"path" = "/Users/immutability/etc/vault.d/data"
}
"api_addr" = "https://localhost:8200"
"listener" "tcp" {
"address" = "localhost:8200"
"tls_cert_file" = "/Users/immutability/etc/vault.d/vault.crt"
"tls_client_ca_file" = "/Users/immutability/etc/vault.d/root.crt"
"tls_key_file" = "/Users/immutability/etc/vault.d/vault.key"
}
"plugin_directory" = "/Users/immutability/etc/vault.d/vault_plugins"
{ "api_addr":"http://127.0.0.1:8200", "plugin_directory":"/vault/plugins", "backend":{ "consul":{ "scheme":"http", "address":"192.168.1.60:9500", "advertise_addr":"http://192.168.1.60", "path":"vault/" } }, "listener":{ "tcp":{ "address":"0.0.0.0:8200", "tls_disable":"true" } } }
That is exactly the config that is running. If I use postman to interact with the API publically. I get the same error message:
POST /sys/mounts/ethereum
{
"type": "plugin",
"config": {
"force_no_cache": true
},
"plugin_name": "ethereum-plugin"
}
Response:
{
"errors": [
"plugin exited before we could connect"
]
}
@cypherhat Is there anywhere I can see more verbose errors to try and debug?
Here is the output of ldd /vault/plugins/vault-ethereum
/lib64/ld-linux-x86-64.so.2 (0x7f0661440000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f0661440000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f0661440000)
Error relocating /vault/plugins/vault-ethereum: __fprintf_chk: symbol not found
Ok, let me review. Probably won't get to it until later this evening.
I am in the last stages of testing a release for the new go-ethereum release (Iceberg). I will cut a Darwin and Ubuntu-tested Linux build of that; then, I will start testing this on the official vault docker image. I apologize for the delay - I use a Xenial-based Vagrant box for testing the plugin rather than a Docker environment.
@cypherhat The official vault docker image is based off this OS: https://alpinelinux.org FYI
I think I need to build from source on Alpine, can you provide instructions on how to do this with Make or go build. Unfamiliar with both of these and I thought go build needs a src directory
Due to the difference in the libraries between glibc and musl I recompiled in the docker file and seem to have got it working.
For reference is my new vault docker file:
FROM vault:latest
# Install build tools
RUN apk add --update alpine-sdk
# Make new directory for plugins
RUN mkdir /vault/plugins
# Download and compile Ethereum plugin
RUN apk update \
&& apk add go git
RUN go get github.com/immutability-io/vault-ethereum \
&& go build github.com/immutability-io/vault-ethereum
RUN mv /root/go/bin/vault-ethereum /vault/plugins/vault-etheruem
I meant to return to this. Apologies.
Can you PR your Dockerfile? That way we can let others work from the official Docker image. Thanks!
Where would you like the Dockerfile? Also I'm still not up and running yet. Currently have this error:
vault write ethereum/accounts/test chain_id=1977 rpc_url=http://192.168.1.60:8545
Error writing data to ethereum/accounts/test: Error making API request.
URL: PUT http://192.168.1.60:9200/v1/ethereum/accounts/test
Code: 500. Errors:
* 1 error occurred:
* unexpected EOF
I've confirmed that from the Vault container I can create ethereum accounts via the JSON RPC:
curl 192.168.1.60:8545 -X POST --data '{"jsonrpc":"2.0","method":"personal_newAccount","params":["********"],"id":1}'
-H "Content-Type: application/json"
{"jsonrpc":"2.0","id":1,"result":"0x589f9ae1df19d051661ee27b3c937269b62ddd6a"}
Any idea how to debug?
You can put it in the root directory of the repo. As regards your error, the plugin doesn't talk to the Ethereum node to create an account, so it is something related to Vault-Plugin communication most likely. I can give it a try this weekend - I had thought you had success.
Closing due to lack of activity.
According to @jefferai here: https://github.com/hashicorp/vault/issues/3417
plugins should be built with CGO_ENABLED=0
@zambien this makes the build fail with:
go build github.com/ethereum/go-ethereum/crypto/secp256k1: build constraints exclude all Go files in /go/pkg/mod/github.com/ethereum/go-ethereum@v1.8.27/crypto/secp256k1
# github.com/ethereum/go-ethereum/rpc
/go/pkg/mod/github.com/ethereum/go-ethereum@v1.8.27/rpc/endpoints.go:96:19: undefined: ipcListen
/go/pkg/mod/github.com/ethereum/go-ethereum@v1.8.27/rpc/ipc.go:50:10: undefined: newIPCConnection
@jbunce, yep. Sorry about that. I forgot I had posted this here. The right way to handle this is to use some other means of cross-compilation if that is what you are going for (for example, compiling darwin in linux).
You can use xgo for this:
https://github.com/techknowlogick/xgo
Although perhaps that isn't maintained anymore so use git@github.com:techknowlogick/xgo.git.
The following will work assuming the following:
For example:
# get/build xgo with vendoring support
go get github.com/techknowlogick/xgo
cd $GOPATH/src/github.com/techknowlogick/xgo
go build .
# build with xgo
cd /tmp
git clone git@github.com:immutability-io/vault-ethereum.git
cd vault-ethereum
rm -rf vendor
$GOPATH/src/github.com/techknowlogick/xgo/xgo -out vault-ethereum --targets=darwin/amd64,linux/amd64,windows/amd64 -deps=https://gmplib.org/download/gmp/gmp-6.0.0a.tar.bz2 .
Perhaps a better approach would be to use goreleaser cross-compilation but I haven't looked into that yet.
https://medium.com/@robdefeo/cross-compile-with-cgo-and-goreleaser-6af884731222
In order to resolve this I'd like to recommend the following:
Anyone have issues with this?
Please PR. I'll approve.
This plugin is long overdue for a re-factor. I want to provide a way to allow smart contracts to be more elegantly integrated. Working on this...
As far as the initial issue, this blog explains the problem and the solution:
http://kefblog.com/2017-07-04/Golang-ang-docker
I'll include this in a PR shortly.
As far as the initial issue, this blog explains the problem and the solution:
FYI link changed to https://kefblog.com/Post/2017-07-04_golang-in-docker-without-disabling-cgo-on-alpine
When attempting to use the vault-ethereum plugin in a docker environment using the official vault docker image I am unable to mount the new plugin and receive a no such file or directory error.
Detailed Description
Here is the vault service in my docker compose file:
I extend the official docker image to attempt to install the vault ethereum plugin:
I then perform the following operations (this is a fresh install of vault with consul as the backend).
ls -lrt /vault/ output
ls -lrt /vault/plugins output
Your Environment
Host OS: Windows 10 Docker: 17.12.0-ce-win47 stable Vault Docker: 0.9.3 Vault Ethereum: v0.0.3