Skip to content

Commit

Permalink
metrics: always resolve all versions
Browse files Browse the repository at this point in the history
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 <ssharon@redhat.com>
  • Loading branch information
synarete committed Aug 5, 2024
1 parent f29cb81 commit cbbbeb5
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions internal/metrics/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package metrics

import (
"context"
"errors"
)

var (
Expand All @@ -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) {
Expand Down

0 comments on commit cbbbeb5

Please sign in to comment.