Skip to content

Commit

Permalink
fix(internal/server): handle poller events no data error (don't error…
Browse files Browse the repository at this point in the history
… level log)

Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho committed Nov 15, 2024
1 parent 9cc8610 commit 9b795a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/server/handlers_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

v1 "github.com/leptonai/gpud/api/v1"
lep_components "github.com/leptonai/gpud/components"
"github.com/leptonai/gpud/components/query"
"github.com/leptonai/gpud/errdefs"
"github.com/leptonai/gpud/log"

Expand Down Expand Up @@ -230,6 +231,11 @@ func (g *globalHandler) getEvents(c *gin.Context) {
}
event, err := component.Events(c, startTime)
if err != nil {
if errors.Is(err, query.ErrNoData) {
log.Logger.Warnw("no events found", "component", componentName)
continue
}

log.Logger.Errorw("failed to invoke component events",
"operation", "GetEvents",
"component", componentName,
Expand Down Expand Up @@ -325,6 +331,11 @@ func (g *globalHandler) getInfo(c *gin.Context) {
}
events, err := component.Events(c, startTime)
if err != nil {
if errors.Is(err, query.ErrNoData) {
log.Logger.Warnw("no events found", "component", componentName)
continue
}

log.Logger.Errorw("failed to invoke component events",
"operation", "GetInfo",
"component", componentName,
Expand Down
6 changes: 6 additions & 0 deletions internal/session/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

v1 "github.com/leptonai/gpud/api/v1"
"github.com/leptonai/gpud/components"
"github.com/leptonai/gpud/components/query"
"github.com/leptonai/gpud/log"
"github.com/leptonai/gpud/pkg/reboot"
"github.com/leptonai/gpud/pkg/systemd"
Expand Down Expand Up @@ -194,6 +195,11 @@ func (s *Session) getEvents(ctx context.Context, payload Request) (v1.LeptonEven
}
event, err := component.Events(ctx, startTime)
if err != nil {
if errors.Is(err, query.ErrNoData) {
log.Logger.Warnw("no events found", "component", componentName)
continue
}

log.Logger.Errorw("failed to invoke component events",
"operation", "GetEvents",
"component", componentName,
Expand Down

0 comments on commit 9b795a0

Please sign in to comment.