Skip to content

Commit

Permalink
http-service: fix get prometheus config panic (#5348)
Browse files Browse the repository at this point in the history
  • Loading branch information
csuzhangxc committed Oct 19, 2023
1 parent fb07d58 commit bbb73c5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/http-service/server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ func (s *ClusterServer) GetCluster(ctx context.Context, req *api.GetClusterReq)
// for TidbMonitor, we don't return error if previous TiDBCluster exists
if apierrors.IsNotFound(err) {
logger.Warn("TidbMonitor not found", zap.Error(err))
tm = nil // set empty TidbMonitor to nil
} else {
logger.Error("Get TidbMonitor failed", zap.Error(err))
}
Expand Down Expand Up @@ -664,9 +665,11 @@ func convertToClusterInfo(logger *zap.Logger, kubeCli kubernetes.Interface, tc *

if tm != nil {
info.Prometheus = &api.PrometheusStatus{
Version: tm.Spec.Prometheus.MonitorContainer.Version,
Resource: reConvertResourceRequirements(tm.Spec.Prometheus.MonitorContainer.ResourceRequirements),
CommandOptions: tm.Spec.Prometheus.Config.CommandOptions,
Version: tm.Spec.Prometheus.MonitorContainer.Version,
Resource: reConvertResourceRequirements(tm.Spec.Prometheus.MonitorContainer.ResourceRequirements),
}
if tm.Spec.Prometheus.Config != nil {
info.Prometheus.CommandOptions = tm.Spec.Prometheus.Config.CommandOptions
}
if tm.Spec.Grafana != nil {
info.Grafana = &api.GrafanaStatus{
Expand Down

0 comments on commit bbb73c5

Please sign in to comment.