-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Scaling API changes #7409
Scaling API changes #7409
Conversation
…of scaling request
updating job scaling endpoints to match RFC, cleaning up the API object as well
… tg.Count, tg.Scaling.Min/Max are well-defined with reasonable defaults. - tg.Count defaults to tg.Scaling.Min if present (falls back on previous default of 1 if Scaling is absent) - Validate() enforces tg.Scaling.Min <= tg.Count <= tg.Scaling.Max modification in ApiScalingPolicyToStructs, api.TaskGroup.Validate so that defaults are handled for TaskGroup.Count and
b0f5ed9
to
906b14b
Compare
- read-job-scaling - scale-job - list-scaling-policies - read-scaling-policy updated the read and right policy dispositions, added the new autoscaler disposition
added ACL protection in Job.Scale in Job.Scale, only perform a Job.Register if the Count was non-nil
that we were throwing away .Min if provided
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test failures look very unrelated.
I have checked this out locally, built and tested against the autoscaler with excellent results!
🎈 🎉 🎈
two tests failures are both flaky tests, merging now. will put Changelog in another PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments, but LGTM. Awesome work!
PolicyRead = "read" | ||
PolicyList = "list" | ||
PolicyWrite = "write" | ||
PolicyAutoscaler = "autoscaler" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of bikeshedding here, but the other policies are named as verbs, so should this be
PolicyAutoscale = "autoscale"
?
resp, _, err := jobs.Info(*job.ID, nil) | ||
require.NoError(err) | ||
require.Equal(*resp.TaskGroups[0].Count, newCount) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a test for count
as nil
since it's a unique use case and to make sure this behaviour doesn't changed by accident.
m = int64(*tg.Count) | ||
} else { | ||
// this should not be at this point, but safeguard here just in case | ||
m = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use m = 1
as safeguard to match https://github.com/hashicorp/nomad/pull/7409/files#diff-6765437a29d3652967c3a164dc7f5752R450?
require.NotNil(tg.Count) | ||
require.NotNil(tg.Scaling.Min) | ||
require.Equal(int64(5), *tg.Scaling.Min) | ||
require.Equal(*tg.Scaling.Min, int64(*tg.Count)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a sanity check where Scaling.Min
and Count
are both set to different values and then check if those values are kept
@@ -26,6 +26,11 @@ func uint64ToPtr(u uint64) *uint64 { | |||
return &u | |||
} | |||
|
|||
// int64ToPtr returns the pointer to a int64 | |||
func int64ToPtr(u int64) *int64 { | |||
return &u |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More bikeshedding: use i
instead of u
since this is acting on int
s
@@ -0,0 +1,14 @@ | |||
job "elastic" { | |||
group "group" { | |||
scaling { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this fixture have min
and max
as well?
"val": 5, | ||
"f": .1, | ||
}, | ||
Enabled: helper.BoolToPtr(false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate min
and max
as well.
Policy: map[string]interface{}{ | ||
"a": "b", | ||
}, | ||
Enabled: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Min
and Max
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
partially completes #7394
Includes:
Scaling
block onTaskGroup
scaling.[min,max]
when scheduling #7413Job.Scale
: short-cut for a Job., will be expanded later to also persist a scaling eventJob.ScaleStatus
: get the current counts for a job's task group. similar to Job.Summary, but with more autoscaler-specific information and an appropriate ACL capabilityScaling.ListPolicies
: list the autoscaling polices in a namespaceScaling.GetPolicy
: get a specific autoscaling policyCurrently missing (will address after PR):