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

Kaniko seg faults while building #756

Closed
cblage opened this issue Aug 28, 2019 · 2 comments
Closed

Kaniko seg faults while building #756

cblage opened this issue Aug 28, 2019 · 2 comments

Comments

@cblage
Copy link

cblage commented Aug 28, 2019

Actual behavior
Kaniko will segmentation fault while building the docker image

Expected behavior
Kaniko will build the docker image successfully

To Reproduce
Steps to reproduce the behavior:

1 - Setup build step on GCB with:

  - name: "gcr.io/kaniko-project/executor:latest"
    args:
      - --build-arg=JS_BUILD_ID=staging-$BUILD_ID
      - --dockerfile=Dockerfile.deployment
      - --destination=us.gcr.io/$PROJECT_ID/agentrisk-web:$COMMIT_SHA
      - --destination=us.gcr.io/$PROJECT_ID/agentrisk-web:latest-staging
      - --cache=true
      - --cache-ttl=720h
    id: "Build and push image"
    waitFor: ["Run tests"]

2 - Trigger build on GCB

3 - It will segfault with this:

ERROR: build step 3 "gcr.io/kaniko-project/executor:latest" failed: exit status 2
ERROR
Finished Step #3 - "Build and push image"
Step #3 - "Build and push image": 	/go/src/github.com/GoogleContainerTools/kaniko/cmd/executor/main.go:26 +0x2d
Step #3 - "Build and push image": main.main()
Step #3 - "Build and push image": 	/go/src/github.com/GoogleContainerTools/kaniko/vendor/github.com/spf13/cobra/command.go:800 +0x2b
Step #3 - "Build and push image": github.com/GoogleContainerTools/kaniko/vendor/github.com/spf13/cobra.(*Command).Execute(0x27a6660, 0xc420601f78, 0xc4200400b8)
Step #3 - "Build and push image": 	/go/src/github.com/GoogleContainerTools/kaniko/vendor/github.com/spf13/cobra/command.go:852 +0x30a
Step #3 - "Build and push image": github.com/GoogleContainerTools/kaniko/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x27a6660, 0x0, 0x1a31f54, 0x25)
Step #3 - "Build and push image": 	/go/src/github.com/GoogleContainerTools/kaniko/vendor/github.com/spf13/cobra/command.go:766 +0x2c1
Step #3 - "Build and push image": github.com/GoogleContainerTools/kaniko/vendor/github.com/spf13/cobra.(*Command).execute(0x27a6660, 0xc420038080, 0x6, 0x6, 0x27a6660, 0xc420038080)
Step #3 - "Build and push image": 	/go/src/github.com/GoogleContainerTools/kaniko/cmd/executor/cmd/root.go:87 +0x9f
Step #3 - "Build and push image": github.com/GoogleContainerTools/kaniko/cmd/executor/cmd.glob..func2(0x27a6660, 0xc4205700c0, 0x0, 0x6)
Step #3 - "Build and push image": 	/go/src/github.com/GoogleContainerTools/kaniko/pkg/executor/build.go:496 +0x369
Step #3 - "Build and push image": github.com/GoogleContainerTools/kaniko/pkg/executor.DoBuild(0x27b6860, 0x1, 0x0, 0x0, 0x1b)
Step #3 - "Build and push image": 	/go/src/github.com/GoogleContainerTools/kaniko/pkg/util/fs_util.go:122 +0x86
Step #3 - "Build and push image": github.com/GoogleContainerTools/kaniko/pkg/util.DeleteFilesystem(0xc42002c638, 0x8)
Step #3 - "Build and push image": 	/usr/local/go/src/path/filepath/path.go:403 +0x106
Step #3 - "Build and push image": path/filepath.Walk(0x19fbd96, 0x1, 0x1ab0240, 0x1bcc460, 0xc4281d8820)
Step #3 - "Build and push image": 	/usr/local/go/src/path/filepath/path.go:381 +0x2c2
Step #3 - "Build and push image": path/filepath.walk(0x19fbd96, 0x1, 0x1bcc460, 0xc42559ea90, 0x1ab0240, 0x0, 0xc42008a7d0)
Step #3 - "Build and push image": 	/usr/local/go/src/path/filepath/path.go:377 +0x20d
Step #3 - "Build and push image": path/filepath.walk(0xc42083d950, 0x4, 0x1bcc460, 0xc42506d040, 0x1ab0240, 0x0, 0xc4200721d0)
Step #3 - "Build and push image": 	/go/src/github.com/GoogleContainerTools/kaniko/pkg/util/fs_util.go:124 +0x51
Step #3 - "Build and push image": github.com/GoogleContainerTools/kaniko/pkg/util.DeleteFilesystem.func1(0xc420517f40, 0x17, 0x0, 0x0, 0x1b9f220, 0xc421be9050, 0x0, 0x0)
Step #3 - "Build and push image": goroutine 1 [running]:
Step #3 - "Build and push image": 
Step #3 - "Build and push image": [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x11223e1]
Step #3 - "Build and push image": panic: runtime error: invalid memory address or nil pointer dereference
Step #3 - "Build and push image": INFO[1056] Deleting filesystem...                       
Step #3 - "Build and push image": INFO[1056] Saving file /export/ for later use.          
Step #3 - "Build and push image": INFO[1050] Pushing layer us.gcr.io/agentriskweb/agentrisk-web/cache:8cfce22644da3467c93b1234d08cfda2999e7df9067a332e957832eef20da0c1 to cache now 
Step #3 - "Build and push image": INFO[0954] Taking snapshot of full filesystem...        
Step #3 - "Build and push image": INFO[0950] Pushing layer us.gcr.io/agentriskweb/agentrisk-web/cache:6d6876cd65cbcec772366413901bd61bb6213dde1e77681bb24302eb74d702dc to cache now 

