Skip to content

Commit

Permalink
fix the duplicate call about strings.Split
Browse files Browse the repository at this point in the history
  • Loading branch information
pengbinbin1 committed Nov 19, 2021
1 parent 712e6f4 commit 60e896f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,8 @@ func isStatefulSetPodToDel(c kubernetes.Interface, pod *v1.Pod, statefulSetName
}

// down scale statefulset
numIndex := len(strings.Split(pod.Name, "-")) - 1
numStr := strings.Split(pod.Name, "-")[numIndex]
tempStrs := strings.Split(pod.Name, "-")
numStr := tempStrs[len(tempStrs)-1]
index, err := strconv.ParseInt(numStr, 10, 0)
if err != nil {
klog.Errorf("failed to parse %s to int", numStr)
Expand Down Expand Up @@ -1118,8 +1118,8 @@ func (c *Controller) acquireAddress(pod *v1.Pod, podNet *kubeovnNet) (string, st
}
}
} else {
numIndex := len(strings.Split(pod.Name, "-")) - 1
numStr := strings.Split(pod.Name, "-")[numIndex]
tempStrs := strings.Split(pod.Name, "-")
numStr := tempStrs[len(tempStrs)-1]
index, _ := strconv.Atoi(numStr)
if index < len(ipPool) {
return c.acquireStaticAddress(key, nicName, ipPool[index], macStr, podNet.Subnet.Name, podNet.AllowLiveMigration)
Expand Down

0 comments on commit 60e896f

Please sign in to comment.