Dashboard versions: Fix list for large dashboards (#109433)

This commit is contained in:
Stephanie Hingtgen
2025-08-11 07:12:16 -06:00
committed by GitHub
parent 63237f0be8
commit cc1f00cbfb
2 changed files with 84 additions and 1 deletions
@@ -259,13 +259,29 @@ func (s *Service) listHistoryThroughK8s(ctx context.Context, orgID int64, dashbo
return nil, dashboards.ErrDashboardNotFound
}
// if k8s returns a continue token, we need to fetch the next page(s) until we either reach the limit or there are no more pages
continueToken = out.GetContinue()
for (len(out.Items) < int(limit)) && (continueToken != "") {
tempOut, err := s.k8sclient.List(ctx, orgID, v1.ListOptions{
LabelSelector: labelSelector,
FieldSelector: fieldSelector,
Continue: continueToken,
Limit: limit - int64(len(out.Items)),
})
if err != nil {
return nil, err
}
out.Items = append(out.Items, tempOut.Items...)
continueToken = tempOut.GetContinue()
}
dashboards, err := s.UnstructuredToLegacyDashboardVersionList(ctx, out.Items, orgID)
if err != nil {
return nil, err
}
return &dashver.DashboardVersionResponse{
ContinueToken: out.GetContinue(),
ContinueToken: continueToken,
Versions: dashboards,
}, nil
}