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

better error handling around Scaling->Max #8360

Merged
merged 5 commits into from
Jul 6, 2020

Conversation

cgbaker
Copy link
Contributor

@cgbaker cgbaker commented Jul 4, 2020

  • made api.Scaling.Max a pointer, so we can detect (and complain) when it is neglected
  • added checks to HCL parsing that it is present
  • when Scaling.Max is absent/invalid, don't return extraneous error messages during validation
  • tweak to multiregion handling to ensure that the count is valid on the interpolated regional jobs

we don't do validation on the api objects, just on the structs objects on the other side of the RPC call. therefore, as a hack that i'm not entirely happy with, when api.ScalingPolicy.Max is missing, i set an invalid value for structs.ScalingPolicy.Max (I don't want this to be a pointer), and then respond during validation with a catch-all error message.

also updated website to document Group->Count default value

@tgross , does https://github.com/hashicorp/nomad/pull/8360/files#diff-396d9428285e4245041a3d0b15546d5dR5963 look okay? i did a local multiregion test and everything behaved.

resolves #8355

cgbaker added 3 commits July 4, 2020 18:33
…messages

* made api.Scaling.Max a pointer, so we can detect (and complain) when it is neglected
* added checks to HCL parsing that it is present
* when Scaling.Max is absent/invalid, don't return extraneous error messages during validation
* tweak to multiregion handling to ensure that the count is valid on the interpolated regional jobs

resolves #8355
@cgbaker cgbaker requested review from jrasell, lgfa29 and shoenig and removed request for lgfa29 and jrasell July 4, 2020 19:10
@cgbaker cgbaker added this to the 0.12.0 milestone Jul 4, 2020
@@ -1345,7 +1345,7 @@ func TestParse(t *testing.T) {
Name: helper.StringToPtr("group"),
Scaling: &api.ScalingPolicy{
Min: nil,
Max: 0,
Max: helper.Int64ToPtr(10),
Copy link
Member

Choose a reason for hiding this comment

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

Intentionally changed from 0 to 10?

- `count` `(int)` - Specifies the number of instances that should be running
under for this group. This value must be non-negative. This defaults to the
`min` value specified in the [`scaling`](/docs/job-specification/scaling)
block, if present; otherwise, this defaults to `1`.
Copy link
Member

Choose a reason for hiding this comment

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

Should max be documented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol. yes. thanks 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uh, actually, i'll leave it alone. i was just trying to update the default here, not the mechanics of count

@tgross
Copy link
Member

tgross commented Jul 6, 2020

@tgross , does https://github.com/hashicorp/nomad/pull/8360/files#diff-396d9428285e4245041a3d0b15546d5dR5963 look okay? i did a local multiregion test and everything behaved.

LGTM

@cgbaker cgbaker merged commit 1fbe58f into master Jul 6, 2020
@cgbaker cgbaker deleted the b-8355-better-scaling-validation branch July 6, 2020 16:32
@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 Dec 31, 2022
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.

confusing defaults when enabling scaling stanza
3 participants