Skip to content

Commit

Permalink
fix assignment to entry in nil map (#3925)
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <zhangbingbing2_yewu@cmss.chinamobile.com>
Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
  • Loading branch information
zhangzujian committed May 21, 2024
1 parent 623c628 commit f69625d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,18 @@ func (c *Controller) enqueueUpdateSubnet(oldObj, newObj interface{}) {
}

if oldSubnet.Spec.Vpc != newSubnet.Spec.Vpc &&
!(oldSubnet.Spec.Vpc == "" && newSubnet.Spec.Vpc == c.config.ClusterRouter ||
oldSubnet.Spec.Vpc == c.config.ClusterRouter && newSubnet.Spec.Vpc == "") {
!(oldSubnet.Spec.Vpc == "" && newSubnet.Spec.Vpc == c.config.ClusterRouter || oldSubnet.Spec.Vpc == c.config.ClusterRouter && newSubnet.Spec.Vpc == "") {

if newSubnet.Annotations == nil {
newSubnet.Annotations = make(map[string]string)
}

if oldSubnet.Spec.Vpc == "" {
newSubnet.Annotations[util.VpcLastName] = c.config.ClusterRouter
} else {
newSubnet.Annotations[util.VpcLastName] = oldSubnet.Spec.Vpc
}

c.updateVpcStatusQueue.Add(oldSubnet.Spec.Vpc)
}

Expand Down

0 comments on commit f69625d

Please sign in to comment.