From ee0ecc999187a36fba094fd7ddef322bc4ddaf4a Mon Sep 17 00:00:00 2001 From: irenarindos Date: Fri, 10 Jun 2022 14:10:05 -0400 Subject: [PATCH] fix context for worker upstreams --- internal/daemon/worker/controller_connection.go | 2 +- internal/daemon/worker/status.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/daemon/worker/controller_connection.go b/internal/daemon/worker/controller_connection.go index 82e410e4ea..aa4d1934d7 100644 --- a/internal/daemon/worker/controller_connection.go +++ b/internal/daemon/worker/controller_connection.go @@ -62,7 +62,7 @@ func (w *Worker) StartControllerConnections() error { if w.conf.RawConfig.HCPBClusterId != "" { clusterAddress := fmt.Sprintf("%s%s", w.conf.RawConfig.HCPBClusterId, hcpbUrlSuffix) initialAddrs = append(initialAddrs, resolver.Address{Addr: clusterAddress}) - event.WriteSysEvent(context.TODO(), op, fmt.Sprintf("Setting HCPB Cluster address %s as upstream address", clusterAddress)) + event.WriteSysEvent(w.baseContext, op, fmt.Sprintf("Setting HCPB Cluster address %s as upstream address", clusterAddress)) } else { return errors.New("no initial controller addresses found") } diff --git a/internal/daemon/worker/status.go b/internal/daemon/worker/status.go index 89840a3aa7..aaeffe710c 100644 --- a/internal/daemon/worker/status.go +++ b/internal/daemon/worker/status.go @@ -213,11 +213,11 @@ func (w *Worker) sendWorkerStatus(cancelCtx context.Context) { // Compare upstreams; update resolver if there is a difference, and emit an event with old and new addresses if lastStatus != nil && !strutil.EquivalentSlices(lastStatus.LastCalculatedUpstreams, newUpstreams) { upstreamsMessage := fmt.Sprintf("Upstreams has changed; old upstreams were: %s, new upstreams are: %s", lastStatus.LastCalculatedUpstreams, newUpstreams) - event.WriteSysEvent(context.TODO(), op, upstreamsMessage) + event.WriteSysEvent(cancelCtx, op, upstreamsMessage) w.Resolver().UpdateState(resolver.State{Addresses: addrs}) } else if lastStatus == nil { w.Resolver().UpdateState(resolver.State{Addresses: addrs}) - event.WriteSysEvent(context.TODO(), op, fmt.Sprintf("Upstreams after first status set to: %s", newUpstreams)) + event.WriteSysEvent(cancelCtx, op, fmt.Sprintf("Upstreams after first status set to: %s", newUpstreams)) } } w.lastStatusSuccess.Store(&LastStatusInformation{StatusResponse: result, StatusTime: time.Now(), LastCalculatedUpstreams: newUpstreams})