From cbbbeb57e20fe2e708b8e13e23c50e20bb720cb4 Mon Sep 17 00:00:00 2001 From: Shachar Sharon Date: Mon, 5 Aug 2024 13:39:38 +0300 Subject: [PATCH] metrics: always resolve all versions Do not bail-out in case of failure to resolve any of the sub-component versions but rather defer this failure to final status code. Required in order to avoid partial versions-view as part of exported status metric. Signed-off-by: Shachar Sharon --- internal/metrics/versions.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/internal/metrics/versions.go b/internal/metrics/versions.go index 41ffd70..e190897 100644 --- a/internal/metrics/versions.go +++ b/internal/metrics/versions.go @@ -4,6 +4,7 @@ package metrics import ( "context" + "errors" ) var ( @@ -26,26 +27,17 @@ func UpdateDefaultVersions(version, commitid string) { // ResolveVersions is a best-effort to resolve current pod's versions info func ResolveVersions(clnt *kclient) (Versions, error) { - var err error + var imgErr, smbVersErr, ctdbVersErr error vers := Versions{ Version: defaultVersions.Version, CommitID: defaultVersions.CommitID, } if clnt != nil { - vers.SambaImage, err = resolveSambaImage(clnt) - if err != nil { - return vers, err - } - } - vers.SambaVersion, err = resolveSambaVersion() - if err != nil { - return vers, err - } - vers.CtdbVersion, err = resolveCtdbVersion() - if err != nil { - return vers, err + vers.SambaImage, imgErr = resolveSambaImage(clnt) } - return vers, nil + vers.SambaVersion, smbVersErr = resolveSambaVersion() + vers.CtdbVersion, ctdbVersErr = resolveCtdbVersion() + return vers, errors.Join(imgErr, smbVersErr, ctdbVersErr) } func resolveSambaImage(clnt *kclient) (string, error) {