Add dependencies and restart policy to s6 services #1802
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is aligned with the issue #1784
Those changes help apko to achieve a similar behavior as in s6-overlay with service-bundles, by adding dependencies between services and restart policies.
This will mimic an
init-containereven in serverless environments like GCP Cloud Run, which is not that straighforward currently. Furthermore, given thatdepends_onfield (see the YAML below) is an array, we could potentially have a services dependency tree just with one container image.The idea would be to have a YAML manifest with an
entrypointsection similar to this:As a result of the above configuration, we can achieve the following:
restartfield, which means that we can force s6 to not restart service2 once correctly finisheda. If we used
restart: no, we would be telling to s6 that we do not care about the exit code of service2, thus service2 will never restart after the first executionThis change hash some extra benefits compared to s6-overlay. We remove the dependency with
sh, which is still needed to properly initialize s6-overlay. Thus there is no need to add a shell or packages like busybox, which as a result provides a cleaner and more secure minimal container. All dependency and restart features are managed by strictly using the s6-supervision-suite and other tools coming by default with apko.In addition, restart field aims to be compliant with the docker way restart policies. We could even have include restart policies like
on-failure[:max-retries]orunless-stopped, but I wanted to keep the first PR simple.Note that I also included a type change in the
ImageEntrypointstruct. The aim behind this change is to keep the code backwards-compatible. Thus if you accept this proposal, current users can still use their manifests in the old-way.I hope the main idea is clear enough. We can discuss about specific details of the code, if you do not feel 100% comfortable with this solution.