Skip to content

Commit

Permalink
Merge pull request #2809 from hashicorp/f-scheduling-logs
Browse files Browse the repository at this point in the history
Basic logs from reconciler
  • Loading branch information
dadgar authored Jul 7, 2017
2 parents 0ce0973 + 5001faf commit e280205
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions scheduler/generic_sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
21 changes: 21 additions & 0 deletions scheduler/reconcile.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package scheduler

import (
"fmt"
"log"
"time"

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e280205

Please sign in to comment.