Skip to content

Commit

Permalink
fix: dashboard panic while replacing query namespace with target name… (
Browse files Browse the repository at this point in the history
#4420)

Co-authored-by: monitor1379 <monitor1379@users.noreply.github.com>
  • Loading branch information
g1eny0ung and monitor1379 committed May 16, 2024
1 parent 0056240 commit 8c7efe4
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ For more information and how-to, see [RFC: Keep A Changelog](https://github.com/
### Fixed

- Fix TTL configuration from environment variables [#4338](https://github.com/chaos-mesh/chaos-mesh/pull/4338)
- Fix dashboard panic while replacing query namespace with targetNamespace in namespace scoped mode [#4409](https://github.com/chaos-mesh/chaos-mesh/issues/4409)

### Security

Expand Down
6 changes: 3 additions & 3 deletions pkg/dashboard/apiserver/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *Service) list(c *gin.Context) {
if ns == "" && !s.conf.ClusterScoped && s.conf.TargetNamespace != "" {
ns = s.conf.TargetNamespace

s.logger.V(1).Info("Replace query namespace with", ns)
s.logger.V(1).Info("Replace query namespace", "ns", ns)
}

start, _ := time.Parse(time.RFC3339, c.Query("start"))
Expand Down Expand Up @@ -146,7 +146,7 @@ func (s *Service) cascadeFetchEventsForWorkflow(c *gin.Context) {
if ns == "" && !s.conf.ClusterScoped && s.conf.TargetNamespace != "" {
ns = s.conf.TargetNamespace

s.logger.V(1).Info("Replace query namespace with", ns)
s.logger.V(1).Info("Replace query namespace", "ns", ns)
}

// we should fetch the events for Workflow and related WorkflowNode, so we need namespaced name at first
Expand Down Expand Up @@ -261,7 +261,7 @@ func (s *Service) get(c *gin.Context) {
if ns == "" && !s.conf.ClusterScoped && s.conf.TargetNamespace != "" {
ns = s.conf.TargetNamespace

s.logger.V(1).Info("Replace query namespace with", ns)
s.logger.V(1).Info("Replace query namespace", "ns", ns)
}

event, err := s.event.Find(context.Background(), uint(intID))
Expand Down
4 changes: 2 additions & 2 deletions pkg/dashboard/apiserver/experiment/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (s *Service) list(c *gin.Context) {
if ns == "" && !s.config.ClusterScoped && s.config.TargetNamespace != "" {
ns = s.config.TargetNamespace

s.log.V(1).Info("Replace query namespace with", ns)
s.log.V(1).Info("Replace query namespace", "ns", ns)
}

exps := make([]*apiservertypes.Experiment, 0)
Expand Down Expand Up @@ -570,7 +570,7 @@ func (s *Service) state(c *gin.Context) {
if ns == "" && !s.config.ClusterScoped && s.config.TargetNamespace != "" {
ns = s.config.TargetNamespace

s.log.V(1).Info("Replace query namespace with", ns)
s.log.V(1).Info("Replace query namespace", "ns", ns)
}

allChaosStatus := status.AllChaosStatus{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/dashboard/apiserver/schedule/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (s *Service) list(c *gin.Context) {
if ns == "" && !s.config.ClusterScoped && s.config.TargetNamespace != "" {
ns = s.config.TargetNamespace

s.log.V(1).Info("Replace query namespace with", ns)
s.log.V(1).Info("Replace query namespace", "ns", ns)
}

ScheduleList := v1alpha1.ScheduleList{}
Expand Down
6 changes: 3 additions & 3 deletions pkg/dashboard/apiserver/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (s *Service) listStatusCheckTemplate(c *gin.Context) {
ns, name := c.Query("namespace"), c.Query("name")
if ns == "" && !s.conf.ClusterScoped && s.conf.TargetNamespace != "" {
ns = s.conf.TargetNamespace
s.logger.Info("Replace query namespace with", ns)
s.logger.Info("Replace query namespace", "ns", ns)
}

configMapList := v1.ConfigMapList{}
Expand Down Expand Up @@ -195,7 +195,7 @@ func (s *Service) getStatusCheckTemplateDetail(c *gin.Context) {
ns, name := c.Query("namespace"), c.Query("name")
if ns == "" && !s.conf.ClusterScoped && s.conf.TargetNamespace != "" {
ns = s.conf.TargetNamespace
s.logger.Info("Replace query namespace with", ns)
s.logger.Info("Replace query namespace", "ns", ns)
}
if name == "" {
u.SetAPIError(c, u.ErrBadRequest.New("name is required"))
Expand Down Expand Up @@ -315,7 +315,7 @@ func (s *Service) deleteStatusCheckTemplate(c *gin.Context) {
ns, name := c.Query("namespace"), c.Query("name")
if ns == "" && !s.conf.ClusterScoped && s.conf.TargetNamespace != "" {
ns = s.conf.TargetNamespace
s.logger.Info("Replace query namespace with", ns)
s.logger.Info("Replace query namespace", "ns", ns)
}
if name == "" {
u.SetAPIError(c, u.ErrBadRequest.New("name is required"))
Expand Down
2 changes: 1 addition & 1 deletion pkg/dashboard/apiserver/utils/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func AuthMiddleware(c *gin.Context, config *config.ChaosDashboardConfig) {
if ns == "" && !config.ClusterScoped && config.TargetNamespace != "" {
ns = config.TargetNamespace

log.L().WithName("auth middleware").V(1).Info("Replace query namespace with", ns)
log.L().WithName("auth middleware").V(1).Info("Replace query namespace", "ns", ns)
}

verb := "list"
Expand Down

0 comments on commit 8c7efe4

Please sign in to comment.