Additional Information

Dockerfile:

FROM us.gcr.io/agentriskweb/agentrisk-elixir-builder:latest as builder

ARG APP_NAME=agentrisk
ARG PHOENIX_SUBDIR=.

# Set up build environment.
ENV MIX_ENV=prod \
    REPLACE_OS_VARS=true \
    TERM=xterm

# Set tmp dir and optionally volume it for backing by ramdrive mount
ENV TMPDIR /tmp
VOLUME /tmp

# Set the build directory.
WORKDIR /opt/app

# ez cache ez build
COPY mix.exs mix.exs
COPY mix.lock mix.lock
COPY config config/
COPY rel rel/

# Build the application deps
RUN mix do deps.get, deps.compile

# Build Elixir app
COPY lib lib/
COPY priv priv/

# Build the application.
RUN mix do clean, compile

# Copy over assets
COPY assets/.sentryclirc assets/.sentryclirc
COPY assets/.babelrc assets/.babelrc
COPY assets/package.json assets/package.json
COPY assets/yarn.lock assets/yarn.lock
COPY assets/postcss.config.js assets/postcss.config.js
COPY assets/webpack.config.js assets/webpack.config.js
COPY assets/js assets/js
COPY assets/scss assets/scss
COPY assets/static assets/static

ARG JS_BUILD_ID="production-build"

ENV HEROKU_SLUG_COMMIT=${JS_BUILD_ID}

# Build assets by running a Brunch build and Phoenix digest.
# If you are using a different mechanism for asset builds, you may need to
# alter these commands.
RUN cd ${PHOENIX_SUBDIR}/assets \
    && yarn install \
    && yarn run deploy \
    && cd .. \
    && mix phx.digest

# Create the release, and move the artifacts to well-known paths so the
# runtime image doesn't need to know the app name. Specifically, the binary
# is renamed to "start_server", and the entire release is moved into
# /opt/release.
RUN mix distillery.release --env=prod --verbose


#Extract Release archive to /export for copying in next stage
RUN RELEASE_DIR=`ls -d ./_build/$MIX_ENV/rel/$APP_NAME/releases/*/` && \
    mkdir /export && \
    tar -xf "$RELEASE_DIR/$APP_NAME.tar.gz" -C /export

########
## Actual Docker image that's gonna run inside docker:
########
FROM us.gcr.io/agentriskweb/agentrisk-elixir-base:latest

ARG APP_NAME=agentrisk
# Set up environment.
ENV MIX_ENV=prod \
    REPLACE_OS_VARS=true \
    TERM=xterm

ENV TMPDIR /tmp
VOLUME /tmp

## Copy build from builder image
RUN rm -rf /opt/release
RUN mkdir -p /opt/release

WORKDIR /opt/release
COPY --from=builder /export/ .

RUN mv /opt/release/bin/${APP_NAME} /opt/release/bin/start_server

ENV PORT=8080 \
    REPLACE_OS_VARS=true

# Cleanup
RUN rm -rf /var/cache/apt/* &&  \
    rm -rf /tmp/* &&  \
    rm -rf /var/log

# Start the server.
EXPOSE ${PORT}
CMD ["/opt/release/bin/start_server", "foreground"]
@cblage
Copy link
Author

cblage commented Aug 28, 2019

More context:

Step #3 - "Build and push image": [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x11223e1]
Step #3 - "Build and push image": panic: runtime error: invalid memory address or nil pointer dereference
Step #3 - "Build and push image": INFO[1074] Deleting filesystem...                       
Step #3 - "Build and push image": INFO[1074] Saving file /export/ for later use.          
Step #3 - "Build and push image": INFO[1067] Pushing layer us.gcr.io/agentriskweb/agentrisk-web/cache:25030579946235437a5159e42393f0e3663ac6a02030040904d2853705f666f4 to cache now 
Step #3 - "Build and push image": INFO[0980] Taking snapshot of full filesystem...        
Step #3 - "Build and push image": INFO[0976] Pushing layer us.gcr.io/agentriskweb/agentrisk-web/cache:00ae9dd8624cd486b310d203a6ce727b7015385e06b20c274ab3076de6dc499d to cache now 
Step #3 - "Build and push image": INFO[0976] args: [-c RELEASE_DIR=`ls -d ./_build/$MIX_ENV/rel/$APP_NAME/releases/*/` &&     mkdir /export &&     tar -xf "$RELEASE_DIR/$APP_NAME.tar.gz" -C /export] 
Step #3 - "Build and push image": INFO[0976] cmd: /bin/sh                                 
Step #3 - "Build and push image": INFO[0976] RUN RELEASE_DIR=`ls -d ./_build/$MIX_ENV/rel/$APP_NAME/releases/*/` &&     mkdir /export &&     tar -xf "$RELEASE_DIR/$APP_NAME.tar.gz" -C /export 
Step #3 - "Build and push image": INFO[0839] Taking snapshot of full filesystem...        
Step #3 - "Build and push image":     > _build/prod/rel/agentrisk/bin/agentrisk hel

@roquie
Copy link

roquie commented Sep 9, 2019

The same problem. +1 Example Dockerfile to reproduce it:
https://github.com/Sylius/Sylius-Standard/blob/master/Dockerfile

Screenshot 2019-09-09 at 23 03 22

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