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

use both job and type query on scaling policy list endpoint #9312

Merged
merged 2 commits into from
Nov 11, 2020

Conversation

cgbaker
Copy link
Contributor

@cgbaker cgbaker commented Nov 10, 2020

the /v1/scaling/policies list endpoint allows filtering by ?job and ?type. unfortunately, the code path for job ignored the type query. this PR remedies this.

unsurprisingly, there weren't any tests protecting this behavior, so those are added as well.

resolves #9227

@cgbaker cgbaker requested review from shoenig and krishicks and removed request for lgfa29 November 11, 2020 16:27
Copy link
Member

@shoenig shoenig left a comment

Choose a reason for hiding this comment

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

LGTM!

if !ok {
return true
}
return policyType != p.Type
Copy link
Contributor

@krishicks krishicks Nov 11, 2020

Choose a reason for hiding this comment

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

I think my only comment about this is that it seems like this check could be moved into ScalingPoliciesByJobTxn, where the new policyType string would be passed through to it.

Looking at ScalingPoliciesByJobTxn, it already does the same kind of type assertion we see here, so it happening again (specifically the !ok part, which I think is inconceivable) makes me want a single filter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, maybe 50/50? this short-circuits the filter on the outside of the loop when policyType == "", as opposed to doing it on every filter operation. merging them avoids duplicate cast assertion checks.

@cgbaker cgbaker merged commit 801911f into master Nov 11, 2020
@cgbaker cgbaker deleted the b-9227-scaling-policy-filtering branch November 11, 2020 18:04
@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 11, 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.

Scaling policy list filter with job and type ignores type
3 participants