K8s: Dashboard History: Improve Error Handling (#101816)

This commit is contained in:
Stephanie Hingtgen
2025-03-09 12:19:40 +03:00
committed by GitHub
parent 9651505cb7
commit b56db69b32
2 changed files with 47 additions and 2 deletions
@@ -7,6 +7,7 @@ import (
"strconv"
"strings"
apierrors "k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -223,8 +224,13 @@ func (s *Service) getDashIDMaybeEmpty(ctx context.Context, uid string, orgID int
func (s *Service) getHistoryThroughK8s(ctx context.Context, orgID int64, dashboardUID string, rv int64) (*dashver.DashboardVersionDTO, error) {
out, err := s.k8sclient.Get(ctx, dashboardUID, orgID, v1.GetOptions{ResourceVersion: strconv.FormatInt(rv, 10)})
if err != nil {
if apierrors.IsNotFound(err) {
return nil, dashboards.ErrDashboardNotFound
}
return nil, err
} else if out == nil {
}
if out == nil {
return nil, dashboards.ErrDashboardNotFound
}
@@ -243,8 +249,13 @@ func (s *Service) listHistoryThroughK8s(ctx context.Context, orgID int64, dashbo
Continue: continueToken,
})
if err != nil {
if apierrors.IsNotFound(err) {
return nil, dashboards.ErrDashboardNotFound
}
return nil, err
} else if out == nil {
}
if out == nil {
return nil, dashboards.ErrDashboardNotFound
}