From f86760db3c48794e4b8d39daf87f8af4d95560b2 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Fri, 7 Jul 2017 16:49:08 -0700 Subject: [PATCH] Basic logs --- nomad/structs/structs.go | 5 +++++ scheduler/generic_sched.go | 1 + scheduler/reconcile.go | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 9657a6c0e..37849d0bc 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -5039,6 +5039,11 @@ type DesiredUpdates struct { Canary uint64 } +func (d *DesiredUpdates) GoString() string { + return fmt.Sprintf("(place %d) (inplace %d) (destructive %d) (stop %d) (migrate %d) (ignore %d) (canary %d)", + d.Place, d.InPlaceUpdate, d.DestructiveUpdate, d.Stop, d.Migrate, d.Ignore, d.Canary) +} + // msgpackHandle is a shared handle for encoding/decoding of structs var MsgpackHandle = func() *codec.MsgpackHandle { h := &codec.MsgpackHandle{RawToString: true} diff --git a/scheduler/generic_sched.go b/scheduler/generic_sched.go index d6ee9deb3..77ce3ed83 100644 --- a/scheduler/generic_sched.go +++ b/scheduler/generic_sched.go @@ -389,6 +389,7 @@ func (s *GenericScheduler) computeJobAllocs() error { genericAllocUpdateFn(s.ctx, s.stack, s.eval.ID), s.batch, s.eval.JobID, s.job, s.deployment, allocs, tainted) results := reconciler.Compute() + s.logger.Printf("[DEBUG] sched: %#v: %#v", s.eval, results) if s.eval.AnnotatePlan { s.plan.Annotations = &structs.PlanAnnotations{ diff --git a/scheduler/reconcile.go b/scheduler/reconcile.go index d01427395..ebb0381fc 100644 --- a/scheduler/reconcile.go +++ b/scheduler/reconcile.go @@ -1,6 +1,7 @@ package scheduler import ( + "fmt" "log" "time" @@ -107,6 +108,26 @@ type allocStopResult struct { statusDescription string } +func (r *reconcileResults) GoString() string { + base := fmt.Sprintf("Total changes: (place %d) (update %d) (stop %d)", + len(r.place), len(r.inplaceUpdate), len(r.stop)) + + if r.deployment != nil { + base += fmt.Sprintf("\nCreated Deployment: %q", r.deployment.ID) + } + for _, u := range r.deploymentUpdates { + base += fmt.Sprintf("\nDeployment Update for ID %q: Status %q; Description %q", + u.DeploymentID, u.Status, u.StatusDescription) + } + if r.followupEvalWait != 0 { + base += fmt.Sprintf("\nFollowup Eval in %v", r.followupEvalWait) + } + for tg, u := range r.desiredTGUpdates { + base += fmt.Sprintf("\nDesired Changes for %q: %#v", tg, u) + } + return base +} + // Changes returns the number of total changes func (r *reconcileResults) Changes() int { return len(r.place) + len(r.inplaceUpdate) + len(r.stop)