Skip to content
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

Merged
merged 30 commits into from
Mar 24, 2020
Merged

Scaling API changes #7409

merged 30 commits into from
Mar 24, 2020

Conversation

cgbaker
Copy link
Contributor

@cgbaker cgbaker commented Mar 21, 2020

partially completes #7394

Includes:

  • new Scaling block on TaskGroup
  • Enforce policy min/max during job registration Enforce scaling.[min,max] when scheduling #7413
  • new RPCs:
    • Job.Scale: short-cut for a Job., will be expanded later to also persist a scaling event
    • Job.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 capability
    • Scaling.ListPolicies: list the autoscaling polices in a namespace
    • Scaling.GetPolicy: get a specific autoscaling policy
  • ACL support and testing for the new RPC endpoints ACL support for scaling APIs #7418
  • HTTP endpoints and API support for the above RPC endpoints
  • new state store table, a view of the scaling policies contained in jobs
  • lifecycle to populate the scaling policy table during job lifecycle

Currently missing (will address after PR):

  • CLI support
  • documentation in website

cgbaker added 4 commits March 24, 2020 13:57
… 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
@cgbaker cgbaker force-pushed the scaling-api branch 2 times, most recently from b0f5ed9 to 906b14b Compare March 24, 2020 14:13
cgbaker added 6 commits March 24, 2020 14:38
- 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
@cgbaker cgbaker marked this pull request as ready for review March 24, 2020 14:46
Copy link
Member

@jrasell jrasell left a 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!

🎈 🎉 🎈

@cgbaker
Copy link
Contributor Author

cgbaker commented Mar 24, 2020

two tests failures are both flaky tests, merging now. will put Changelog in another PR

@cgbaker cgbaker merged commit 33360be into master Mar 24, 2020
@cgbaker cgbaker deleted the scaling-api branch March 24, 2020 16:02
Copy link
Contributor

@lgfa29 lgfa29 left a 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"
Copy link
Contributor

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)

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require.NotNil(tg.Count)
require.NotNil(tg.Scaling.Min)
require.Equal(int64(5), *tg.Scaling.Min)
require.Equal(*tg.Scaling.Min, int64(*tg.Count))
Copy link
Contributor

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
Copy link
Contributor

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 ints

@@ -0,0 +1,14 @@
job "elastic" {
group "group" {
scaling {
Copy link
Contributor

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),
Copy link
Contributor

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Min and Max

@github-actions
Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants