From 1dfc23277ccc63713d1be08f85d37f63e7ea0318 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Fri, 26 Jul 2024 18:04:30 +1000 Subject: [PATCH] fix: return error rather than logging (#2181) Also was logging with incorrect package... --- .golangci.yml | 2 ++ backend/controller/console.go | 3 +-- backend/controller/cronjobs/cronjobs.go | 4 ++-- go.mod | 1 - go.sum | 2 -- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index daba8a5c1c..d46adb0ba2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -93,6 +93,8 @@ linters-settings: desc: "use github.com/TBD54566975/ftl/internal/exec" - pkg: golang.design/x/reflect desc: "use github.com/TBD54566975/ftl/internal/reflect" + - pkg: "github.com/reugn/go-quartz/logger" + desc: "use github.com/TBD54566975/ftl/internal/log" # wrapcheck: # ignorePackageGlobs: # - github.com/TBD54566975/ftl/* diff --git a/backend/controller/console.go b/backend/controller/console.go index b3764eccf5..4ac283b979 100644 --- a/backend/controller/console.go +++ b/backend/controller/console.go @@ -9,7 +9,6 @@ import ( "connectrpc.com/connect" "github.com/alecthomas/types/optional" - "github.com/reugn/go-quartz/logger" "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/timestamppb" @@ -164,7 +163,7 @@ func (c *ConsoleService) GetModules(ctx context.Context, req *connect.Request[pb sorted, err := buildengine.TopologicalSort(graph(sch)) if err != nil { - logger.Debugf(err.Error()) + return nil, fmt.Errorf("failed to sort modules: %w", err) } topology := &pbconsole.Topology{ Levels: make([]*pbconsole.TopologyGroup, len(sorted)), diff --git a/backend/controller/cronjobs/cronjobs.go b/backend/controller/cronjobs/cronjobs.go index dfe07c371e..4d88227c95 100644 --- a/backend/controller/cronjobs/cronjobs.go +++ b/backend/controller/cronjobs/cronjobs.go @@ -307,7 +307,7 @@ func (s *Service) watchForUpdates(ctx context.Context) { now := s.clock.Now() next := now.Add(time.Hour) // should never be reached, expect a different signal long beforehand for _, j := range state.jobs { - if possibleNext, err := s.nextAttemptForJob(j, state, now,false); err == nil && possibleNext.Before(next) { + if possibleNext, err := s.nextAttemptForJob(j, state, now, false); err == nil && possibleNext.Before(next) { next = possibleNext } } @@ -333,7 +333,7 @@ func (s *Service) watchForUpdates(ctx context.Context) { // as if there is a pause of over a second we could miss jobs if we use the current time // this is very unlikely to happen, but if it did it would be hard to diagnose jobsToAttempt := slices.Filter(state.jobs, func(j model.CronJob) bool { - if n, err := s.nextAttemptForJob(j, state, next,true); err == nil { + if n, err := s.nextAttemptForJob(j, state, next, true); err == nil { return !n.After(s.clock.Now().UTC()) } return false diff --git a/go.mod b/go.mod index 899105728c..6b889fa076 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,6 @@ require ( github.com/multiformats/go-base36 v0.2.0 github.com/otiai10/copy v1.14.0 github.com/radovskyb/watcher v1.0.7 - github.com/reugn/go-quartz v0.12.0 github.com/rs/cors v1.11.0 github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 github.com/swaggest/jsonschema-go v0.3.72 diff --git a/go.sum b/go.sum index 200eecea3b..4cd9afc792 100644 --- a/go.sum +++ b/go.sum @@ -207,8 +207,6 @@ github.com/radovskyb/watcher v1.0.7 h1:AYePLih6dpmS32vlHfhCeli8127LzkIgwJGcwwe8t github.com/radovskyb/watcher v1.0.7/go.mod h1:78okwvY5wPdzcb1UYnip1pvrZNIVEIh/Cm+ZuvsUYIg= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/reugn/go-quartz v0.12.0 h1:RsrklW++R5Swc7mCPYseXM06PTWN4N7/f1rsYkhHiww= -github.com/reugn/go-quartz v0.12.0/go.mod h1:no4ktgYbAAuY0E1SchR8cTx1LF4jYIzdgaQhzRPSkpk= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/robertkrimen/otto v0.2.1 h1:FVP0PJ0AHIjC+N4pKCG9yCDz6LHNPCwi/GKID5pGGF0=