krakend / krakend-ce

KrakenD Community Edition: High-performance, stateless, declarative, API Gateway written in Go.
https://www.krakend.io
Apache License 2.0
1.92k stars 452 forks source link

Error relocating grpc-gateway.so: unsupported relocation type 7 #831

Open Kozaky opened 9 months ago

Kozaky commented 9 months ago

Hi,

I am basically following the example from this blog to create a grpc plugin: https://www.krakend.io/blog/krakend-grpc-gateway-plugin/

The issue is that ones I try to run it on my mac I get the following error:

2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.838 ▶ DEBUG [SERVICE: telemetry/logging] Improved logging started. 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.838 ▶ INFO Starting KrakenD v2.5.0 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.839 ▶ INFO Working directory is /etc/krakend 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.839 ▶ DEBUG [SERVICE: Plugin Loader] Starting loading process 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.842 ▶ DEBUG [SERVICE: Executor Plugin] plugin #0 (plugins/grpc-gateway.so): plugin.Open("plugins/grpc-gateway.so"): Error relocating /etc/krakend/plugins/grpc-gateway.so: unsupported relocation type 7 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.843 ▶ DEBUG [SERVICE: Handler Plugin] plugin #0 (plugins/grpc-gateway.so): plugin.Open("plugins/grpc-gateway.so"): Error relocating /etc/krakend/plugins/grpc-gateway.so: unsupported relocation type 7 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.843 ▶ DEBUG [SERVICE: Modifier Plugin] plugin #0 (plugins/grpc-gateway.so): plugin.Open("plugins/grpc-gateway.so"): Error relocating /etc/krakend/plugins/grpc-gateway.so: unsupported relocation type 7 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.843 ▶ DEBUG [SERVICE: Plugin Loader] Loading process completed 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.843 ▶ INFO Starting the KrakenD instance 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.843 ▶ DEBUG [ENDPOINT: /user-manager/user/create] Building the proxy pipe 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.843 ▶ DEBUG [BACKEND: /user-manager/user/create] Building the backend pipe 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.843 ▶ DEBUG [BACKEND: /user-manager/user/create] No plugins registered for the module 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.843 ▶ DEBUG [ENDPOINT: /user-manager/user/create] Building the http handler 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.843 ▶ DEBUG [ENDPOINT: /user-manager/user/create][JWTSigner] Signer disabled 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.843 ▶ INFO [ENDPOINT: /user-manager/user/create][JWTValidator] Validator disabled for this endpoint 2023-12-18 00:16:26 [KRAKEND] 2023/12/17 - 23:16:26.843 ▶ INFO [SERVICE: Gin] Listening on port: 8000 2023-12-18 00:16:31 [KRAKEND] 2023/12/17 - 23:16:31.840 ▶ DEBUG [SERVICE: Telemetry] Registering usage stats for Cluster ID 2Tg5FBe+Uw2LHg0LnQEXdMI8LJ/ccadxsFzGBL7NAxg= 2023-12-18 00:16:26 Parsing configuration file: /etc/krakend/krakend.json

This is the dockerfile that I am using:

FROM krakend/builder:2.5 as builder

WORKDIR /src ADD go.mod /go.mod ADD go.sum /go.sum COPY ./gateway/ /gateway COPY ./generated/ /generated COPY ./plugins/ /plugins RUN export CGO_ENABLED=1 RUN export CC=aarch64-linux-musl-gcc RUN export GOARCH=arm64 RUN export GOHOSTARCH=amd64 RUN export EXTRA_LDFLAGS='-extldflags=-fuse-ld=bfd -extld=aarch64-linux-musl-gcc' RUN go build -ldflags="${EXTRA_LDFLAGS}" -buildmode=plugin -o /plugins/grpc-gateway.so /plugins/grpc-gateway.go

FROM devopsfaith/krakend:2.5

COPY --from=builder /plugins/grpc-gateway.so /etc/krakend/plugins/

COPY krakend.json /etc/krakend/krakend.json

I think the issue is related to the architecture problems you mention on your site for ARM64: https://www.krakend.io/docs/extending/injecting-plugins/, but adding the flags you mentioned there doesn't seem to solve the issue.

Do you know how I can solve it? Thanks in advance :)

taik0 commented 7 months ago

Hi @Kozaky You should add the environment variables with the ENV Dockerfile directive, the RUN export will not work. Try running this manually or inside a script to check if it works for you.