Add /api/v3/cluster/process/:id/probe endpoint

This commit is contained in:
Ingo Oppermann
2023-07-05 11:03:45 +02:00
parent e49de44eb7
commit 71dbfe329e
11 changed files with 295 additions and 24 deletions

View File

@@ -40,6 +40,7 @@ type Node interface {
ReloadProcess(id app.ProcessID) error
DeleteProcess(id app.ProcessID) error
UpdateProcess(id app.ProcessID, config *app.Config, metadata map[string]interface{}) error
ProbeProcess(id app.ProcessID) (clientapi.Probe, error)
NodeReader
}
@@ -1106,3 +1107,21 @@ func (n *node) UpdateProcess(id app.ProcessID, config *app.Config, metadata map[
return n.peer.ProcessUpdate(client.NewProcessID(id.ID, id.Domain), cfg)
}
func (n *node) ProbeProcess(id app.ProcessID) (clientapi.Probe, error) {
n.peerLock.RLock()
defer n.peerLock.RUnlock()
if n.peer == nil {
probe := clientapi.Probe{
Log: []string{fmt.Sprintf("the node %s where the process %s resides, is not connected", n.id, id.String())},
}
return probe, fmt.Errorf("not connected")
}
probe, err := n.peer.ProcessProbe(client.NewProcessID(id.ID, id.Domain))
probe.Log = append([]string{fmt.Sprintf("probed on node: %s", n.id)}, probe.Log...)
return probe, err
}