Skip to content

Commit

Permalink
log error
Browse files Browse the repository at this point in the history
  • Loading branch information
d80tb7 committed Sep 12, 2023
1 parent 2457da7 commit a606fe8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
5 changes: 4 additions & 1 deletion internal/scheduler/metrics.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package scheduler

import (
"github.com/armadaproject/armada/internal/common/logging"

Check failure on line 4 in internal/scheduler/metrics.go

View workflow job for this annotation

GitHub Actions / lint / Lint Go

File is not `gofumpt`-ed (gofumpt)
"strings"
"sync/atomic"
"time"

Check failure on line 7 in internal/scheduler/metrics.go

View workflow job for this annotation

GitHub Actions / lint / Lint Go

File is not `gofumpt`-ed (gofumpt)
Expand Down Expand Up @@ -87,7 +88,9 @@ func (c *MetricsCollector) Run(ctx *armadacontext.Context) error {
case <-ticker.C():
err := c.refresh(ctx)
if err != nil {
log.WithError(err).Warnf("error refreshing metrics state")
logging.
WithStacktrace(ctx.Log, err).
Warnf("error refreshing metrics state")
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion internal/scheduler/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package scheduler

import (
"fmt"
"github.com/armadaproject/armada/internal/common/logging"

Check failure on line 5 in internal/scheduler/publisher.go

View workflow job for this annotation

GitHub Actions / lint / Lint Go

File is not `gofumpt`-ed (gofumpt)
"strconv"
"sync"
"time"

Check failure on line 8 in internal/scheduler/publisher.go

View workflow job for this annotation

GitHub Actions / lint / Lint Go

File is not `gofumpt`-ed (gofumpt)
Expand Down Expand Up @@ -109,7 +110,9 @@ func (p *PulsarPublisher) PublishMessages(ctx *armadacontext.Context, events []*
for _, msg := range msgs {
p.producer.SendAsync(sendCtx, msg, func(_ pulsar.MessageID, _ *pulsar.ProducerMessage, err error) {
if err != nil {
log.WithError(err).Error("error sending message to Pulsar")
logging.
WithStacktrace(ctx.Log, err).
Error("error sending message to Pulsar")
errored = true
}
wg.Done()
Expand Down
8 changes: 5 additions & 3 deletions internal/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ func (s *Scheduler) initialise(ctx *armadacontext.Context) error {
return nil
default:
if _, err := s.syncState(ctx); err != nil {
ctx.Log.WithError(err).Error("failed to initialise; trying again in 1 second")
logging.WithStacktrace(ctx.Log, err).Error("failed to initialise; trying again in 1 second")
time.Sleep(1 * time.Second)
} else {
// Initialisation succeeded.
Expand All @@ -830,7 +830,7 @@ func (s *Scheduler) ensureDbUpToDate(ctx *armadacontext.Context, pollInterval ti
default:
numSent, err = s.publisher.PublishMarkers(ctx, groupId)
if err != nil {
ctx.Log.WithError(err).Error("Error sending marker messages to pulsar")
logging.WithStacktrace(ctx.Log, err).Error("Error sending marker messages to pulsar")
s.clock.Sleep(pollInterval)
} else {
messagesSent = true
Expand All @@ -846,7 +846,9 @@ func (s *Scheduler) ensureDbUpToDate(ctx *armadacontext.Context, pollInterval ti
default:
numReceived, err := s.jobRepository.CountReceivedPartitions(ctx, groupId)
if err != nil {
ctx.Log.WithError(err).Error("Error querying the database or marker messages")
logging.
WithStacktrace(ctx.Log, err).
Error("Error querying the database or marker messages")
}
if numSent == numReceived {
ctx.Log.Infof("Successfully ensured that database state is up to date")
Expand Down
5 changes: 4 additions & 1 deletion internal/scheduler/schedulerapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package scheduler

import (
"fmt"
"github.com/armadaproject/armada/internal/common/logging"

Check failure on line 5 in internal/scheduler/schedulerapp.go

View workflow job for this annotation

GitHub Actions / lint / Lint Go

File is not `gofumpt`-ed (gofumpt)
"net"
"net/http"
"strings"
Expand Down Expand Up @@ -68,7 +69,9 @@ func Run(config schedulerconfig.Configuration) error {
defer func() {
err := redisClient.Close()
if err != nil {
log.WithError(errors.WithStack(err)).Warnf("Redis client didn't close down cleanly")
logging.
WithStacktrace(ctx.Log, err).
Warnf("Redis client didn't close down cleanly")
}
}()
queueRepository := database.NewLegacyQueueRepository(redisClient)
Expand Down
14 changes: 10 additions & 4 deletions internal/scheduler/submitcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package scheduler

import (
"fmt"
"github.com/armadaproject/armada/internal/common/logging"

Check failure on line 5 in internal/scheduler/submitcheck.go

View workflow job for this annotation

GitHub Actions / lint / Lint Go

File is not `gofumpt`-ed (gofumpt)
"strings"
"sync"
"time"

lru "github.com/hashicorp/golang-lru"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"golang.org/x/exp/maps"
"k8s.io/apimachinery/pkg/util/clock"

Expand Down Expand Up @@ -101,7 +101,9 @@ func (srv *SubmitChecker) Run(ctx *armadacontext.Context) error {
func (srv *SubmitChecker) updateExecutors(ctx *armadacontext.Context) {
executors, err := srv.executorRepository.GetExecutors(ctx)
if err != nil {
log.WithError(err).Error("Error fetching executors")
logging.
WithStacktrace(ctx.Log, err).
Error("Error fetching executors")
return
}
for _, executor := range executors {
Expand All @@ -114,10 +116,14 @@ func (srv *SubmitChecker) updateExecutors(ctx *armadacontext.Context) {
}
srv.mu.Unlock()
if err != nil {
log.WithError(err).Errorf("Error constructing node db for executor %s", executor.Id)
logging.
WithStacktrace(ctx.Log, err).
Errorf("Error constructing node db for executor %s", executor.Id)
}
} else {
log.WithError(err).Warnf("Error clearing nodedb for executor %s", executor.Id)
logging.
WithStacktrace(ctx.Log, err).
Warnf("Error clearing nodedb for executor %s", executor.Id)
}
}

Expand Down

0 comments on commit a606fe8

Please sign in to comment.