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

PMM-13348 Fix status presentation. #3200

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion admin/commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ func (a listResultAgent) NiceAgentStatus() string {
if res == "" {
res = "unknown" //nolint:goconst
}
res = cases.Title(language.English).String(strings.ToLower(res))
res = strings.ToLower(res)
res = cases.Title(language.English).String(res)
res = strings.ReplaceAll(res, "_", " ")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be good to extract this into method since it is used in two places. With that we can ensure always same "formatting" in both methods.

if a.Disabled {
res += " (disabled)"
}
Expand Down
4 changes: 3 additions & 1 deletion admin/commands/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ func (res *statusResult) HumanReadableAgentType(agentType string) string {
}

func (res *statusResult) NiceAgentStatus(status string) string {
return cases.Title(language.English).String(strings.ToLower(status))
status = strings.ToLower(status)
status = cases.Title(language.English).String(status)
return strings.ReplaceAll(status, "_", " ")
}

func (res *statusResult) Result() {}
Expand Down
2 changes: 1 addition & 1 deletion agent/agents/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (p *Process) toFailing(err error) {
p.l.Tracef("Process: failing")
p.changes <- inventorypb.AgentStatus_INITIALIZATION_ERROR
p.l.Infof("Process: exited: %s.", p.cmd.ProcessState)
go p.toDone()
close(p.changes)
p.err = err
p.initialized <- false
}
Expand Down
20 changes: 10 additions & 10 deletions agent/agents/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,16 @@ func (s *Supervisor) startProcess(agentID string, agentProcess *agentpb.SetState
close(done)
}()

//nolint:forcetypeassert
s.agentProcesses[agentID] = &agentProcessInfo{
cancel: cancel,
done: done,
requestedState: proto.Clone(agentProcess).(*agentpb.SetStateRequest_AgentProcess),
listenPort: port,
processExecPath: processParams.Path,
logStore: logStore,
}

t := time.NewTimer(start_Process_Waiting)
defer t.Stop()
select {
Expand All @@ -500,16 +510,6 @@ func (s *Supervisor) startProcess(agentID string, agentProcess *agentpb.SetState
}
case <-t.C:
}

//nolint:forcetypeassert
s.agentProcesses[agentID] = &agentProcessInfo{
cancel: cancel,
done: done,
requestedState: proto.Clone(agentProcess).(*agentpb.SetStateRequest_AgentProcess),
listenPort: port,
processExecPath: processParams.Path,
logStore: logStore,
}
return nil
}

Expand Down
Loading