-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[supervisor] support shutdown task #11287
Conversation
@svenefftinge: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
started the job as gitpod-build-sefftinge-allow-end-tasks-which-3966.1 because the annotations in the pull request description changed |
4d5ccc4
to
097d76f
Compare
Had a discussion with @svenefftinge about this:
Example # give the workspace enough time to finish the shutdown tasks
terminationGracePeriodSeconds: 300
tasks:
# Note that the shutdown command is NOT part of the same task so that the database
# keeps running until the `foobardb flush` command has been executed.
- command: foobardb --datadir /workspace/data/db
- shutdown: foobardb flush
# Say you wanted to carry an image across multiple workspaces, using the shutdown command
# you could push that image to a registry prior before the workspace shuts down
- before: echo "$DOCKER_PWD" | docker login -u $DOCKER_USER --password-stdin myreg.company.dev
init: docker pull myreg.company.dev/devstate/$GITPOD_OWNER_ID/server:latest
command: docker run -it --name server -v /workspace/data/server:/data myreg.company.dev/devstate/$GITPOD_OWNER_ID/server:latest
shutdown: docker container commit server myreg.company.dev/devstate/$GITPOD_OWNER_ID/server:latest && docker push myreg.company.dev/devstate/$GITPOD_OWNER_ID/server:latest |
/werft run 👍 started the job as gitpod-build-sefftinge-allow-end-tasks-which-3966.9 |
/werft run 👍 started the job as gitpod-build-sefftinge-allow-end-tasks-which-3966.10 |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Is this PR still alive? |
Yes, we got to prioritize some other topics for the time being but will pick this up soon again. Could you outline what you plan to use this for? |
We have folks that are affected by #11183 which currently seems to be caused by not running This same set of folks would also use shutdown to push images to Docker registries and persist data to object store on workspace shutdown. They'd do the opposite on workspace startup load data from object store and pull images. |
097d76f
to
801840b
Compare
Hey @svenefftinge |
@sagor999 there is real analysis of the underlying problem in #11183 can you elaborate a bit on how you hope this PR will fix those issues? Is the underlying problem that docker doesn't terminate gracefully on workspace stop and increasing the time would help? |
Yeah, it seems that way indeed. |
update: depends on #13495 |
@csweichel Just to understand how I can get proper docker-compose running in the background similar how people are doing it with systemd for instance [1]. I would do following? tasks:
- init: docker-compose pull --quiet --parallel
command: |
docker-compose up &
exit
shutdown: docker-compose down With this solution though task terminal still can pop up in VS Code while pulling for instance in a workspace without the prebuild. I wish we would have something like background property for tasks that it does not create pty service but only shell, for example: tasks:
- init: docker-compose pull --quiet --parallel
command: docker-compose up
shutdown: docker-compose down
background: true
👍
I'm not sure about the order consider another use case with docker-compose with terminal: tasks:
- init: docker-compose pull --quiet --parallel
command: docker-compose up
shutdown: docker-compose down Sending SIGTERM to
I'm not sure what is reasoning, i.e. shutdown of one task can affect execution of another task? Should not we rather design that it should be local to the task itself?
👍 |
In that case people would need to start the shutdown in a separate terminal:
|
Is not it make it complex for a user there will be 2 different semantics depending whether shutdown is present or not? I wonder what use case won't be covered by all tasks are closed in parallel, shutdown is executed before SIGTERM? There is also |
Yes, makes sense. So you suggest to go back to the design where we don't have a shutdown lifecycle on terminals but one global one. I.e. what I propose here? |
I think it makes sense to have shutdown per a task, i.e. to reload docker-compose configuration. Having it under another task or globally won't allow it. I meant that the contract can be different:
We have |
I think instead of introducing a hard-coded concept of a lifecycle for which the contract are not really clear (i.e. |
This requires developers to be very experienced. Many developers do not live on the command line, do not use shell job management, don't know about the various signals, or how to trap them. I couldn't make this work, @axonasif had to give me a snippet to make it work. Many developers find Dockerfile challenging enough. Most folks do not have to manage this today. They've got full VMs with real inits and systemd doing clean up. Having to manage this is something for us and our abstraction. The original thoughts around Its easy to drill into the specifics of the particular docker compose example but that wasn't the original signal this came from. |
I quite dislike that we even have a notion of "stop" and "start". I wish that "stop" was hibernete and "restart" was resume. I wish that we could snapshot the current state versus go through a full lifecycle of starting and stopping a container. Though we use containers it feels like a leaky abstraction. There are things I would like to be able to do as a developer to distinguish between shutdown and workspace deletion. (but like I mentioned, I don't like that we have start/stop in the first place) For instance, for a project, for each workspace I create, I want to provision an SQS queue. And when the workspace is deleted I want to deprovision the SQS queue. When the workspace is running I want to be polling the queue. I can see following the same lifecycle with a cloud based database as well. Provision a new database or keyspace, load with seed data and clean up when the workspace is deleted. Every "ephemeral" workspace gets it's own ephemeral cloud resources. |
I would like to have an option within
This could work too 👍
I assume this is close to what I'm asking. |
That's why I suggested building or using a convenient CLI. |
fixes #3966
Description
Related Issue(s)
Fixes #
How to test
Release Notes
Documentation
Werft options: