-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
kubeadm: check required number of CPUs on master #70048
kubeadm: check required number of CPUs on master #70048
Conversation
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.
thanks @bart0sh
added a couple of minor comments, LGTM
@@ -777,3 +777,26 @@ func TestImagePullCheck(t *testing.T) { | |||
t.Fatalf("expected 2 errors but got %d: %q", len(errors), errors) | |||
} | |||
} | |||
|
|||
func TestNumCPUCheck(t *testing.T) { | |||
// Expected success |
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.
let's use a table of the test cases like var tests = []struct {...
line 690.
cmd/kubeadm/app/preflight/checks.go
Outdated
func (ncc NumCPUCheck) Check() (warnings, errors []error) { | ||
numCPU := runtime.NumCPU() | ||
if numCPU < ncc.NumCPU { | ||
errors = append(errors, fmt.Errorf("number of CPUs %d is less than required %d", numCPU, ncc.NumCPU)) |
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.
number of CPUs %d is less than required %d
-->
the number of available CPUs %d is less than the required %d
db07f1b
to
198f914
Compare
@neolit123 Thanks for the review! Updated. |
cmd/kubeadm/app/preflight/checks.go
Outdated
func (ncc NumCPUCheck) Check() (warnings, errors []error) { | ||
numCPU := runtime.NumCPU() | ||
if numCPU < ncc.NumCPU { | ||
errors = append(errors, fmt.Errorf("The number of available CPUs %d is less than the required %d", numCPU, ncc.NumCPU)) |
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.
contents of Errorf() should start will lowercase.
{int(^uint(0) >> 1), 1, 0}, | ||
} | ||
|
||
for _, rt := range tests { |
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.
FYI we gravitate towards using subtests with t.Run
for new code, but not critical here.
numWarnings int | ||
}{ | ||
{0, 0, 0}, | ||
{int(^uint(0) >> 1), 1, 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.
instead of 2^31-1
we might as well hardcode a very big int like 99999999, for better readability?
and so that we don't include math
.
also having test names is a plus.
Implemented preflight check to ensure that number of CPUs on the master node is not less than required.
198f914
to
d230b24
Compare
/test pull-kubernetes-e2e-kops-aws |
/retest |
one argument here would be if we want it as a warning or an error. /lgtm |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bart0sh, timothysc 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 |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Implemented preflight check to ensure that number of CPUs
on the master node is not less than required.
Does this PR introduce a user-facing change?: