Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.7](backport #2384) Minor code cleanup #2464

Merged
merged 2 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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