Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GuanqunYang193 committed Apr 2, 2024
1 parent 86b79a2 commit 7f99acb
Show file tree
Hide file tree
Showing 43 changed files with 1,067 additions and 1,066 deletions.
9 changes: 4 additions & 5 deletions agent/agents/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type Process struct {
changes chan inventorypb.AgentStatus
backoff *backoff.Backoff
ctxDone chan struct{}
err chan error
err error
initialized chan bool

// recreated on each restart
Expand Down Expand Up @@ -97,16 +97,15 @@ func New(params *Params, redactWords []string, l *logrus.Entry) *Process {
changes: make(chan inventorypb.AgentStatus, 10),
backoff: backoff.New(backoffMinDelay, backoffMaxDelay),
ctxDone: make(chan struct{}),
err: make(chan error),
initialized: make(chan bool, 2),
initialized: make(chan bool),
}
}

func (p *Process) IsInitialized() <-chan bool {
return p.initialized
}

func (p *Process) GetError() <-chan error {
func (p *Process) GetError() error {
return p.err
}

Expand Down Expand Up @@ -212,8 +211,8 @@ func (p *Process) toFailing(err error) {
p.changes <- inventorypb.AgentStatus_INITIALIZATION_ERROR
p.l.Infof("Process: exited: %s.", p.cmd.ProcessState)
go p.toDone()
p.err = err
p.initialized <- false
p.err <- err
}

// STOPPING -> DONE.
Expand Down
2 changes: 1 addition & 1 deletion agent/agents/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ func (s *Supervisor) startProcess(agentID string, agentProcess *agentpb.SetState

if !<-process.IsInitialized() {
defer cancel()
return <-process.GetError()
return process.GetError()
}

//nolint:forcetypeassert
Expand Down
12 changes: 6 additions & 6 deletions api/agentlocalpb/json/agentlocalpb.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,18 @@
"x-order": 4
},
"status": {
"description": "AgentStatus represents actual Agent status.\n\n - STARTING: Agent is starting.\n - RUNNING: Agent is running.\n - WAITING: Agent will be restarted automatically soon.\n - STOPPING: Agent is stopping.\n - DONE: Agent finished.\n - UNKNOWN: Agent is not connected, we don't know anything about it's state.\n - INITIALIZATION_ERROR: Agent encountered error when starting.",
"description": "AgentStatus represents actual Agent status.\n\n - STARTING: Agent is starting.\n - INITIALIZATION_ERROR: Agent encountered error when starting.\n - RUNNING: Agent is running.\n - WAITING: Agent encountered error when running and will be restarted automatically soon.\n - STOPPING: Agent is stopping.\n - DONE: Agent finished.\n - UNKNOWN: Agent is not connected, we don't know anything about it's state.",
"type": "string",
"default": "AGENT_STATUS_INVALID",
"enum": [
"AGENT_STATUS_INVALID",
"STARTING",
"INITIALIZATION_ERROR",
"RUNNING",
"WAITING",
"STOPPING",
"DONE",
"UNKNOWN",
"INITIALIZATION_ERROR"
"UNKNOWN"
],
"x-order": 2
}
Expand Down Expand Up @@ -343,18 +343,18 @@
"x-order": 4
},
"status": {
"description": "AgentStatus represents actual Agent status.\n\n - STARTING: Agent is starting.\n - RUNNING: Agent is running.\n - WAITING: Agent will be restarted automatically soon.\n - STOPPING: Agent is stopping.\n - DONE: Agent finished.\n - UNKNOWN: Agent is not connected, we don't know anything about it's state.\n - INITIALIZATION_ERROR: Agent encountered error when starting.",
"description": "AgentStatus represents actual Agent status.\n\n - STARTING: Agent is starting.\n - INITIALIZATION_ERROR: Agent encountered error when starting.\n - RUNNING: Agent is running.\n - WAITING: Agent encountered error when running and will be restarted automatically soon.\n - STOPPING: Agent is stopping.\n - DONE: Agent finished.\n - UNKNOWN: Agent is not connected, we don't know anything about it's state.",
"type": "string",
"default": "AGENT_STATUS_INVALID",
"enum": [
"AGENT_STATUS_INVALID",
"STARTING",
"INITIALIZATION_ERROR",
"RUNNING",
"WAITING",
"STOPPING",
"DONE",
"UNKNOWN",
"INITIALIZATION_ERROR"
"UNKNOWN"
],
"x-order": 2
}
Expand Down
14 changes: 7 additions & 7 deletions api/agentlocalpb/json/client/agent_local/status2_responses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions api/agentlocalpb/json/client/agent_local/status_responses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions api/inventorypb/agent_status.dot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ digraph {
UNKNOWN [fillcolor=yellow];

STARTING -> RUNNING;
STARTING -> FAILING; [style=dotted]
STARTING -> FAILING;
STARTING -> UNKNOWN; [style=dotted]

RUNNING -> STOPPING;
RUNNING -> WAITING;
Expand All @@ -19,7 +20,8 @@ digraph {
WAITING -> DONE;
WAITING -> UNKNOWN; [style=dotted]

FAILING -> DONE; [style=dotted]
FAILING -> DONE;
FAILING -> UNKNOWN; [style=dotted]

STOPPING -> DONE;
STOPPING -> UNKNOWN; [style=dotted]
Expand Down
22 changes: 11 additions & 11 deletions api/inventorypb/agent_status.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions api/inventorypb/agent_status.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ enum AgentStatus {
AGENT_STATUS_INVALID = 0;
// Agent is starting.
STARTING = 1;
// Agent encountered error when starting.
INITIALIZATION_ERROR = 7;
// Agent is running.
RUNNING = 2;
// Agent will be restarted automatically soon.
// Agent encountered error when running and will be restarted automatically soon.
WAITING = 3;
// Agent is stopping.
STOPPING = 4;
// Agent finished.
DONE = 5;
// Agent is not connected, we don't know anything about it's state.
UNKNOWN = 6;
// Agent encountered error when starting.
INITIALIZATION_ERROR = 7;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7f99acb

Please sign in to comment.