Skip to content

Commit

Permalink
replace pod name when create ip crd
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Apr 6, 2022
1 parent f0bb276 commit aa7c3b8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,9 @@ func (c *Controller) handleAddPod(key string) error {
return err
}

if err := c.createOrUpdateCrdIPs(pod.Name, ipStr, mac, subnet.Name, pod.Namespace, pod.Spec.NodeName, podNet.ProviderName); err != nil {
klog.Errorf("failed to create IP %s.%s: %v", pod.Name, pod.Namespace, err)
podName := c.getNameByPod(pod)
if err := c.createOrUpdateCrdIPs(podName, ipStr, mac, subnet.Name, pod.Namespace, pod.Spec.NodeName, podNet.ProviderName); err != nil {
klog.Errorf("failed to create IP %s.%s: %v", podName, pod.Namespace, err)
}

if podNet.Type != providerTypeIPAM {
Expand All @@ -507,7 +508,6 @@ func (c *Controller) handleAddPod(key string) error {
}
securityGroupAnnotation := pod.Annotations[fmt.Sprintf(util.SecurityGroupAnnotationTemplate, podNet.ProviderName)]

podName := c.getNameByPod(pod)
portName := ovs.PodNameToPortName(podName, namespace, podNet.ProviderName)
if err := c.ovnClient.CreatePort(subnet.Name, portName, ipStr, subnet.Spec.CIDRBlock, mac, podName, pod.Namespace, portSecurity, securityGroupAnnotation); err != nil {
c.recorder.Eventf(pod, v1.EventTypeWarning, "CreateOVNPortFailed", err.Error())
Expand Down

0 comments on commit aa7c3b8

Please sign in to comment.