Skip to content

Commit

Permalink
Fix cni panic due to pod.Annotations is a nil map (#1974)
Browse files Browse the repository at this point in the history
Co-authored-by: Relk Li <relk@maicoin.com>
  • Loading branch information
Downager and Downager authored Apr 18, 2022
1 parent c22f72e commit db1481f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/ipamd/ipamd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,9 @@ func (c *IPAMContext) AnnotatePod(podName, podNamespace, key, val string) error
}

newPod := pod.DeepCopy()
if newPod.Annotations == nil {
newPod.Annotations = make(map[string]string)
}
newPod.Annotations[key] = val
if err = c.rawK8SClient.Patch(ctx, newPod, client.MergeFrom(pod)); err != nil {
log.Errorf("Failed to annotate %s the pod with %s, error %v", key, val, err)
Expand Down

0 comments on commit db1481f

Please sign in to comment.