Skip to content

Commit

Permalink
update upgrade for ovn-default and join subnet
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Feb 24, 2021
1 parent f8bda10 commit 215c8f4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,14 @@ func (c *Controller) InitDefaultVpc() error {
func (c *Controller) initDefaultLogicalSwitch() error {
subnet, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Get(context.Background(), c.config.DefaultLogicalSwitch, v1.GetOptions{})
if err == nil {
if subnet != nil && subnet.Spec.CIDRBlock != c.config.DefaultCIDR {
// upgrade to dual-stack
if subnet != nil && util.CheckProtocol(c.config.DefaultCIDR) != util.CheckProtocol(subnet.Spec.CIDRBlock) {
// single-stack upgrade to dual-stack
if util.CheckProtocol(c.config.DefaultCIDR) == kubeovnv1.ProtocolDual {
subnet.Spec.CIDRBlock = c.config.DefaultCIDR
if err := formatSubnet(subnet, c); err != nil {
klog.Errorf("init format subnet %s failed %v", c.config.DefaultLogicalSwitch, err)
return err
}
} else {
return fmt.Errorf("can not modify subnet to single protocol")
}
}
return nil
Expand Down Expand Up @@ -132,16 +130,14 @@ func (c *Controller) initDefaultLogicalSwitch() error {
func (c *Controller) initNodeSwitch() error {
subnet, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Get(context.Background(), c.config.NodeSwitch, v1.GetOptions{})
if err == nil {
if subnet != nil && subnet.Spec.CIDRBlock != c.config.NodeSwitchCIDR {
// upgrade to dual-stack
if subnet != nil && util.CheckProtocol(c.config.NodeSwitchCIDR) != util.CheckProtocol(subnet.Spec.CIDRBlock) {
// single-stack upgrade to dual-stack
if util.CheckProtocol(c.config.NodeSwitchCIDR) == kubeovnv1.ProtocolDual {
subnet.Spec.CIDRBlock = c.config.NodeSwitchCIDR
if err := formatSubnet(subnet, c); err != nil {
klog.Errorf("init format subnet %s failed %v", c.config.NodeSwitch, err)
return err
}
} else {
return fmt.Errorf("can not modify subnet to single protocol")
}
}
return nil
Expand Down

0 comments on commit 215c8f4

Please sign in to comment.