Skip to content

Commit b62f472

Browse files
committed
use existing node switch cidr instead of the configured one (#2359)
1 parent 902b9a3 commit b62f472

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/controller/init.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ func (c *Controller) initDefaultLogicalSwitch() error {
154154
func (c *Controller) initNodeSwitch() error {
155155
subnet, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Get(context.Background(), c.config.NodeSwitch, metav1.GetOptions{})
156156
if err == nil {
157-
if subnet != nil && util.CheckProtocol(c.config.NodeSwitchCIDR) != util.CheckProtocol(subnet.Spec.CIDRBlock) {
157+
if util.CheckProtocol(c.config.NodeSwitchCIDR) == kubeovnv1.ProtocolDual && util.CheckProtocol(subnet.Spec.CIDRBlock) != kubeovnv1.ProtocolDual {
158158
// single-stack upgrade to dual-stack
159-
if util.CheckProtocol(c.config.NodeSwitchCIDR) == kubeovnv1.ProtocolDual {
160-
subnet := subnet.DeepCopy()
161-
subnet.Spec.CIDRBlock = c.config.NodeSwitchCIDR
162-
if err := formatSubnet(subnet, c); err != nil {
163-
klog.Errorf("init format subnet %s failed: %v", c.config.NodeSwitch, err)
164-
return err
165-
}
159+
subnet := subnet.DeepCopy()
160+
subnet.Spec.CIDRBlock = c.config.NodeSwitchCIDR
161+
if err := formatSubnet(subnet, c); err != nil {
162+
klog.Errorf("init format subnet %s failed: %v", c.config.NodeSwitch, err)
163+
return err
166164
}
165+
} else {
166+
c.config.NodeSwitchCIDR = subnet.Spec.CIDRBlock
167167
}
168168
return nil
169169
}

0 commit comments

Comments
 (0)