update switchq to calling provisioner, fixed a few bugs found while testing at on.labs
Change-Id: I2367669aa54f680b98ff0cbbc8d41a49fb7e7a79
diff --git a/provisioner/dispatcher.go b/provisioner/dispatcher.go
index fb16458..bf6ebbf 100644
--- a/provisioner/dispatcher.go
+++ b/provisioner/dispatcher.go
@@ -20,10 +20,10 @@
}
type StatusMsg struct {
- Request *WorkRequest
- Worker int
- Status TaskStatus
- Message string
+ Request *WorkRequest `json:"request"`
+ Worker int `json:"worker"`
+ Status TaskStatus `json:"status"`
+ Message string `json:"message"`
}
func NewWorker(id int, workerQueue chan chan WorkRequest, statusChan chan StatusMsg) Worker {
@@ -49,7 +49,7 @@
case work := <-w.Work:
// Receive a work request.
w.StatusChan <- StatusMsg{&work, w.ID, Running, ""}
- log.Printf("RUN: %s %s %s %s %s %s",
+ log.Printf("[debug] RUN: %s %s %s %s %s %s",
work.Script, work.Info.Id, work.Info.Name,
work.Info.Ip, work.Info.Mac, work.Role)
err := exec.Command(work.Script, work.Info.Id, work.Info.Name,
@@ -117,12 +117,12 @@
for {
select {
case work := <-d.WorkQueue:
- log.Println("Received work requeust")
+ log.Println("[debug] Received work requeust")
go func() {
d.StatusChan <- StatusMsg{&work, -1, Pending, ""}
worker := <-d.WorkerQueue
- log.Println("Dispatching work request")
+ log.Println("[debug] Dispatching work request")
worker <- work
}()
case update := <-d.StatusChan: