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

kubeadm: aggregate all the errors when the shared certs are validated #106042

Merged
merged 1 commit into from
Nov 4, 2021

Conversation

chendave
Copy link
Member

@chendave chendave commented Nov 1, 2021

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?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 1, 2021
@chendave
Copy link
Member Author

chendave commented Nov 1, 2021

/sig cluster-lifecycle

Copy link
Member

@neolit123 neolit123 left a 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"
Copy link
Member

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"

Copy link
Member Author

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)
Copy link
Member

@neolit123 neolit123 Nov 2, 2021

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 }

Copy link
Member Author

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". 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@neolit123
Copy link
Member

/triage accepted
/priority backlog

LGTM, other than the two comments above.

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/backlog Higher priority than priority/awaiting-more-evidence. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 2, 2021
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")
Copy link
Member

@neolit123 neolit123 Nov 3, 2021

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Member Author

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")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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

Copy link
Member Author

Choose a reason for hiding this comment

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

:)

Copy link
Member

@neolit123 neolit123 left a 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.

@neolit123
Copy link
Member

/retitle kubeadm: aggregate all the errors when the shared certs are validated

@k8s-ci-robot k8s-ci-robot changed the title Aggregate all the errors when the shared certs are validated kubeadm: aggregate all the errors when the shared certs are validated Nov 3, 2021
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>
@chendave
Copy link
Member Author

chendave commented Nov 4, 2021

@neolit123 thanks for the review, could you pls take a look again?

@chendave
Copy link
Member Author

chendave commented Nov 4, 2021

/retest

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

thanks
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 4, 2021
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 4, 2021
@k8s-ci-robot k8s-ci-robot merged commit 6d30c96 into kubernetes:master Nov 4, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Nov 4, 2021
@chendave chendave deleted the aggregate branch November 5, 2021 01:53
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. area/kubeadm cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note-none Denotes a PR that doesn't merit a release note. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants