From 951dd1386646a25e36aa17bba2a7bf938f106d59 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Fri, 6 Oct 2023 16:00:20 +0200 Subject: [PATCH] no error if images for containers don't exist Signed-off-by: Christian Goll --- CHANGELOG.md | 1 + internal/pkg/api/container/container.go | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05fd94ac..ab76ff74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,6 +103,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - During node discovery, prefer the primary network interface, if defined. #775 - added general test framework which creates temporary directories on the fly - only write IPMI if write is true +- Don't show an error if image files for containers can't be found. #933 ## [4.4.0] 2023-01-18 diff --git a/internal/pkg/api/container/container.go b/internal/pkg/api/container/container.go index 2539ff50..ca5bf82a 100644 --- a/internal/pkg/api/container/container.go +++ b/internal/pkg/api/container/container.go @@ -330,9 +330,7 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) { } var modTime uint64 imageStat, err := os.Stat(container.ImageFile(source)) - if err != nil { - wwlog.Error("%s\n", err) - } else { + if err == nil { modTime = uint64(imageStat.ModTime().Unix()) } size, err := util.DirSize(container.SourceDir(source)) @@ -340,15 +338,11 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) { wwlog.Error("%s\n", err) } imgSize, err := os.Stat(container.ImageFile(source)) - if err != nil { - wwlog.Error("%s\n", err) - } else { + if err == nil { size += imgSize.Size() } imgSize, err = os.Stat(container.ImageFile(source) + ".gz") - if err != nil { - wwlog.Error("%s\n", err) - } else { + if err == nil { size += imgSize.Size() }