From 456a78867e3ffe394f3b49cc8f170a1e7a140c62 Mon Sep 17 00:00:00 2001 From: Maliz Date: Fri, 2 Jun 2023 16:50:38 +0000 Subject: [PATCH] backport of commit fc71ecc87e7ccdcf1048725e400a3ce1a9b3c88a --- agent/local/state.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/agent/local/state.go b/agent/local/state.go index d3ffa1e023e..5a037313b36 100644 --- a/agent/local/state.go +++ b/agent/local/state.go @@ -10,20 +10,20 @@ import ( "sync/atomic" "time" + "github.com/hashicorp/consul/acl" "github.com/hashicorp/consul/acl/resolver" + "github.com/hashicorp/consul/agent/structs" + "github.com/hashicorp/consul/agent/token" + "github.com/hashicorp/consul/api" + "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/lib/stringslice" + "github.com/hashicorp/consul/types" "github.com/armon/go-metrics" "github.com/armon/go-metrics/prometheus" "github.com/hashicorp/go-hclog" + "github.com/hashicorp/go-multierror" "github.com/mitchellh/copystructure" - - "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/agent/structs" - "github.com/hashicorp/consul/agent/token" - "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/lib" - "github.com/hashicorp/consul/types" ) var StateCounters = []prometheus.CounterDefinition{ @@ -1247,6 +1247,7 @@ func (l *State) SyncChanges() error { } } + var errs error // Sync the services // (logging happens in the helper methods) for id, s := range l.services { @@ -1260,7 +1261,7 @@ func (l *State) SyncChanges() error { l.logger.Debug("Service in sync", "service", id.String()) } if err != nil { - return err + errs = multierror.Append(errs, err) } } @@ -1281,10 +1282,10 @@ func (l *State) SyncChanges() error { l.logger.Debug("Check in sync", "check", id.String()) } if err != nil { - return err + errs = multierror.Append(errs, err) } } - return nil + return errs } // deleteService is used to delete a service from the server