From 115ffc5998598b020b8251c9f448ec514b294c55 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 5 Apr 2023 21:52:29 -0700 Subject: [PATCH] [8.7](backport #2384) Minor code cleanup (#2464) * Minor code cleanup (#2384) * Formatting * Update ubuntu release * Revert unsafe change (cherry picked from commit e4768d517cf1c934c4880fa7cb68db4611407008) # Conflicts: # Vagrantfile # internal/pkg/agent/application/coordinator/coordinator.go * Resolving conflicts --------- Co-authored-by: Shaunak Kashyap --- internal/pkg/agent/application/coordinator/coordinator.go | 7 ++++++- pkg/component/runtime/command.go | 1 + pkg/component/runtime/manager.go | 5 +++-- pkg/component/runtime/runtime_comm.go | 5 ++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/internal/pkg/agent/application/coordinator/coordinator.go b/internal/pkg/agent/application/coordinator/coordinator.go index 175ab56b014..8c9b4c8c1eb 100644 --- a/internal/pkg/agent/application/coordinator/coordinator.go +++ b/internal/pkg/agent/application/coordinator/coordinator.go @@ -828,7 +828,12 @@ func (c *Coordinator) compute() (map[string]interface{}, []component.Component, configInjector = c.monitorMgr.MonitoringConfig } - comps, err := c.specs.ToComponents(cfg, configInjector, c.state.logLevel, c.agentInfo) + comps, err := c.specs.ToComponents( + cfg, + configInjector, + c.state.logLevel, + c.agentInfo, + ) if err != nil { return nil, nil, fmt.Errorf("failed to render components: %w", err) } diff --git a/pkg/component/runtime/command.go b/pkg/component/runtime/command.go index 9972a0795b5..a8610f9b764 100644 --- a/pkg/component/runtime/command.go +++ b/pkg/component/runtime/command.go @@ -148,6 +148,7 @@ func (c *CommandRuntime) Run(ctx context.Context, comm Communicator) error { if sendExpected || c.state.unsettled() { comm.CheckinExpected(c.state.toCheckinExpected(), nil) } + if changed { c.sendObserved() } diff --git a/pkg/component/runtime/manager.go b/pkg/component/runtime/manager.go index 7b1fa4cf52c..35d2b14ff10 100644 --- a/pkg/component/runtime/manager.go +++ b/pkg/component/runtime/manager.go @@ -644,7 +644,7 @@ func (m *Manager) Actions(server proto.ElasticAgent_ActionsServer) error { // update updates the current state of the running components. // -// This returns as soon as possible, work is performed in the background to +// This returns as soon as possible, work is performed in the background. func (m *Manager) update(components []component.Component, teardown bool) error { m.mx.Lock() defer m.mx.Unlock() @@ -660,7 +660,8 @@ func (m *Manager) update(components []component.Component, teardown bool) error newComponents := make([]component.Component, 0, len(components)) for _, comp := range components { touched[comp.ID] = true - if existing, ok := m.current[comp.ID]; ok { + existing, ok := m.current[comp.ID] + if ok { // existing component; send runtime updated value existing.currComp = comp if err := existing.runtime.Update(comp); err != nil { diff --git a/pkg/component/runtime/runtime_comm.go b/pkg/component/runtime/runtime_comm.go index 51a621895d8..9b7f81802e4 100644 --- a/pkg/component/runtime/runtime_comm.go +++ b/pkg/component/runtime/runtime_comm.go @@ -132,7 +132,10 @@ func (c *runtimeComm) WriteConnInfo(w io.Writer, services ...client.Service) err return nil } -func (c *runtimeComm) CheckinExpected(expected *proto.CheckinExpected, observed *proto.CheckinObserved) { +func (c *runtimeComm) CheckinExpected( + expected *proto.CheckinExpected, + observed *proto.CheckinObserved, +) { if c.agentInfo != nil && c.agentInfo.AgentID() != "" { expected.AgentInfo = &proto.CheckinAgentInfo{ Id: c.agentInfo.AgentID(),