just-containers / s6-overlay

s6 overlay for containers (includes execline, s6-linux-utils & a custom init)
Other
3.73k stars 212 forks source link

`S6_CMD_WAIT_FOR_SERVICES=1` makes no diference #546

Closed felipecrs closed 11 months ago

felipecrs commented 1 year ago

I pushed a reproduction repo: https://github.com/felipecrs/test-s6-overlay

$ git clone https://github.com/felipecrs/test-s6-overlay
$ cd test-s6-overlay
$ docker build . -t test
$ docker run --rm test true
  1. s6-overlay doesn't wait for myservice to be ready before executing CMD
  2. executes CMD even if myservice never gets ready
  3. exits with a 0 code (probably because CMD got executed)

Is my expectation wrong?

felipecrs commented 1 year ago

I edited the issue with more clear reproduction steps.

skarnet commented 1 year ago

Does it wait for 5 seconds before executing your CMD? If so, that's expected: that's the default maximum waiting time. If you want s6-overlay to wait forever until your /etc/services.d services are ready, you should also set the S6_CMD_WAIT_FOR_SERVICES_MAXTIME variable to 0.

felipecrs commented 1 year ago

No, it doesn't wait 5 seconds neither S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 makes any difference:

https://github.com/just-containers/s6-overlay/assets/29582865/b3610e84-4c5d-4f53-97d6-7e5733066896

skarnet commented 1 year ago

Indeed it was a bug, thanks for the report! It should be fixed now in the latest git head.

New compiled versions will come out as soon as possible, probably some time in September.

felipecrs commented 1 year ago

Awesome, thanks a lot.

felipecrs commented 1 year ago

Another thing, after exceeding the S6_CMD_WAIT_FOR_SERVICES_MAXTIME, will CMD still be executed as you mentioned above?

I wonder if the most desired behavior would not be to exit early the container with a non zero status code.

skarnet commented 1 year ago

You can already customize that via S6_BEHAVIOUR_IF_STAGE2_FAILS.

felipecrs commented 1 year ago

Oh, that's perfect then.

PS: documentation only mentions that S6_BEHAVIOUR_IF_STAGE2_FAILS is valid for cont-init and fix-attrs, but not for services.d readiness.

skarnet commented 1 year ago

Documentation updated, thanks.

felipecrs commented 1 year ago

Amazing! It's extremely clear now.

felipecrs commented 1 year ago

New compiled versions will come out as soon as possible, probably some time in September.

@skarnet, I don't want to be inconvenient, but is this something you are still planning?

skarnet commented 1 year ago

Yes. I'm behind on schedule (when am I not?) but working to make the release as fast as possible without sacrificing quality.

(The reason for the delay is that the new skarnet.org release includes a web server, which is a significant piece of software; it's now in beta and being debugged and polished to make it ready for release. And in the process there was an important amount of changes done to the skarnet.org stack, so getting everything in a row takes time.)

Sorry for the delays.

(Edit: typo)

felipecrs commented 1 year ago

Got it. Makes sense. Thanks for the detailed response.

skarnet commented 11 months ago

The new release is finally out! Please test and report if it fixes (or does not fix) the issue.

felipecrs commented 11 months ago

All seems to be working fine now. Thanks a lot!