mirror of
https://github.com/containers/podman.git
synced 2025-10-18 03:33:32 +08:00
quadlet: Add a network requirement on .image units
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 https://github.com/containers/podman/issues/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 https://github.com/containers/podman/pull/22057#issuecomment-2008959993 - 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 <jbtrystram@redhat.com>
This commit is contained in:
@ -90,6 +90,11 @@ func (g *unitGroup) addLine(line *unitLine) {
|
||||
g.lines = append(g.lines, line)
|
||||
}
|
||||
|
||||
func (g *unitGroup) prependLine(line *unitLine) {
|
||||
n := []*unitLine{line}
|
||||
g.lines = append(n, g.lines...)
|
||||
}
|
||||
|
||||
func (g *unitGroup) addComment(line *unitLine) {
|
||||
g.comments = append(g.comments, line)
|
||||
}
|
||||
@ -923,6 +928,17 @@ func (f *UnitFile) PrependComment(groupName string, comments ...string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (f *UnitFile) PrependUnitLine(groupName string, key string, value string) {
|
||||
var group *unitGroup
|
||||
if groupName == "" && len(f.groups) > 0 {
|
||||
group = f.groups[0]
|
||||
} else {
|
||||
// Uses magic "" for first comment-only group if no other groups
|
||||
group = f.ensureGroup(groupName)
|
||||
}
|
||||
group.prependLine(newUnitLine(key, value, false))
|
||||
}
|
||||
|
||||
func (f *UnitFile) GetTemplateParts() (string, string) {
|
||||
ext := filepath.Ext(f.Filename)
|
||||
basename := strings.TrimSuffix(f.Filename, ext)
|
||||
|
Reference in New Issue
Block a user