-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Quadlet .image file should wait for dns name resolution #21873
Comments
@alexlarsson Do we need to force? Wants=network-online.target |
network-online.target do not guarantee DNS resolution, only that interfaces are up and have an IP address. For name resolution the target should be nss-lookup.target |
Seems reasonable to me, I am not sure how quadlets setup those types of requirements right now. |
yeah, I should have included that in the initial issue :
Note that I have not tried with podman 5 |
If you add to your image quadlet
Does this fix your issue? |
@rhatdan just did some further testing : Adding just this solves the issue in my case
I got used to put the Ordering after |
I guess the question is should we do this automatically or just document it? |
I don't think it is for Quadlet to decide the dependencies of the unit files. Users should treat Quadlet files the same as they do any other systemd service file, just with an additional section (each file type with its own special section). What if DNS resolution is not required? |
SGTM |
I think units should run out-of-the-box without further massaging by users, especially when all units needed editing to just run.
Quadlet only adds |
the |
Good point! Yet, |
@vrothberg I understand your point. However, if you recall, Quadlet started out very opinionated and we have since removed most (if not all) of its opinions. I'd hate to add this functionality just to have to add a nob that overrides it later. |
The opinions usually changed backed by data. Here we have a data point that can help refine earlier decisions.
Do you have a use case in mind where a container would need to run before the network is online? If there are valid concerns of breaking important use cases, I am OK with documenting. At the moment, I cannot find one and fear of more users running into the problem. |
Famous last words:
:) If you think it's OK, I don't mind adding it. |
Let's call in @rhatdan :^) |
Well depends there could be early boot stuff running in container that shouldn't wait for the network. Also you do no really need to implement an option to overwrite it, in systemd syntax something like this should work
This would unset all previously set After's, so as long as quadlet adds the user provided dependencies after the default ones by quadlet users will have the option to unset the network dependency if they do not want it. |
I would like to go with the least surprise here. Especially after @Luap99 found a I like the idea of doing After network. And then adding docs about it, and the |
SGTM 👍 |
I'll cook up a PR with the changes. Can someone assign the issue to me and put the corresponding label ? |
just noting here that for user units (i.e. not system units) depending on I think in the very least we should make sure we don't generate user units that have this setting set if it doesn't work (could lead to confusion). We can mention the upstream RFE and say we should enable it if the RFE ever gets implemented maybe? |
If a container unit starts on boot with a dependency on `default.target` the image unit may start too soon, before network is ready. This cause the unit to fail to pull the image. - Add a dependency on `network-online.target` to make sure image pulls don't fail. See containers#21873 - Document the hardcoded dependency on `network-online.target` for images unit and explain how it can be overriden if necessary. - tests/e2e/quadlet: Add `assert-last-key-regex` Required to test the `After=` override in [Unit] section See containers#22057 (comment) - quadlet/unitfile: add a prepenUnitLine method Requirements on networks should be inserted at the top of the section so the user can override them. Signed-off-by: jbtrystram <[email protected]>
Issue Description
When creating a .image quadlet file, the service fails to start if DNS name resolution is to early.
Steps to reproduce the issue
Reproducer :
/etc/containers/systemd/immich.image
Then have another quadlet container file which requires this image and start on boot :
/etc/containers/systemd/immich.container
Describe the results you received
The image fails to pull because it starts too early and DNS name resolution is not ready yet :
Describe the results you expected
As my
immich-server.container
declares aWantedBy
dependency onmulti-user.target
i'd expect my service to come up at boot time.However this fails due to the name resolution failure when pulling the image.
podman info output
Podman in a container
No
Privileged Or Rootless
Privileged
Upstream Latest Release
Yes
Additional environment details
systemd-253.15-2.fc38.x86_64
Additional information
A workaround that is to add a
After
requirement onnss-lookup.target
, on the service.So this could probably added by default on generated
.image
oneshot services.The text was updated successfully, but these errors were encountered: