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

Fix to previous EnsureAdminClusterRoleBindingImpl fix #122906

Merged
merged 1 commit into from
Jan 23, 2024

Conversation

danwinship
Copy link
Contributor

What type of PR is this?

/kind bug
/kind cleanup
/kind failing-test

What this PR does / why we need it:

Fix to #122893; The previous fix changed the behavior of EnsureAdminClusterRoleBindingImpl under the assumption that the unit test was correct and the real-world behavior was wrong, but in fact, the real-world behavior was already correct, and the unit test was expecting the wrong result because of the difference in behavior between real and fake clients.

Comparing the original state, the post-122893 state, and the new state with this commit:

  • If the Create() succeeds:
    • original: crbResult would contain the result of the Create (line 640), and so crbResult != nil would be true and we'd return adminClient, nil (line 672-673)
    • 122893: same
    • new: crbExists would be set to true (line 661), so crbExists would be true and we'd return adminClient, nil (line 669-670)
  • If the Create() fails with apierrors.IsForbidden()
    • original: crbResult would get set to nil (line 653), so crbResult != nil would be false (line 672) and we'd try the superAdminClient
    • 122893: same except crbClient gets set to nil on line 648
    • new: crbExists never gets set to true, so crbExists would be false on line 669 and we'd try the superAdminClient
  • If the Create() fails with apierrors.IsAlreadyExists()
    • original:
      • in CI, crbResult is nil, so the crbResult != nil check at line 672 fails so we fall through to maybe try with the superAdminClient, which will fail whether or not superAdminClient is set; This is not the correct behavior, but the "admin.conf: CRB already exists, use the admin.conf client" test had expectedError: true anyway! 🙁
      • in the real world, crbResult is an empty CRB object, so the crbResult != nil check at line 672 succeeds and we return the adminClient, which is what was supposed to happen
    • 122893: both in CI and in the real world, crbResult gets set to nil (line 648), so we fall through at line 671 rather than returning the adminClient. This caused kubeadm-kinder-upgrade-*-1-29-latest failed for existing ClusterRoleBinding kubeadm#3000
    • new: both in CI and in the real world, crbExists gets set to true (line 653), so the check at line 669 succeeds and we return the adminClient, fixing the bug
  • If the Create() fails with any other error and eventually times out:
    • original: crbResult is nil in CI and non-nil in the real world, but it doesn't matter because, we see that err != nil and return lastError (line 667-668)
    • 122893: crbResult is nil either way, but again, we return lastError before checking it
    • new: crbExists is fasl either way, but again, we return lastError before checking it

So I think this should be correct...

Which issue(s) this PR fixes:

Fixes kubernetes/kubeadm#3000

Does this PR introduce a user-facing change?

NONE

/assign @neolit123 @pacoxu

The previous fix changed the behavior of
EnsureAdminClusterRoleBindingImpl under the assumption that the unit
test was correct and the real-world behavior was wrong, but in fact,
the real-world behavior was already correct, and the unit test was
expecting the wrong result because of the difference in behavior
between real and fake clients.
@k8s-ci-robot k8s-ci-robot added the release-note-none Denotes a PR that doesn't merit a release note. label Jan 22, 2024
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jan 22, 2024
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. 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. labels Jan 22, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added 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 Jan 22, 2024
Copy link
Member

@pacoxu pacoxu left a comment

Choose a reason for hiding this comment

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

lgtm
The fix seems valid to me as well

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danwinship, pacoxu

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 Jan 22, 2024
@pacoxu
Copy link
Member

pacoxu commented Jan 22, 2024

The fix seems valid to me as well

#122901 is another way to fix it(not sure which is better)

@pacoxu
Copy link
Member

pacoxu commented Jan 23, 2024

/lgtm

To make the CI green.

/assign @neolit123 @SataQiu
to confirm later.

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

LGTM label has been added.

Git tree hash: 6ffb09c05032df0a7d48aa1623fd16480f23fd22

@k8s-ci-robot k8s-ci-robot merged commit 3aa8c59 into kubernetes:master Jan 23, 2024
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.30 milestone Jan 23, 2024
@danwinship danwinship deleted the kubeadm-kubeconfig-fix-2 branch January 23, 2024 13:01
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/bug Categorizes issue or PR as related to a bug. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubeadm-kinder-upgrade-*-1-29-latest failed for existing ClusterRoleBinding
5 participants