datawire / aes-example-plugins

A few example Ambassador Edge Stack filter plugins
4 stars 12 forks source link

plugin was built with a different version of package github.com/hashicorp/consul/api #59

Closed kriptor closed 3 years ago

kriptor commented 3 years ago

Hi,

I cloned the repo and did the following (under master branch):

$ make APRO_VERSION=1.12.2 DOCKER_IMAGE=testrepo/apro-example-plugin:v1
docker run --rm --entrypoint=cat docker.io/datawire/aes:1.12.2 /ambassador/aes-abi.txt > aes-abi.txt
{ \
        sed -n 's/^# *_*/AES_/p' < aes-abi.txt; \
        echo AES_GOENV=$(sed -En 's/^# *([A-Z])/\1/p' < aes-abi.txt); \
    } > aes-abi.mk
go list ./...
go: downloading github.com/hashicorp/consul v1.4.3
go: downloading github.com/mitchellh/mapstructure v1.1.2
go: downloading github.com/hashicorp/go-rootcerts v1.0.0
go: downloading github.com/hashicorp/go-cleanhttp v0.5.1
go: downloading github.com/hashicorp/serf v0.8.2
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da
go: downloading github.com/hashicorp/go-immutable-radix v1.0.0
go: downloading github.com/hashicorp/golang-lru v0.5.4
github.com/datawire/apro-example-plugin
docker pull golang:1.15.0 || docker run --rm --entrypoint=true golang:1.15.0
1.15.0: Pulling from library/golang
Digest: sha256:4afdc8ea330492631e6c0b46ba04ba985e8ff494431124816aac1bc1b18ff1ce
Status: Image is up to date for golang:1.15.0
docker.io/library/golang:1.15.0
grep -v '^#' < aes-abi.txt > aes-abi.pkgs.txt
docker build -t plugin-builder --build-arg CUR_DIR=/Users/user1/git/apro-example-plugin --build-arg AES_GOVERSION=1.15.0 --build-arg UID=501 build/
[+] Building 0.1s (10/10) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                                                     0.0s
 => => transferring dockerfile: 37B                                                                                                                                                                                                      0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                                                                          0.0s
 => [internal] load metadata for docker.io/library/golang:1.15.0                                                                                                                                                                         0.0s
 => [1/6] FROM docker.io/library/golang:1.15.0                                                                                                                                                                                           0.0s
 => CACHED [2/6] RUN apt update                                                                                                                                                                                                          0.0s
 => CACHED [3/6] RUN apt install rsync -y                                                                                                                                                                                                0.0s
 => CACHED [4/6] RUN mkdir -p /Users/user1/git/apro-example-plugin                                                                                                                                                                         0.0s
 => CACHED [5/6] RUN mkdir -p /mnt/goproxy                                                                                                                                                                                               0.0s
 => CACHED [6/6] WORKDIR /Users/user1/git/apro-example-plugin                                                                                                                                                                              0.0s
 => exporting to image                                                                                                                                                                                                                   0.0s
 => => exporting layers                                                                                                                                                                                                                  0.0s
 => => writing image sha256:a1c341da9ab688d9c7552d178bc0ab14a9b23545dc6f784ae7a5600a1d8a5ff9                                                                                                                                             0.0s
 => => naming to docker.io/library/plugin-builder                                                                                                                                                                                        0.0s
