mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
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 ```
This commit is contained in:
commit
7d759ba0c9
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user