Skip to content

remove one-shot entrypoint/switch default entrypoint to spack-env#17429

Closed
opadron wants to merge 1 commit intospack:developfrom
opadron:docker-image-entrypoint-simplify
Closed

remove one-shot entrypoint/switch default entrypoint to spack-env#17429
opadron wants to merge 1 commit intospack:developfrom
opadron:docker-image-entrypoint-simplify

Conversation

@opadron
Copy link
Copy Markdown
Member

@opadron opadron commented Jul 8, 2020

(Further) simplifies the ENTRYPOINT for the docker images. This change removes the one-shot default entrypoint and replaces it with the spack-env entrypoint. Combined with the interactive-shell default CMD, these changes yield the following behavior:

  • Before these changes: when running the image with no ENTRYPOINT or CMD override, an interactive shell session was created. This session had spack loaded and ready for immediate use. This behavior is preserved by the changes.

  • Before these changes: when running the image with a CMD override, the CMD was taken as a set of arguments to spack, itself (i.e.: spack '...'). These changes remove this behavior. Instead, the CMD is ran as in /usr/bin/env sh -c '...', except that the passed commands can use Spack without the need to source its loading script. Existing uses of the prior behavior can accomplish the same by just adding spack to the beginning of the CMD:

 $ docker run --rm ... spack/ubuntu-bionic spec hdf5  # before
 $ docker run --rm ... spack/ubuntu-bionic spack spec hdf5  # after
  • The docker-shell variant continues to work as before. RUN commands in a Dockerfile that use our image as a base can still run spack commands without needing to source spack's loading script.

Without these changes, spack ci users would need to explicitly override the ENTRYPOINT of jobs that run using our images. This requirement precluded use in environments where entrypoint overrides were disabled, or ignored, such as with the Kubernetes executor (see this issue). With these changes, the ENTRYPOINT now works, by default, in a manner compatible with all Gitlab CI use cases.

@haampie
Copy link
Copy Markdown
Member

haampie commented Jul 8, 2020

This does not seem to solve the problem :(.

In kubernetes with gitlab ci I'm still getting:

$ spack env activate .
/bin/bash: line 95: spack: command not found

@opadron
Copy link
Copy Markdown
Member Author

opadron commented Jul 8, 2020

Are you using a imagePullPolicy of Always?
https://docs.gitlab.com/runner/executors/kubernetes.html

More to the point: new versions of the Spack docker images won't be built until this is merged. You'll need to build a locally-tagged version of the image yourself and test with that version until then.

@haampie
Copy link
Copy Markdown
Member

haampie commented Jul 8, 2020

Yes, I've been using a specific digest, so I'm quite confident the image is correct.

Currently I think the issue is upstream with gitlab confusing command / entrypoint in kubernetes terms (kubernetes/kubernetes#8235)

@opadron
Copy link
Copy Markdown
Member Author

opadron commented Aug 3, 2020

@haampie Just wanted to chime in and post an update on this:

I suspect that there may be some differences between how Gitlab CI runs images in docker executors and how it does it in kubernetes executors. I recall that while preparing the docker images, we tested locally on docker executors and I never recall having any problems (neither before nor after the changes proposed in this PR), but we never actually tried on a kubernetes executor. Would you have a chance to try an experiment and let me know what you find?

If so, try running Gitlab runners using the docker and kubernetes executors, and try running a simple job that uses spack, something like

...

.test:
  image: <your-local-docker-image-build>
  script: ["spack -d spec hdf5"]  # or something similar

docker-test:
  extends: .test
  tags: [...]  # target your docker executor here

k8s-test:
  extends: .test
  tags: [...]  # target your kubernetes executor here

...

My hypothesis is that the docker test will work but the kubernetes one will fail because it can't find spack. In any case, your findings would help shine some light on the issue.

@alalazo
Copy link
Copy Markdown
Member

alalazo commented Feb 11, 2022

Is this PR still WIP or can we close it?

@alalazo
Copy link
Copy Markdown
Member

alalazo commented May 5, 2022

Closing, since there has been no activity in a while. Feel free to reopen if you want to continue work on this.

@alalazo alalazo closed this May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants