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 __res_init: symbol not found in alpine based images #3725

Closed
jralmaraz opened this issue Aug 10, 2021 · 3 comments
Closed

Error __res_init: symbol not found in alpine based images #3725

jralmaraz opened this issue Aug 10, 2021 · 3 comments

Comments

@jralmaraz
Copy link

jralmaraz commented Aug 10, 2021

Expected Behavior

Download binary in alpine linux and run.

Actual Behavior

Currently latest binaries fail with: __res_init: symbol not found

Steps to Reproduce the Problem

When running the latest 0.31.0 binary on Alpine 3.13.5 (Linux a7d0b91913d1 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 x86_64 GNU/Linux) we notice the following error:

a7d0b91913d1:/working$ /usr/local/bin/opa-test version
Error relocating /usr/local/bin/opa-test: __res_init: symbol not found

I was suspecting that an O.S package was missing, checked if gcompat libc6-compat were installed and the error remained.

Tried building from source and it worked fine, so, I wonder if there's any dependency issue with the binary that we should be aware of ?

go build -ldflags '-X github.com/open-policy-agent/opa/version.Version=v0.31.0' -o bin/opa-current
a7d0b91913d1:/working$ opa-current version
Version: v0.31.0
Build Commit: 
Build Timestamp: 
Build Hostname: 
Go Version: go1.15.12
WebAssembly: unavailable

Main reason that we're opening this is that we noticed that it used to work fine with version 0.27.1, so we wonder what other kind of dependency we need to address as we currently embed opa in a developer toolbox docker image.


a7d0b91913d1:/working$ sudo curl --location https://artifactory.gcp.anz/artifactory/github/open-policy-agent/opa/releases/download/v0.30.0/opa_linux_amd64 --output /usr/local/bin/opa-test2 && sudo chmod +x /usr/local/bin/opa-test2
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 47.7M  100 47.7M    0     0  5726k      0  0:00:08  0:00:08 --:--:-- 6943k
a7d0b91913d1:/working$ /usr/local/bin/opa-test2 version
Error relocating /usr/local/bin/opa-test2: __res_init: symbol not found

a7d0b91913d1:/working$ sudo curl --location https://artifactory.gcp.anz/artifactory/github/open-policy-agent/opa/releases/download/v0.29.4/opa_linux_amd64 --output /usr/local/bin/opa-test3 && sudo chmod +x /usr/local/bin/opa-test3
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 49.4M  100 49.4M    0     0  5482k      0  0:00:09  0:00:09 --:--:-- 6934k
a7d0b91913d1:/working$ /usr/local/bin/opa-test3 version
Error relocating /usr/local/bin/opa-test3: __res_init: symbol not found

a7d0b91913d1:/working$ sudo curl --location https://artifactory.gcp.anz/artifactory/github/open-policy-agent/opa/releases/download/v0.27.1/opa_linux_amd64 --output /usr/local/bin/opa-test4 && sudo chmod +x /usr/local/bin/opa-test4
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 23.1M  100 23.1M    0     0  2630k      0  0:00:09  0:00:09 --:--:-- 3832k
a7d0b91913d1:/working$ /usr/local/bin/opa-test4 version 
Version: 0.27.1
Build Commit: e514c03
Build Timestamp: 2021-03-12T14:53:58Z
Build Hostname: 8a9274d57604
Go Version: go1.15.8
WebAssembly: unavailable

Thanks a lot!

@srenatus
Copy link
Contributor

Thanks for the detailed issue.

For scenarios where there is no glibc around, the "static" variant of the binary introduced in 0.29.x should work, opa_linux_amd64_static. But that's first a first thought, I'll have a closer look at this.

@srenatus
Copy link
Contributor

Expected Behavior

Download binary in alpine linux and run.

Just verified that we can meet that expectation with the opa_linux_amd64_static binary:

$ curl -vLO https://github.com/open-policy-agent/opa/releases/download/v0.31.0/opa_linux_amd64_static
$ chmod +x opa_linux_amd64_static
$ docker run -v $(pwd):/s -it alpine:3 sh
/ # cd /s
/s # ./opa_linux_amd64_static version
Version: 0.31.0
Build Commit: e88ad16
Build Timestamp: 2021-07-28T07:40:01Z
Build Hostname: bbd37e4df7a1
Go Version: go1.16.5
WebAssembly: unavailable
/s #

We've been publishing static binaries for the alpine use case (among others) with v0.29.4.

The build instructions used for that binary should do the trick for you, too. Could you try?

@jralmaraz
Copy link
Author

Awesome. Thanks @srenatus for looking at this and for providing the detailed explanation, I have tried using the static version and it works perfectly fine. Cheers!

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

No branches or pull requests

3 participants