From f4599bebe1073c953c39319fc2115befbacbdb67 Mon Sep 17 00:00:00 2001 From: Savely Krasovsky Date: Sat, 10 May 2025 16:44:27 +0200 Subject: [PATCH] feat: support podman volatile containers It's used by all Podman Quadlets. Those containers are not in fact volatile, but due to the managed nature of those containers, they probably decided to make them transient. --- container/podman/fs.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/container/podman/fs.go b/container/podman/fs.go index e714e900c3..51ea8b4f90 100644 --- a/container/podman/fs.go +++ b/container/podman/fs.go @@ -24,7 +24,8 @@ import ( ) const ( - containersJSONFilename = "containers.json" + containersJSONFilename = "containers.json" + volatileContainersJSONFilename = "volatile-containers.json" ) type containersJSON struct { @@ -44,6 +45,25 @@ func rwLayerID(storageDriver docker.StorageDriver, storageDir string, containerI return "", err } + // Read volatile-containers.json if it exists. + // This is important for Podman Quadlets since they are not presented in the containers.json file. + volatileData, err := os.ReadFile(filepath.Join( + storageDir, + string(storageDriver)+"-containers", + volatileContainersJSONFilename, + )) + if err != nil && !os.IsNotExist(err) { + return "", err + } + if volatileData != nil { + var volatileContainers []containersJSON + err = json.Unmarshal(volatileData, &volatileContainers) + if err != nil { + return "", err + } + containers = append(containers, volatileContainers...) + } + for _, c := range containers { if c.ID == containerID { return c.Layer, nil