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

chore: Factor minValues requirements checking into the InstanceTypes methods #1246

Merged
merged 1 commit into from
May 16, 2024

Conversation

jonathan-innis
Copy link
Member

@jonathan-innis jonathan-innis commented May 12, 2024

Fixes #N/A

Description

This refactors the minValues code to be reusable by other places were instance types are used and truncated (like in aws/karpenter-provider-aws#6182). It also clarifies some of the usages and checking of minValues.

How was this change tested?

make presubmit

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 12, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jonathan-innis

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 12, 2024
@jonathan-innis jonathan-innis force-pushed the factor-min-values branch 17 times, most recently from 86ae394 to 92f03ef Compare May 12, 2024 04:50
@coveralls
Copy link

coveralls commented May 12, 2024

Pull Request Test Coverage Report for Build 9106406205

Details

  • 75 of 80 (93.75%) changed or added relevant lines in 6 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.03%) to 78.466%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/cloudprovider/types.go 33 34 97.06%
pkg/controllers/disruption/consolidation.go 16 20 80.0%
Files with Coverage Reduction New Missed Lines %
pkg/scheduling/requirements.go 2 97.98%
Totals Coverage Status
Change from base Build 9099680257: -0.03%
Covered Lines: 8264
Relevant Lines: 10532

💛 - Coveralls

pkg/cloudprovider/types.go Outdated Show resolved Hide resolved
@@ -136,8 +136,8 @@ func (m *MultiNodeConsolidation) firstNConsolidationOption(ctx context.Context,
// required
replacementHasValidInstanceTypes := false
if cmd.Action() == ReplaceAction {
cmd.replacements[0].InstanceTypeOptions = filterOutSameType(cmd.replacements[0], candidatesToConsolidate)
replacementHasValidInstanceTypes = len(cmd.replacements[0].InstanceTypeOptions) > 0
cmd.replacements[0].InstanceTypeOptions, err = filterOutSameType(cmd.replacements[0], candidatesToConsolidate)
Copy link
Member

Choose a reason for hiding this comment

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

Do we ever expect this error to be non-nil since min values is still already validated in compute consolidation? It doesn't hurt to have this check, but if there is a new non-nil scenario, I'm wondering if we should still silently fail here.

Copy link
Member Author

@jonathan-innis jonathan-innis May 16, 2024

Choose a reason for hiding this comment

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

It could definitely be non-nil. If we filter out the same type and this breaks the minValues requirement, then we should fail. Also, conceptually, I'd like to keep the semantic with this to be: "when we filter we can fail if our constraints aren't maintained. An error indicates that our constraints weren't maintained."

Copy link
Member

Choose a reason for hiding this comment

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

Got it, makes sense to me 👍 When I was reading the original implementation I missed that filterByPriceWithMinValues would return an empty slice when violated so I thought this was a new error check.

@jonathan-innis jonathan-innis marked this pull request as ready for review May 16, 2024 04:20
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 16, 2024
@k8s-ci-robot k8s-ci-robot requested a review from tallaxes May 16, 2024 04:20
@jmdeal
Copy link
Member

jmdeal commented May 16, 2024

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 16, 2024
@k8s-ci-robot k8s-ci-robot merged commit 0e67812 into kubernetes-sigs:main May 16, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants