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
Check kubeClient against nil for reconciler #86795
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tedyu The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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
This change sounds wise to me - returning an informative error message is definitely better than panicking :)
/retest |
/assign @jsafrane |
/test pull-kubernetes-e2e-gce-csi-serial |
In kubelet, the following controllers uses KubeClient
I think all of three could not work correctly if KubeClient is nil. Seems like only volumePluginMgr checks whether client is nil or not https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/volumemanager/volume_manager.go#L270 Maybe we should double check the logic around it. |
@jingxu97 |
@kubernetes/sig-storage-pr-reviews |
86181ce
to
5669bc3
Compare
@tedyu, one concern about kubelet standalone mode. I am not sure how it works in standalone mode? Desired_state_pupulator could not fetch any PVC/PV through kubeClient since it is nil? |
i am ok with current pr. maybe create an issue mentioning the kubeclient nil issue with those managers so we could at least document that things that are not working under standalone mode |
/assign @msau42 |
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.
Can we add unit tests that test the kubeclient nil case, so we can make sure that we don't regress in this area in the future?
@msau42
|
d6a9731
to
1cacf59
Compare
New changes are detected. LGTM label has been removed. |
/test pull-kubernetes-e2e-gce |
1cacf59
to
c93ed41
Compare
/test pull-kubernetes-e2e-gce |
@msau42 thanks |
c93ed41
to
9eff9cb
Compare
/test pull-kubernetes-kubemark-e2e-gce-big |
@msau42 |
@msau42 |
@@ -599,6 +599,10 @@ func (rc *reconciler) reconstructVolume(volume podVolume) (*reconstructedVolume, | |||
|
|||
// updateDevicePath gets the node status to retrieve volume device path information. | |||
func (rc *reconciler) updateDevicePath(volumesNeedUpdate map[v1.UniqueVolumeName]*reconstructedVolume) { | |||
if rc.kubeClient == nil { | |||
klog.Errorf("kubeClient is nil") |
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.
It would be better to add more context to this error message so we can search for the source more easily.
How common is this error in normal operation? Are we going to start flooding errors? cc @jingxu97 is this only called during reconstruction that happens once when kubelet starts?
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.
updateStates() is called by syncStates() which is called from reconciler#reconciliationLoopFunc() which is called from reconciler#Run()
This error shouldn't be common in normal operation.
kubeletPodsDir) | ||
rec := recon.(*reconciler) | ||
rec.kubeClient = nil | ||
rec.updateDevicePath(nil) |
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 isn't really testing the reconstruction path, but I guess we currently don't have any unit tests for reconstruction? @jingxu97 do you have any ideas?
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.
Yeah - trying to find good way to test it.
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.
@msau42
Can the test be added in a follow-on PR ?
@tedyu: PR needs rebase. 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. |
In favor of #88136 |
What type of PR is this?
/kind bug
What this PR does / why we need it:
See discussion over #86722
When Kubelet is constructed, kubeDeps.KubeClient may be nil.
We should check kubeClient against nil in reconciler#updateDevicePath.
Which issue(s) this PR fixes:
Fixes #86722
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: