Skip to content

Commit

Permalink
fix external-vpc
Browse files Browse the repository at this point in the history
  • Loading branch information
fanriming committed Sep 6, 2021
1 parent 00cd3a8 commit 25b151c
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions dist/images/install-pre-1.16.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ VLAN_NIC=${VLAN_NIC:-}
HW_OFFLOAD=${HW_OFFLOAD:-false}
ENABLE_LB=${ENABLE_LB:-true}
ENABLE_NP=${ENABLE_NP:-true}
ENABLE_EXTERNAL_VPC=${ENABLE_EXTERNAL_VPC:-true}
# The nic to support container network can be a nic name or a group of regex
# separated by comma, if empty will use the nic that the default route use
IFACE=${IFACE:-}
Expand Down Expand Up @@ -1762,6 +1763,7 @@ spec:
- --pod-nic-type=$POD_NIC_TYPE
- --enable-lb=$ENABLE_LB
- --enable-np=$ENABLE_NP
- --enable-external-vpc=$ENABLE_EXTERNAL_VPC
env:
- name: ENABLE_SSL
value: "$ENABLE_SSL"
Expand Down
2 changes: 2 additions & 0 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ VLAN_NIC=${VLAN_NIC:-}
HW_OFFLOAD=${HW_OFFLOAD:-false}
ENABLE_LB=${ENABLE_LB:-true}
ENABLE_NP=${ENABLE_NP:-true}
ENABLE_EXTERNAL_VPC=${ENABLE_EXTERNAL_VPC:-true}
# The nic to support container network can be a nic name or a group of regex
# separated by comma, if empty will use the nic that the default route use
IFACE=${IFACE:-}
Expand Down Expand Up @@ -1814,6 +1815,7 @@ spec:
- --pod-nic-type=$POD_NIC_TYPE
- --enable-lb=$ENABLE_LB
- --enable-np=$ENABLE_NP
- --enable-external-vpc=$ENABLE_EXTERNAL_VPC
env:
- name: ENABLE_SSL
value: "$ENABLE_SSL"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ func (c *Controller) startWorkers(stopCh <-chan struct{}) {
for {
klog.Infof("wait for %s and %s ready", c.config.DefaultLogicalSwitch, c.config.NodeSwitch)
time.Sleep(3 * time.Second)
lss, err := c.ovnClient.ListLogicalSwitch()
lss, err := c.ovnClient.ListLogicalSwitch(c.config.EnableExternalVpc)
if err != nil {
klog.Fatalf("failed to list logical switch: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (c *Controller) gcLogicalSwitch() error {
for _, s := range subnets {
subnetNames = append(subnetNames, s.Name)
}
lss, err := c.ovnClient.ListLogicalSwitch(fmt.Sprintf("external_ids:vendor=%s", util.CniTypeName))
lss, err := c.ovnClient.ListLogicalSwitch(c.config.EnableExternalVpc)
if err != nil {
klog.Errorf("failed to list logical switch, %v", err)
return err
Expand Down Expand Up @@ -126,7 +126,7 @@ func (c *Controller) gcCustomLogicalRouter() error {
for _, s := range vpcs {
vpcNames = append(vpcNames, s.Name)
}
lrs, err := c.ovnClient.ListLogicalRouter(fmt.Sprintf("external_ids:vendor=%s", util.CniTypeName))
lrs, err := c.ovnClient.ListLogicalRouter(c.config.EnableExternalVpc)
if err != nil {
klog.Errorf("failed to list logical router, %v", err)
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (c *Controller) initNodeSwitch() error {

// InitClusterRouter init cluster router to connect different logical switches
func (c *Controller) initClusterRouter() error {
lrs, err := c.ovnClient.ListLogicalRouter()
lrs, err := c.ovnClient.ListLogicalRouter(c.config.EnableExternalVpc)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/ovn-ic.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (c *Controller) stopOVNIC() error {
func (c *Controller) waitTsReady() error {
retry := 6
for retry > 0 {
exists, err := c.ovnClient.LogicalSwitchExists(util.InterconnectionSwitch)
exists, err := c.ovnClient.LogicalSwitchExists(util.InterconnectionSwitch, c.config.EnableExternalVpc)
if err != nil {
klog.Errorf("failed to list logical switch, %v", err)
return err
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error {
}
}

exist, err := c.ovnClient.LogicalSwitchExists(subnet.Name, fmt.Sprintf("external_ids:vendor=%s", util.CniTypeName))
exist, err := c.ovnClient.LogicalSwitchExists(subnet.Name, c.config.EnableExternalVpc)
if err != nil {
klog.Errorf("failed to list logical switch, %v", err)
c.patchSubnetStatus(subnet, "ListLogicalSwitchFailed", err.Error())
Expand Down Expand Up @@ -649,10 +649,10 @@ func (c *Controller) handleDeleteRoute(subnet *kubeovnv1.Subnet) error {
return c.deleteStaticRoute(subnet.Spec.CIDRBlock, vpc.Status.Router, subnet)
}

func (c *Controller) handleDeleteLogicalSwitch(key string) error {
func (c *Controller) handleDeleteLogicalSwitch(key string) (err error) {
c.ipam.DeleteSubnet(key)

exist, err := c.ovnClient.LogicalSwitchExists(key, fmt.Sprintf("external_ids:vendor=%s", util.CniTypeName))
exist, err := c.ovnClient.LogicalSwitchExists(key, c.config.EnableExternalVpc)
if err != nil {
klog.Errorf("failed to list logical switch, %v", err)
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ func (c *Controller) getVpcSubnets(vpc *kubeovnv1.Vpc) (subnets []string, defaul

// createVpcRouter create router to connect logical switches in vpc
func (c *Controller) createVpcRouter(lr string) error {
lrs, err := c.ovnClient.ListLogicalRouter()
lrs, err := c.ovnClient.ListLogicalRouter(c.config.EnableExternalVpc)
if err != nil {
return err
}
Expand Down
11 changes: 7 additions & 4 deletions pkg/ovs/ovn-nbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,10 @@ func (c Client) DeleteGatewaySwitch(name string) error {
}

// ListLogicalSwitch list logical switch names
func (c Client) ListLogicalSwitch(args ...string) ([]string, error) {
func (c Client) ListLogicalSwitch(needVendorFilter bool, args ...string) ([]string, error) {
if needVendorFilter {
args = append(args, fmt.Sprintf("external_ids:vendor=%s", util.CniTypeName))
}
return c.ListLogicalEntity("logical_switch", args...)
}

Expand Down Expand Up @@ -526,8 +529,8 @@ func (c Client) GetEntityInfo(entity string, index string, attris []string) (res
return result, nil
}

func (c Client) LogicalSwitchExists(logicalSwitch string, args ...string) (bool, error) {
lss, err := c.ListLogicalSwitch(args...)
func (c Client) LogicalSwitchExists(logicalSwitch string, needVendorFilter bool, args ...string) (bool, error) {
lss, err := c.ListLogicalSwitch(needVendorFilter, args...)
if err != nil {
return false, err
}
Expand Down Expand Up @@ -595,7 +598,7 @@ func (c Client) ListRemoteLogicalSwitchPortAddress() ([]string, error) {
}

// ListLogicalRouter list logical router names
func (c Client) ListLogicalRouter(args ...string) ([]string, error) {
func (c Client) ListLogicalRouter(needVendorFilter bool, args ...string) ([]string, error) {
return c.ListLogicalEntity("logical_router", args...)
}

Expand Down
1 change: 1 addition & 0 deletions yamls/kube-ovn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ spec:
- --pod-nic-type=veth-pair
- --enable-lb=true
- --enable-np=true
- --enable-external-vpc=true
env:
- name: ENABLE_SSL
value: "false"
Expand Down

0 comments on commit 25b151c

Please sign in to comment.