From c51c5a0436ed367388b720a5599a803fded1640f Mon Sep 17 00:00:00 2001 From: Chris Baker <1675087+cgbaker@users.noreply.github.com> Date: Mon, 15 Jun 2020 19:49:22 +0000 Subject: [PATCH] core: update Job.Scale to save the previous job count in the ScalingEvent --- nomad/job_endpoint.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/nomad/job_endpoint.go b/nomad/job_endpoint.go index 7cf31aef9..5f60b842f 100644 --- a/nomad/job_endpoint.go +++ b/nomad/job_endpoint.go @@ -933,6 +933,7 @@ func (j *Job) Scale(args *structs.JobScaleRequest, reply *structs.JobRegisterRes // If the count is present, commit the job update via Raft // for now, we'll do this even if count didn't change + prevCount := found.Count if args.Count != nil { truncCount := int(*args.Count) if int64(truncCount) != *args.Count { @@ -997,11 +998,12 @@ func (j *Job) Scale(args *structs.JobScaleRequest, reply *structs.JobRegisterRes JobID: job.ID, TaskGroup: groupName, ScalingEvent: &structs.ScalingEvent{ - Time: now, - Count: args.Count, - Message: args.Message, - Error: args.Error, - Meta: args.Meta, + Time: now, + PreviousCount: int64(prevCount), + Count: args.Count, + Message: args.Message, + Error: args.Error, + Meta: args.Meta, }, } if reply.EvalID != "" {