Merge pull request #67648 from xlgao-zju/fix-annotate-panic

Automatic merge from submit-queue (batch tested with PRs 65788, 67648, 67660). 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>.

[kubeadm] fix panic when node annotation is nil

**What this PR does / why we need it**:
kubeadm will panic, when the node annotation is nil.

**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 #

**Special notes for your reviewer**:
/assign @neolit123 

**Release note**:

```release-note
kubeadm:  Fix panic when node annotation is nil
```
pull/8/head
Kubernetes Submit Queue 2018-08-21 10:14:01 -07:00 committed by GitHub
commit 9b8f3f3cb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -36,5 +36,8 @@ func AnnotateCRISocket(client clientset.Interface, nodeName string, criSocket st
}
func annotateNodeWithCRISocket(n *v1.Node, criSocket string) {
if n.ObjectMeta.Annotations == nil {
n.ObjectMeta.Annotations = make(map[string]string)
}
n.ObjectMeta.Annotations[constants.AnnotationKubeadmCRISocket] = criSocket
}