podman: remember hooks-dir on restarts

When podman restarts config values within the Engine are lost.
Add --hook-dirs arguments as appropriate to the cleanup command
so that hooks are preserved on restarts due to the on-restart setting

Tests: add a check that prestart/poststop hooks ran every time after 2
restarts.
`wait_for_restart_count` was re-used to wait for restarts and moved to
helpers file.

Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
Fixes: #17935
This commit is contained in:
Dominique Martinet
2025-05-14 17:24:27 +09:00
parent a1ac6c33cc
commit 90ee7c86a3
4 changed files with 71 additions and 21 deletions

View File

@ -285,6 +285,9 @@ func CreateExitCommandArgs(storageConfig storageTypes.StoreOptions, config *conf
"--db-backend", config.Engine.DBBackend,
fmt.Sprintf("--transient-store=%t", storageConfig.TransientStore),
}
for _, dir := range config.Engine.HooksDir.Get() {
command = append(command, []string{"--hooks-dir", dir}...)
}
if storageConfig.ImageStore != "" {
command = append(command, []string{"--imagestore", storageConfig.ImageStore}...)
}