-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Better support regular container restarts #3929
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
Better support regular container restarts #3929
Conversation
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Earlier suggestion for simplifying the conditional branch. Suggestion is slightly awkward due to web UI functionality 😅
Thanks, but I already got what you proposed 👍 I just had no time yesterday answering you. The reason I did it my way is: Depending on the log level defined in After your comment, I read the source again and noticed, that for that situation there is already a safe-guard not to try to modify the configuration (and reloading supervisor), when not needed. But I think the intention for that in the first place was not in regard of a container restart. Even with that safe-guard in place, there is no need to call that function on container restarts. Regarding I hope you understand what I tried to say. Summery: I did it that way, with a view to effectiveness (avoiding double functions calls on some circumstances) --> saving some CPU cycles 😆 |
Ideally it shouldn't be a problem for container restarts since ENV doesn't change.
This is the actual problem, and is due to: Lines 316 to 317 in 2133b51
docker-mailserver/target/supervisor/conf.d/dms-services.conf Lines 7 to 16 in 2133b51
docker-mailserver/target/scripts/start-mailserver.sh Lines 190 to 191 in 2133b51
What is the technical reason for needing to run the startup script as a separate service? If we didn't then this early supervisord support wouldn't be necessary and the script would not need to restart it and exit itself to re-run? docker-mailserver/target/scripts/startup/setup-stack.sh Lines 47 to 48 in 2133b51
Yes thanks, I hadn't considered it. Although it should be fine for our default EDIT: My bad So while this would be preferable: _early_supervisor_setup
_early_variables_setup
_register_functions
_log 'info' "Welcome to docker-mailserver ${DMS_RELEASE}"
# Ensure DMS only adjusts config files for a new container.
# Container restarts should skip as they retain the modified config.
if [[ ! -f /CONTAINER_START ]]; then
_check
_setup
_run_user_patches
# Only displayed on fresh containers (better for bug reports)
[[ ${LOG_LEVEL} =~ (debug|trace) ]] && print-environment
else
_log 'info' 'Container was restarted. Skipping setup routines..'
fi
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small nitpicks. Otherwise, LGMT 👍🏼 Why doesn't this PR ship the corresponding documentation updates?
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
Oops, my suggestion contained an additional space - praise be linters 😝 |
Just in short: There may be other ways to do things as you noted - absolutely. And I don't say, that these are bad or anything. Those ways may have new issues/problems. The current solution is approved and solid for a long time. # Only displayed on fresh containers (better for bug reports)
[[ ${LOG_LEVEL} =~ (debug|trace) ]] && print-environment I don't care about this one and can change that, but I am wondering what your reasoning for that is. If someone enables debugging, why should we omit debug information on container restarts? There are solutions/logging drivers where the log size is limited and you can't scroll back to the very beginning and only get the last X lines. |
If they enable the ENV it'll do a fresh start AFAIK. Unless there's other surprising cases like how compose will keep a Sure there might be a legitimate need for it with a container restart, I just figured we'd prefer bug reports for fresh containers only and this would be more evident in their log output without us having to do extra back and forth? If there is a legit bug that is reproduced only with a container restart, they could manually get the equivalent output since we write it to a file anyway?
In that sense, this output is even less helpful? Personally I'd rather we had this limited to Often when ENV matters, the user doesn't provide such log output, and we're just given a |
LGTM 👍🏼 Still, why isn't this PR adjusting our docs? |
? If you change ENVs and want to take them place, you'll have to recreate the container. "start/stop" does not take changed variables into account.
I haven't thought about this at all 👍 For me, enabling debugging is not mutual exclusive to opening an issue. Enabling any feature, I would not expect, that some functions are only run on first container start. That's why I find it in this case inconsistent, when printing the ENVs, would only take place on the first container start.
That's unfortunately nothing we can fix scripting wise 😆
I haven't checked it, but I guess that there are many places that need to be adjusted. I simply have no time for that right now. We can leave this PR open if you or @polarathene want to do the docu stuff. On the other hand, starting with a fresh container is still a good advice. That "wrong" information does not hurt in any way. We could wait some time to see, how well this PR ages and adjust the docs, when we are 100% confident, that container restarts are fully supported and there are no more issues with that. |
But that's exactly what this PR does, conditionally run startup logic based on if this is a new container instance or not?
This is related to troubleshooting right? That's the main purpose of that output, yet by skipping the output from running initial container setup, you're lacking any helpful insights that come from that which can emit warnings/errors. It's better to encourage a fresh container instance for this and by ensuring the ENV print method is also only run for that it will be communicated much better to us with bug reports, and for the user who's more likely to see the skipped log message this PR adds when there is less noise being output?
Disagree, we know what are default ENV values are, we could absolutely output only non-defaults, either at startup via log or a
That was kind of my point. With With Docker Compose, IIRC adjusting ENV via So if a user explicitly changes ENV for a container, they'll need a fresh container instance regardless. Not sure what value we're providing to the user by keeping ENV printing at container startup for restarts/resumes?
I've not chimed in on the docs as I don't know what docs are being referred to that need updating. There's two pages (usage and debugging) with the Does this PR completely address the internal state issue?
👍 I don't see issue with leaving doc as-is for now either. Rather have that there for now and we can remove it later if it doesn't provide value. I think it's still good advice for the debugging page. |
Let's stop the discussion at this point about printing the ENVs on startup if that's fine for you. I see you have valid points - me too. I was about to reply to your points and noticed it was getting quiet lengthy again. Surely you would reply again to my answers. I think it's not worth to invest that much time for 1 LOC. If you or Georg demand a change, I can do it or you can change it directly 👍
I hope so, but I wouldn't bet any money on this 😆 |
Agreed, let's not make a lengthy discussion out of it 🚀 I am fine with not updating the docs for now, but only if it does not become the default behavior. We also need to update the docs when we are confident that all is well with this feature. |
Description
Described here.
Not covered by this PR:
Fixes #3886
Type of change
Checklist
docs/
)CHANGELOG.md