-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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: aggregate all the errors when the shared certs are validated #106042
Conversation
/sig cluster-lifecycle |
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, i will have a look tomorrow.
@@ -29,6 +29,7 @@ import ( | |||
"k8s.io/client-go/util/keyutil" | |||
"k8s.io/klog/v2" | |||
|
|||
utilerrors "k8s.io/apimachinery/pkg/util/errors" |
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.
this should be in the group above:
"k8s.io/client-go/util/keyutil"
"k8s.io/klog/v2"
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.
Done
} | ||
} | ||
|
||
if len(errs) != 0 { | ||
return false, utilerrors.NewAggregate(errs) |
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.
this is worth updating the unit tests to check how many errors were returned exactly:
https://github.com/kubernetes/kubernetes/blob/e363bbdddb17100e6cc41a36c83caac49ea4c3c7/cmd/kubeadm/app/phases/certs/certs_test.go#L378
expectedError bool
-> expectedErrors int
len(err) != len(expectedErrors) { unit test failed, print err }
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.
Just found that testcase "missing etcd/ca.crt" is not wrote correctly, it is just a copy of "missing front-proxy.crt". 😄
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.
Done
/triage accepted LGTM, other than the two comments above. |
case test.expectedError && err == nil: | ||
case err != nil: | ||
if agg, ok := err.(utilerrors.Aggregate); ok && len(agg.Errors()) != test.expectedErrors { | ||
t.Errorf("SharedCertificateExists didn't failed with expected error numbers") |
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.
t.Errorf("SharedCertificateExists didn't failed with expected error numbers") | |
t.Errorf("SharedCertificateExists didn't fail with the expected number of errors, expected: %v, got: %v", ....) |
we should also include the error numbers.
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.
Good catch! Done
if agg, ok := err.(utilerrors.Aggregate); ok && len(agg.Errors()) != test.expectedErrors { | ||
t.Errorf("SharedCertificateExists didn't failed with expected error numbers") | ||
} | ||
case err == nil && test.expectedErrors != 0: | ||
t.Errorf("error SharedCertificateExists didn't failed when expected") |
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.
t.Errorf("error SharedCertificateExists didn't failed when expected") | |
t.Errorf("error SharedCertificateExists didn't fail when expected") |
^ there is also a typo in the old code
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.
:)
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.
found a couple of typos.
please keep the commits squashed to 1.
/retitle kubeadm: aggregate all the errors when the shared certs are validated |
Instead of the individual error and return, it's better to aggregate all the errors so that we can fix them all at once. Take the chance to fix some comments, since kubeadm are not checking that the certs are equal across controlplane. Signed-off-by: Dave Chen <dave.chen@arm.com>
@neolit123 thanks for the review, could you pls take a look again? |
/retest |
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
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chendave, neolit123 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 |
Instead of the individual error and return, it's better to aggregate all the errors so that we can fix them all at once.
Take the chance to fix some comments, since kubeadm are not checking that the certs are equal across controlplane.
Signed-off-by: Dave Chen dave.chen@arm.com
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: