Skip to content

Commit

Permalink
[8.7](backport #2384) Minor code cleanup (#2464)
Browse files Browse the repository at this point in the history
* Minor code cleanup (#2384)

* Formatting

* Update ubuntu release

* Revert unsafe change

(cherry picked from commit e4768d5)

# Conflicts:
#	Vagrantfile
#	internal/pkg/agent/application/coordinator/coordinator.go

* Resolving conflicts

---------

Co-authored-by: Shaunak Kashyap <ycombinator@gmail.com>
  • Loading branch information
mergify[bot] and ycombinator committed Apr 6, 2023
1 parent 7ffdfe0 commit 115ffc5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion internal/pkg/agent/application/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/component/runtime/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/component/runtime/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion pkg/component/runtime/runtime_comm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 115ffc5

Please sign in to comment.