From f0ac6d5c9f319c74bd8174fd0fdc9ad3b4352e86 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Sun, 9 Feb 2025 16:13:08 +0000 Subject: [PATCH] [runsc] Print file name when cannot load state file --- runsc/container/state_file.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runsc/container/state_file.go b/runsc/container/state_file.go index 63ccfcb31..0fcd70dff 100644 --- a/runsc/container/state_file.go +++ b/runsc/container/state_file.go @@ -383,8 +383,12 @@ func (s *StateFile) load(v any, opts LoadOpts) error { } defer s.UnlockOrDie() - metaBytes, err := os.ReadFile(s.statePath()) + path := s.statePath() + metaBytes, err := os.ReadFile(path) if err != nil { + // Caller of this function relies on error code, we cannot return new error, + // but we need to provide a message with file name. + log.Warningf("Error loading state file %q: %v", path, err) return err } return json.Unmarshal(metaBytes, &v)