docker run --rm -d --env-file=/Users/user1/git/apro-example-plugin/aes-abi.mk plugin-builder
fb7b5fda64638a77bcec9f9880a4210893f07aa881667295fa48b50e6ea823b0
rsync --blocking-io -e 'docker exec -i' --exclude-from=/Users/user1/git/apro-example-plugin/build/sync-excludes.txt -r . fb7b5fda6463:/Users/user1/git/apro-example-plugin
rsync --blocking-io -e 'docker exec -i' -r /Users/user1/go/pkg/mod/cache/download/ fb7b5fda6463:/mnt/goproxy/
docker exec -i fb7b5fda6463 go build -trimpath -buildmode=plugin -o consul-plugin.so consul-plugin.go
go: downloading github.com/hashicorp/consul v1.4.3
go: downloading github.com/hashicorp/serf v0.8.2
go: downloading github.com/hashicorp/go-cleanhttp v0.5.1
go: downloading github.com/hashicorp/go-rootcerts v1.0.0
go: downloading github.com/mitchellh/mapstructure v1.1.2
go: downloading github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da
go: downloading github.com/hashicorp/go-immutable-radix v1.0.0
go: downloading github.com/hashicorp/golang-lru v0.5.4
rsync --blocking-io -e 'docker exec -i' -a fb7b5fda6463:/Users/user1/git/apro-example-plugin/consul-plugin.so .
docker exec -i fb7b5fda6463 go build -trimpath -buildmode=plugin -o method-change.so method-change.go
rsync --blocking-io -e 'docker exec -i' -a fb7b5fda6463:/Users/user1/git/apro-example-plugin/method-change.so .
docker exec -i fb7b5fda6463 go build -trimpath -buildmode=plugin -o param-plugin.so param-plugin.go
rsync --blocking-io -e 'docker exec -i' -a fb7b5fda6463:/Users/user1/git/apro-example-plugin/param-plugin.so .
docker exec -i fb7b5fda6463 go build -trimpath -buildmode=plugin -o wiki-plugin.so wiki-plugin.go
rsync --blocking-io -e 'docker exec -i' -a fb7b5fda6463:/Users/user1/git/apro-example-plugin/wiki-plugin.so .
docker exec -i fb7b5fda6463 go build -trimpath -buildmode=plugin -o x-dc-plugin.so x-dc-plugin.go
rsync --blocking-io -e 'docker exec -i' -a fb7b5fda6463:/Users/user1/git/apro-example-plugin/x-dc-plugin.so .
docker exec -i fb7b5fda6463 go build -trimpath -buildmode=plugin -o xff-plugin.so xff-plugin.go
rsync --blocking-io -e 'docker exec -i' -a fb7b5fda6463:/Users/user1/git/apro-example-plugin/xff-plugin.so .
sed 's,@AES_IMAGE@,docker.io/datawire/aes:1.12.2,' < Dockerfile.in > Dockerfile
docker build -t testrepo/apro-example-plugin:v1 .
[+] Building 2.4s (7/7) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                                                     0.0s
 => => transferring dockerfile: 115B                                                                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                        0.0s
 => => transferring context: 34B                                                                                                                                                                                                         0.0s
 => [internal] load metadata for docker.io/datawire/aes:1.12.2                                                                                                                                                                           0.0s
 => [internal] load build context                                                                                                                                                                                                        2.3s
 => => transferring context: 54.38MB                                                                                                                                                                                                     2.2s
 => [1/2] FROM docker.io/datawire/aes:1.12.2                                                                                                                                                                                             0.0s
 => CACHED [2/2] COPY ./*.so /etc/ambassador-plugins/                                                                                                                                                                                    0.0s
 => exporting to image                                                                                                                                                                                                                   0.0s
 => => exporting layers                                                                                                                                                                                                                  0.0s
 => => writing image sha256:3e2900ca721b83157a7476d0941fe9e977d4d35a784d092018d90eb3b0129c74                                                                                                                                             0.0s
 => => naming to docker.io/testrepo/apro-example-plugin:v1                                                                                                                                                                               0.0s
date > .docker.stamp
$
$ aes-plugin-runner :8080 ./consul-plugin.so
 > aes-plugin-runner 1.12.2 (go1.15 darwin/amd64)
 > running in Docker
 $ 'docker' 'run' '--rm' '-it' '--volume=/Users/user1/git/apro-example-plugin:/Users/user1/git/apro-example-plugin:ro' '--publish=:8080:8080' '--entrypoint=/ambassador/aes-plugin-runner' 'docker.io/datawire/aes:1.12.2' ':8080' '/Users/user1/git/apro-example-plugin/consul-plugin.so'
2021/04/08 22:27:49 AMBASSADOR_CLUSTER_ID=07eb43c8-1166-5145-a060-45e4dd907e10
 > aes-plugin-runner 1.12.2 (go1.15 linux/amd64)
 > running natively
/ambassador/aes-plugin-runner: error: load plugin file: plugin.Open("/Users/user1/git/apro-example-plugin/consul-plugin"): plugin was built with a different version of package github.com/hashicorp/consul/api
$
$ aes-plugin-runner :8080 ./x-dc-plugin.so
 > aes-plugin-runner 1.12.2 (go1.15 darwin/amd64)
 > running in Docker
 $ 'docker' 'run' '--rm' '-it' '--volume=/Users/user1/git/apro-example-plugin:/Users/user1/git/apro-example-plugin:ro' '--publish=:8080:8080' '--entrypoint=/ambassador/aes-plugin-runner' 'docker.io/datawire/aes:1.12.2' ':8080' '/Users/user1/git/apro-example-plugin/x-dc-plugin.so'
2021/04/08 22:31:34 AMBASSADOR_CLUSTER_ID=07eb43c8-1166-5145-a060-45e4dd907e10
 > aes-plugin-runner 1.12.2 (go1.15 linux/amd64)
 > running natively
/ambassador/aes-plugin-runner: error: load plugin file: plugin.Open("/Users/user1/git/apro-example-plugin/x-dc-plugin"): plugin was built with a different version of package github.com/hashicorp/consul/api
$
$

Is go.mod correct?

In my plugin I would actually like to use

... but it seems even the samples don't work.

Is it possible to get a complete dependency graph of AES 1.12.2 for it seems quite impossible to successfully/correctly build any kind of non-trivial plugin?

Thx

LukeShu commented 3 years ago

Ugg, this is because of some weirdness with how Consul split their go.mod file; it's confusing the version check in the Makefile in to thinking everything's OK when it's not. This is already fixed on AES's master branch (by virtue of upgrading the Consul libraries) and will be fixed in 1.13.0; but we should fix the examples for 1.12, certainly.

The example plugins that don't use github.com/hashicorp/consul/* should all work fine.

Is it possible to get a complete dependency graph of AES 1.12.2 for it seems quite impossible to successfully/correctly build any kind of non-trivial plugin?

Yes, so that's what it's doing when the Makefile runs:

docker run --rm --entrypoint=cat docker.io/datawire/aes:1.12.2 /ambassador/aes-abi.txt > aes-abi.txt

aes-abi.txt is the definitive listing of what went in to the actual AES executable. Alternatively, if you don't want to trust that, you can run go version -m /path/to/file on the /usr/local/bin/amb-sidecar file from the AES image (go is not installed in the image; you can apk add go, or extract the file from the image).

kriptor commented 3 years ago

@LukeShu thanks for the explanation, I appreciate it.