From 8434fb2914862059ca86c6faf2479bc78b7bde5f Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 23 Mar 2023 18:57:08 -0400 Subject: [PATCH 1/2] 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 --- Vagrantfile | 6 ++++++ .../pkg/agent/application/coordinator/coordinator.go | 9 +++++++++ pkg/component/runtime/command.go | 1 + pkg/component/runtime/manager.go | 5 +++-- pkg/component/runtime/runtime_comm.go | 5 ++++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 8cfde6f4b3b..33c901c3ff1 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -129,8 +129,14 @@ Vagrant.configure("2") do |config| end end +<<<<<<< HEAD config.vm.define "elastic-agent" do |nodeconfig| nodeconfig.vm.box = "ubuntu/jammy64" +======= + config.vm.define "dev" do |nodeconfig| + nodeconfig.vm.box = "ubuntu/jammy64" + +>>>>>>> e4768d517c (Minor code cleanup (#2384)) nodeconfig.vm.hostname = "elastic-agent-dev" nodeconfig.vm.network "private_network", diff --git a/internal/pkg/agent/application/coordinator/coordinator.go b/internal/pkg/agent/application/coordinator/coordinator.go index 175ab56b014..94fc5f1e0dc 100644 --- a/internal/pkg/agent/application/coordinator/coordinator.go +++ b/internal/pkg/agent/application/coordinator/coordinator.go @@ -828,7 +828,16 @@ func (c *Coordinator) compute() (map[string]interface{}, []component.Component, configInjector = c.monitorMgr.MonitoringConfig } +<<<<<<< HEAD comps, err := c.specs.ToComponents(cfg, configInjector, c.state.logLevel, c.agentInfo) +======= + comps, err := c.specs.ToComponents( + cfg, + configInjector, + c.logLevel, + c.agentInfo, + ) +>>>>>>> e4768d517c (Minor code cleanup (#2384)) 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(), From 9e7089b88612cf33ee0d68f0663718591a11c8f2 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 5 Apr 2023 21:32:52 -0700 Subject: [PATCH 2/2] Resolving conflicts --- Vagrantfile | 6 ------ internal/pkg/agent/application/coordinator/coordinator.go | 6 +----- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 33c901c3ff1..8cfde6f4b3b 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -129,14 +129,8 @@ Vagrant.configure("2") do |config| end end -<<<<<<< HEAD config.vm.define "elastic-agent" do |nodeconfig| nodeconfig.vm.box = "ubuntu/jammy64" -======= - config.vm.define "dev" do |nodeconfig| - nodeconfig.vm.box = "ubuntu/jammy64" - ->>>>>>> e4768d517c (Minor code cleanup (#2384)) nodeconfig.vm.hostname = "elastic-agent-dev" nodeconfig.vm.network "private_network", diff --git a/internal/pkg/agent/application/coordinator/coordinator.go b/internal/pkg/agent/application/coordinator/coordinator.go index 94fc5f1e0dc..8c9b4c8c1eb 100644 --- a/internal/pkg/agent/application/coordinator/coordinator.go +++ b/internal/pkg/agent/application/coordinator/coordinator.go @@ -828,16 +828,12 @@ func (c *Coordinator) compute() (map[string]interface{}, []component.Component, configInjector = c.monitorMgr.MonitoringConfig } -<<<<<<< HEAD - comps, err := c.specs.ToComponents(cfg, configInjector, c.state.logLevel, c.agentInfo) -======= comps, err := c.specs.ToComponents( cfg, configInjector, - c.logLevel, + c.state.logLevel, c.agentInfo, ) ->>>>>>> e4768d517c (Minor code cleanup (#2384)) if err != nil { return nil, nil, fmt.Errorf("failed to render components: %w", err) }