Do not skip /run when counting the size (#538)

(cherry picked from commit a6bf3541c5)
This commit is contained in:
Itxaka 2024-09-13 17:31:40 +02:00 committed by Itxaka
parent 4f2bc7732c
commit e23d099a07

View File

@ -823,12 +823,11 @@ func GetSourceSize(config *Config, source *v1.ImageSource) (int64, error) {
hostDir = "/host"
}
err = fsutils.WalkDirFs(config.Fs, source.Value(), func(path string, d fs.DirEntry, err error) error {
// If its empty we are just not setting it, so probably out of the k8s upgrade path
if hostDir != "" && strings.HasPrefix(path, hostDir) {
config.Logger.Logger.Debug().Str("path", path).Str("hostDir", hostDir).Msg("Skipping file as it is a host directory")
} else if strings.HasPrefix(path, "/proc") || strings.HasPrefix(path, "/dev") || strings.HasPrefix(path, "/run") {
config.Logger.Logger.Debug().Str("path", path).Str("hostDir", hostDir).Msg("Skipping dir as it is a system directory (/proc, /dev or /run)")
} else if strings.HasPrefix(path, "/proc") || strings.HasPrefix(path, "/dev") {
config.Logger.Logger.Debug().Str("path", path).Str("hostDir", hostDir).Msg("Skipping dir as it is a runtime directory (/proc or /dev)")
} else {
v := getSize(&size, filesVisited, path, d, err)
return v