Skip to content

Commit

Permalink
add ovnext0 inside ns on gw node for ecmp static route with bfd (#2237)
Browse files Browse the repository at this point in the history
Co-authored-by: zhangbingbing <zhangbingbing@yealink.com>
  • Loading branch information
bobz965 and zhangbingbing committed Feb 14, 2023
1 parent 4ca994b commit b0b4694
Show file tree
Hide file tree
Showing 20 changed files with 1,065 additions and 120 deletions.
8 changes: 8 additions & 0 deletions Makefile.e2e
Expand Up @@ -105,6 +105,14 @@ kube-ovn-lb-svc-conformance-e2e:
E2E_NETWORK_MODE=$(E2E_NETWORK_MODE) \
./test/e2e/lb-svc/e2e.test --ginkgo.focus=CNI:Kube-OVN

.PHONY: kube-ovn-eip-conformance-e2e
kube-ovn-eip-conformance-e2e:
go test ./test/e2e/ovn-eip -c -o test/e2e/ovn-eip/e2e.test
E2E_BRANCH=$(E2E_BRANCH) \
E2E_IP_FAMILY=$(E2E_IP_FAMILY) \
E2E_NETWORK_MODE=$(E2E_NETWORK_MODE) \
./test/e2e/ovn-eip/e2e.test --ginkgo.focus=CNI:Kube-OVN

.PHONY: kube-ovn-security-e2e
kube-ovn-security-e2e:
go test ./test/e2e/security -c -o test/e2e/security/e2e.test
Expand Down
22 changes: 17 additions & 5 deletions dist/images/install.sh
Expand Up @@ -773,24 +773,34 @@ spec:
subresources:
status: {}
additionalPrinterColumns:
- jsonPath: .spec.v4ip
name: IP
- jsonPath: .status.v4Ip
name: V4IP
type: string
- jsonPath: .spec.macAddress
- jsonPath: .status.v6Ip
name: V6IP
type: string
- jsonPath: .status.macAddress
name: Mac
type: string
- jsonPath: .spec.type
name: Type
type: string
- jsonPath: .status.ready
name: Ready
type: boolean
schema:
openAPIV3Schema:
type: object
properties:
status:
type: object
properties:
ready:
type: boolean
v4Ip:
type: string
v6Ip:
type: string
macAddress:
type: string
conditions:
Expand All @@ -817,7 +827,9 @@ spec:
type: string
type:
type: string
v4ip:
v4Ip:
type: string
v6Ip:
type: string
macAddress:
type: string
Expand Down Expand Up @@ -3170,7 +3182,7 @@ spec:
name: host-run-ovn
- mountPath: /var/run/netns
name: host-ns
mountPropagation: HostToContainer
mountPropagation: Bidirectional
- mountPath: /var/log/kube-ovn
name: kube-ovn-log
- mountPath: /var/log/openvswitch
Expand Down
9 changes: 6 additions & 3 deletions pkg/apis/kubeovn/v1/types.go
Expand Up @@ -995,10 +995,11 @@ type OvnEip struct {
}
type OvnEipSpec struct {
ExternalSubnet string `json:"externalSubnet"`
V4Ip string `json:"v4ip"`
V4Ip string `json:"v4Ip"`
V6Ip string `json:"v6Ip"`
MacAddress string `json:"macAddress"`
Type string `json:"type"`
// usage type: fip, snat, lrp
// usage type: fip, snat, lrp, node external gw
}

// Condition describes the state of an object at a certain point.
Expand Down Expand Up @@ -1029,7 +1030,9 @@ type OvnEipStatus struct {
// +patchStrategy=merge
Conditions []OvnEipCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`

V4Ip string `json:"v4ip" patchStrategy:"merge"`
Ready bool `json:"ready" patchStrategy:"merge"`
V4Ip string `json:"v4Ip" patchStrategy:"merge"`
V6Ip string `json:"v6Ip" patchStrategy:"merge"`
MacAddress string `json:"macAddress" patchStrategy:"merge"`
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/client/clientset/versioned/clientset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 4 additions & 75 deletions pkg/client/informers/externalversions/factory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 13 additions & 8 deletions pkg/controller/external-gw.go
Expand Up @@ -160,6 +160,11 @@ func (c *Controller) establishExternalGateway(config map[string]string) error {
klog.Errorf("failed to create external gateway switch, %v", err)
return err
}
lrpEipName := fmt.Sprintf("%s-%s", util.DefaultVpc, c.config.ExternalGatewaySwitch)
if err = c.patchOvnEipStatus(lrpEipName, true); err != nil {
klog.Errorf("failed to patch ovn eip cr status for lrp %s, %v", lrpEipName, err)
return err
}
return nil
}

Expand All @@ -181,8 +186,13 @@ func (c *Controller) createDefaultVpcLrpEip(config map[string]string) (string, s
}
var v4ip, mac string
if !needCreateEip {
v4ip = cachedEip.Spec.V4Ip
mac = cachedEip.Spec.MacAddress
v4ip = cachedEip.Status.V4Ip
mac = cachedEip.Status.MacAddress
if v4ip == "" || mac == "" {
err = fmt.Errorf("lrp '%s' ip or mac should not be empty", lrpEipName)
klog.Error(err)
return "", "", err
}
} else {
var v6ip string
v4ip, v6ip, mac, err = c.acquireIpAddress(c.config.ExternalGatewaySwitch, lrpEipName, lrpEipName)
Expand All @@ -194,16 +204,11 @@ func (c *Controller) createDefaultVpcLrpEip(config map[string]string) (string, s
klog.Errorf("failed to create ovn eip cr for lrp %s, %v", lrpEipName, err)
return "", "", err
}
if err = c.patchOvnEipStatus(lrpEipName); err != nil {
if err = c.patchOvnEipStatus(lrpEipName, false); err != nil {
klog.Errorf("failed to patch ovn eip cr status for lrp %s, %v", lrpEipName, err)
return "", "", err
}
}
if v4ip == "" || mac == "" {
err = fmt.Errorf("lrp '%s' ip or mac should not be empty", lrpEipName)
klog.Error(err)
return "", "", err
}
v4ipCidr := util.GetIpAddrWithMask(v4ip, cachedSubnet.Spec.CIDRBlock)
return v4ipCidr, mac, nil
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/gc.go
Expand Up @@ -327,6 +327,11 @@ func (c *Controller) markAndCleanLSP() error {
if node.Annotations[util.AllocatedAnnotation] == "true" {
ipMap[fmt.Sprintf("node-%s", node.Name)] = struct{}{}
}

if _, err := c.ovnEipsLister.Get(node.Name); err == nil {
// node external gw lsp is managed by ovn eip cr, skip gc its lsp
ipMap[node.Name] = struct{}{}
}
}

// The lsp for vm pod should not be deleted if vm still exists
Expand Down
4 changes: 1 addition & 3 deletions pkg/controller/init.go
Expand Up @@ -429,9 +429,7 @@ func (c *Controller) InitIPAM() error {
return err
}
for _, oeip := range oeips {
if _, _, _, err = c.ipam.GetStaticAddress(oeip.Name, oeip.Name, oeip.Spec.V4Ip,
oeip.Spec.MacAddress, oeip.Spec.ExternalSubnet, false); err != nil {

if _, _, _, err = c.ipam.GetStaticAddress(oeip.Name, oeip.Name, oeip.Status.V4Ip, oeip.Status.MacAddress, oeip.Spec.ExternalSubnet, true); err != nil {
klog.Errorf("failed to init ipam from ovn eip cr %s: %v", oeip.Name, err)
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/node.go
Expand Up @@ -195,7 +195,7 @@ func (c *Controller) handleAddNode(key string) error {
return err
}
node := cachedNode.DeepCopy()
klog.Infof("handle add node %v", node.Name)
klog.Infof("handle add node %s", node.Name)

subnets, err := c.subnetsLister.List(labels.Everything())
if err != nil {
Expand Down Expand Up @@ -777,7 +777,7 @@ func (c *Controller) checkGatewayReady() error {

if !success {
if exist {
klog.Warningf("failed to ping ovn0 %s or node %v is not ready, delete ecmp policy route for node", ip, node.Name)
klog.Warningf("failed to ping ovn0 %s or node %s is not ready, delete ecmp policy route for node", ip, node.Name)
nextHops = util.RemoveString(nextHops, ip)
delete(nameIpMap, node.Name)
klog.Infof("update policy route for centralized subnet %s, nextHops %s", subnet.Name, nextHops)
Expand All @@ -803,7 +803,7 @@ func (c *Controller) checkGatewayReady() error {
}
} else {
if exist {
klog.Infof("subnet %v gatewayNode does not contains node %v, delete policy route for node ip %s", subnet.Name, node.Name, ip)
klog.Infof("subnet %s gatewayNode does not contains node %v, delete policy route for node ip %s", subnet.Name, node.Name, ip)
nextHops = util.RemoveString(nextHops, ip)
delete(nameIpMap, node.Name)
klog.Infof("update policy route for centralized subnet %s, nextHops %s", subnet.Name, nextHops)
Expand Down

0 comments on commit b0b4694

Please sign in to comment.