From de764b05589ec73e1aa9ddd2d7118ced301602f0 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 15 Mar 2022 10:39:08 +0100 Subject: nodes: Silence warnings about ignored errors for `checkNodes()` Both the local and SQL electors don't check errors returned by `checkNodes()`. While we could convert all sites to properly do this, it doesn't really feel worth it: both electors only exist due to legacy reasons and should not be used in production systems at all. Ignore most of those errors inline so that we can remove the excemptions from golangci-lint's config file. --- .golangci.yml | 12 ------------ internal/praefect/nodes/local_elector.go | 6 +++++- internal/praefect/nodes/manager.go | 3 +++ internal/praefect/nodes/sql_elector.go | 5 +++++ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 226847520..417897f8c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -77,18 +77,6 @@ issues: - linters: - errcheck text: "Error return value of `[^`]+.(Close|Serve)` is not checked" - - linters: - - errcheck - path: "internal/praefect/nodes/local_elector.go" - text: "Error return value of `s.checkNodes` is not checked" - - linters: - - errcheck - path: "internal/praefect/nodes/manager.go" - text: "Error return value of `strategy.checkNodes` is not checked" - - linters: - - errcheck - path: "internal/praefect/nodes/sql_elector.go" - text: "Error return value of `s.checkNodes` is not checked" - linters: - errcheck path: "internal/middleware/limithandler/limithandler.go" diff --git a/internal/praefect/nodes/local_elector.go b/internal/praefect/nodes/local_elector.go index bea1ef68b..95c2c3f35 100644 --- a/internal/praefect/nodes/local_elector.go +++ b/internal/praefect/nodes/local_elector.go @@ -52,7 +52,11 @@ func (s *localElector) bootstrap(d time.Duration) { <-timer.C ctx := context.TODO() - s.checkNodes(ctx) + + if err := s.checkNodes(ctx); err != nil { + s.log.WithError(err).Warn("error checking nodes") + } + timer.Reset(d) } } diff --git a/internal/praefect/nodes/manager.go b/internal/praefect/nodes/manager.go index f7578cfbf..e57abeb0b 100644 --- a/internal/praefect/nodes/manager.go +++ b/internal/praefect/nodes/manager.go @@ -229,6 +229,9 @@ func (n *Mgr) Stop() { func (n *Mgr) checkShards() { for _, strategy := range n.strategies { ctx := context.Background() + + //nolint:errcheck // We don't care for this error. The nodes manager is only + // used for the deprecated SQL elector anyway. strategy.checkNodes(ctx) } } diff --git a/internal/praefect/nodes/sql_elector.go b/internal/praefect/nodes/sql_elector.go index fb976a3ed..b3adf2d8c 100644 --- a/internal/praefect/nodes/sql_elector.go +++ b/internal/praefect/nodes/sql_elector.go @@ -144,6 +144,8 @@ func (s *sqlElector) stop() { func (s *sqlElector) bootstrap(d time.Duration) { ctx := context.Background() + //nolint:errcheck // We don't care for this error. The nodes manager is only + // used for the deprecated SQL elector anyway. s.checkNodes(ctx) } @@ -159,6 +161,9 @@ func (s *sqlElector) monitor(d time.Duration) { return case <-ticker.C: } + + //nolint:errcheck // We don't care for this error. The nodes manager is only + // used for the deprecated SQL elector anyway. s.checkNodes(ctx) } } -- cgit v1.2.3