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

feat: add logging to agent to track usage [DET-3878] #1110

Merged
merged 1 commit into from
Aug 18, 2020
Merged
Changes from all commits
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
8 changes: 8 additions & 0 deletions master/internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func (a *agent) Receive(ctx *actor.Context) error {
ctx.Ask(a.socket, ws.WriteMessage{Message: aproto.AgentMessage{SignalContainer: &msg}})
case sproto.StartTaskOnAgent:
start := ws.WriteMessage{Message: aproto.AgentMessage{StartContainer: &msg.StartContainer}}
ctx.Log().Infof("starting container id: %s slots: %d task handler: %s",
msg.StartContainer.Container.ID, len(msg.StartContainer.Container.Devices),
msg.Task.Address())

ctx.Ask(a.socket, start)
ctx.Tell(a.slots, msg.StartContainer)
a.containers[msg.Container.ID] = msg.Task
Expand Down Expand Up @@ -94,6 +98,7 @@ func (a *agent) Receive(ctx *actor.Context) error {

return errors.Wrapf(msg.Error, "child failed: %s", msg.Child.Address())
case actor.PostStop:
ctx.Log().Infof("agent disconnected")
for cid := range a.containers {
stopped := aproto.ContainerError(
aproto.AgentFailed, errors.New("agent failed while container was running"))
Expand Down Expand Up @@ -125,6 +130,8 @@ func (a *agent) handleIncomingWSMessage(ctx *actor.Context, msg aproto.MasterMes
switch {
case msg.AgentStarted != nil:
telemetry.ReportAgentConnected(ctx.Self().System(), a.uuid, msg.AgentStarted.Devices)
ctx.Log().Infof("agent connected ip: %v slots: %d",
a.address, len(msg.AgentStarted.Devices))

ctx.Tell(a.cluster, sproto.AddAgent{Agent: ctx.Self(), Label: msg.AgentStarted.Label})
ctx.Tell(a.slots, *msg.AgentStarted)
Expand Down Expand Up @@ -170,6 +177,7 @@ func (a *agent) containerStateChanged(ctx *actor.Context, sc aproto.ContainerSta
ContainerStarted: sc.ContainerStarted,
})
case container.Terminated:
ctx.Log().Infof("stopped container id: %s", sc.Container.ID)
delete(a.containers, sc.Container.ID)

ctx.Tell(a.cluster, sproto.TaskTerminatedOnAgent{
Expand Down