Unverified Commit 7d759ba0 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #54928 from fisherxu/kubeletfix

Automatic merge from submit-queue (batch tested with PRs 55050, 53464, 54936, 55028, 54928). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix panic in kubelet because of uninitialized map **What this PR does / why we need it**: Initialized the uninitialized map in kubelet **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes [#54927](https://github.com/kubernetes/kubernetes/issues/54927) **Special notes for your reviewer**: The default value of --enable-controller-attach-detach is true, map will be initialized like: ``` if kl.enableControllerAttachDetach { if node.Annotations == nil { node.Annotations = make(map[string]string) } ... } ``` if set --enable-controller-attach-detach to false, map will have no Initialized. **Release note**: ```release-note NONE ```
parents b448dfa0 04b876e6
......@@ -445,6 +445,9 @@ func (kl *Kubelet) setNodeAddress(node *v1.Node) error {
if kl.externalCloudProvider {
if kl.nodeIP != nil {
if node.ObjectMeta.Annotations == nil {
node.ObjectMeta.Annotations = make(map[string]string)
}
node.ObjectMeta.Annotations[kubeletapis.AnnotationProvidedIPAddr] = kl.nodeIP.String()
}
// We rely on the external cloud provider to supply the addresses.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment