Skip to content

Skylight Platform Util does not always detect Alpine Linux/musl #92

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

Closed
ryansch opened this issue Feb 16, 2017 · 21 comments
Closed

Skylight Platform Util does not always detect Alpine Linux/musl #92

ryansch opened this issue Feb 16, 2017 · 21 comments

Comments

@ryansch
Copy link

ryansch commented Feb 16, 2017

RbConfig::CONFIG['host_os'] seems to reflect the host OS in use when ruby was compiled. If an alpine linux container is being built on an alpine host then we get linux-musl but if an alpine linux container is being built on a libc host then we get either linux or linux-gnu.

This means that the official ruby:2.3.3-alpine container will report linux-gnu back and install the wrong version of libskylight. Here's a copy of my install.log from inside of a ruby:2.3.3-alpine container:

I, [2017-02-16T16:56:53.004002 #13693]  INFO -- : SKYLIGHT_HDR_PATH=/usr/local/bundle/gems/skylight-1.0.1/ext; SKYLIGHT_LIB_PATH=/usr/local/bundle/gems/skylight-1.0.1/lib/skylight/native/x86_64-linux
I, [2017-02-16T16:56:53.004332 #13693]  INFO -- : [SKYLIGHT] fetching native ext; curr-platform=x86_64-linux; requested-arch=x86_64-linux; version=1.0.1-fcb0e55
I, [2017-02-16T16:56:53.004660 #13693]  INFO -- : [SKYLIGHT] attempting to fetch from remote; uri=https://s3.amazonaws.com/skylight-agent-packages/skylight-native/1.0.1-fcb0e55/skylight_x86_64-linux.tar.gz
I, [2017-02-16T16:56:54.649761 #13693]  INFO -- : [SKYLIGHT] successfully downloaded native ext; out=/usr/local/bundle/gems/skylight-1.0.1/ext/skylight_x86_64-linux.tar.gz

This appears to be the root cause behind #59 and #91.

A more reliable way to detect alpine might be to inspect the contents of /etc/os-release or /etc/alpine-release.

@wagenet
Copy link
Contributor

wagenet commented Feb 16, 2017

Huh, that's quite odd and seems like a bug in Ruby. However, unless we want to wait for a fix there I guess we'll have to work around it.

@wagenet
Copy link
Contributor

wagenet commented Feb 16, 2017

@ryansch have you verified that it works if we use the musl version instead?

@ryansch
Copy link
Author

ryansch commented Feb 16, 2017

@wagenet I'll fork and do that now.

@wagenet
Copy link
Contributor

wagenet commented Feb 16, 2017

@ryansch thanks!

@wagenet
Copy link
Contributor

wagenet commented Feb 16, 2017

FWIW, it seems very odd to me that they're building Ruby against libc when it will be used on a platform without it. I'm not sure how this isn't causing lots of problems elsewhere!

@ryansch
Copy link
Author

ryansch commented Feb 16, 2017

@wagenet Ruby is being built against musl here but the value of host_os only seems to contain musl when alpine is the actual host os (not to be confused with container os).

@wagenet
Copy link
Contributor

wagenet commented Feb 16, 2017

@ryansch hmm... I could have sworn I got this to work when Linux was the host! Definitely something weird going on, but Docker isn't my strong suit :/

@ryansch
Copy link
Author

ryansch commented Feb 16, 2017

@wagenet I can confirm that rails does start now with the musl version of libskylight installed.

Hack: master...outstand:hardcode-musl

@wagenet
Copy link
Contributor

wagenet commented Feb 16, 2017

@ryansch thanks for checking this! I'll try to get a proper fix in place soon.

@ryansch
Copy link
Author

ryansch commented Feb 16, 2017

@wagenet Do you need a small container to test with?

@wagenet
Copy link
Contributor

wagenet commented Feb 16, 2017

Looks like RbConfig::CONFIG['arch'] should be safer. Verifying the value on other platforms.

@ryansch
Copy link
Author

ryansch commented Feb 16, 2017

@wagenet Doesn't look reliable here.

screen shot 2017-02-16 at 11 27 27 am

Edit: I don't see the string 'musl' anywhere inside of RbConfig::CONFIG.

@ryansch
Copy link
Author

ryansch commented Feb 16, 2017

@wagenet Have a look at the output of ldd --version.

ruby:2.3.3-alpine
screen shot 2017-02-16 at 11 31 33 am

ruby:2.3.3
screen shot 2017-02-16 at 11 33 11 am

@wagenet
Copy link
Contributor

wagenet commented Feb 16, 2017

Ah, I was building Ruby as part of the RUN in my Dockerfile. Looks like on the official Ruby Alpine images there is no mention of musl in all of RbConfig 😞 .

@ryansch
Copy link
Author

ryansch commented Feb 16, 2017

Exactly. Comparing the Dockerfile vs the APKBUILD didn't show anything obvious.

@wagenet
Copy link
Contributor

wagenet commented Feb 16, 2017

I'm thinking of doing this:

      OS = case os = RbConfig::CONFIG['host_os'].downcase
      when /linux/
        if ENV['SKYLIGHT_MUSL'] || `ldd --version 2>&1` =~ /musl/
          "linux-musl"
        else
          "linux"
        end

@wagenet
Copy link
Contributor

wagenet commented Feb 16, 2017

I don't love it, but I'm not sure of a better way to handle this.

@ryansch
Copy link
Author

ryansch commented Feb 16, 2017

@wagenet I think that's the best solution right now.

@wagenet
Copy link
Contributor

wagenet commented Feb 16, 2017

Should be fixed in 138bb9a

@wagenet wagenet closed this as completed Feb 16, 2017
@wagenet
Copy link
Contributor

wagenet commented Feb 16, 2017

@ryansch thanks again for your help here!

@ryansch
Copy link
Author

ryansch commented Feb 16, 2017

@wagenet And thanks for yours!

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

No branches or pull requests

2 participants