Skip to content

Commit

Permalink
sync subnet to vpc while switching between custom VPC and default VPC
Browse files Browse the repository at this point in the history
Signed-off-by: 夜微澜 <qiutingjun_yewu@cmss.chinamobile.com>
  • Loading branch information
qiutingjun committed Oct 14, 2023
2 parents 9389319 + 60ef1ad commit 01c36d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
6 changes: 3 additions & 3 deletions dist/images/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax = docker/dockerfile:experimental
FROM ubuntu:23.10 as ovs-builder
FROM ubuntu:22.04 as ovs-builder

ARG ARCH
ARG DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -73,7 +73,7 @@ RUN mkdir /packages/ && \
cp /usr/src/ovn-*deb /packages && \
cd /packages && rm -f *source* *doc* *datapath* *docker* *vtep* *test* *dev*

FROM ubuntu:23.10
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y && apt install ca-certificates python3 hostname libunwind8 netbase \
Expand All @@ -93,7 +93,7 @@ ARG ARCH
ENV CNI_VERSION=v1.3.0
RUN curl -sSf -L --retry 5 https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz | tar -xz -C . ./loopback ./portmap ./macvlan

ENV KUBE_VERSION="v1.27.4"
ENV KUBE_VERSION="v1.28.2"

RUN curl -L https://dl.k8s.io/${KUBE_VERSION}/kubernetes-client-linux-${ARCH}.tar.gz | tar -xz -C . && cp ./kubernetes/client/bin/kubectl /usr/bin/kubectl \
&& chmod +x /usr/bin/kubectl && rm -rf ./kubernetes
Expand Down
27 changes: 13 additions & 14 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (c *Controller) processNextAddSubnetWorkItem() bool {
return false
}

err := func(obj interface{}) error {
if err := func(obj interface{}) error {
defer c.addOrUpdateSubnetQueue.Done(obj)
var key string
var ok bool
Expand All @@ -209,8 +209,7 @@ func (c *Controller) processNextAddSubnetWorkItem() bool {
}
c.addOrUpdateSubnetQueue.Forget(obj)
return nil
}(obj)
if err != nil {
}(obj); err != nil {
utilruntime.HandleError(err)
return true
}
Expand All @@ -223,7 +222,7 @@ func (c *Controller) processNextUpdateSubnetStatusWorkItem() bool {
return false
}

err := func(obj interface{}) error {
if err := func(obj interface{}) error {
defer c.updateSubnetStatusQueue.Done(obj)
var key string
var ok bool
Expand All @@ -238,8 +237,7 @@ func (c *Controller) processNextUpdateSubnetStatusWorkItem() bool {
}
c.updateSubnetStatusQueue.Forget(obj)
return nil
}(obj)
if err != nil {
}(obj); err != nil {
utilruntime.HandleError(err)
return true
}
Expand All @@ -252,7 +250,7 @@ func (c *Controller) processNextDeleteSubnetWorkItem() bool {
return false
}

err := func(obj interface{}) error {
if err := func(obj interface{}) error {
defer c.deleteSubnetQueue.Done(obj)
var subnet *kubeovnv1.Subnet
var ok bool
Expand All @@ -267,8 +265,7 @@ func (c *Controller) processNextDeleteSubnetWorkItem() bool {
}
c.deleteSubnetQueue.Forget(obj)
return nil
}(obj)
if err != nil {
}(obj); err != nil {
utilruntime.HandleError(err)
return true
}
Expand Down Expand Up @@ -526,8 +523,7 @@ func (c Controller) patchSubnetStatus(subnet *kubeovnv1.Subnet, reason, errStr s
}
}

bytes, err := subnet.Status.Bytes()
if err != nil {
if bytes, err := subnet.Status.Bytes(); err != nil {
klog.Error(err)
} else {
if _, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Patch(context.Background(), subnet.Name, types.MergePatchType, bytes, metav1.PatchOptions{}, "status"); err != nil {
Expand Down Expand Up @@ -1195,16 +1191,18 @@ func (c *Controller) syncVirtualPort(key string) error {
}

func (c *Controller) reconcileNamespaces(subnet *kubeovnv1.Subnet) error {
var err error
var (
namespaces []*v1.Namespace
err error
)

// 1. add annotations to bind namespace
for _, ns := range subnet.Spec.Namespaces {
c.addNamespaceQueue.Add(ns)
}

// 2. update unbind namespace annotation
namespaces, err := c.namespacesLister.List(labels.Everything())
if err != nil {
if namespaces, err = c.namespacesLister.List(labels.Everything()); err != nil {
klog.Errorf("failed to list namespaces, %v", err)
return err
}
Expand Down Expand Up @@ -1265,6 +1263,7 @@ func (c *Controller) reconcileCustomVpcBfdStaticRoute(vpcName, subnetName string
return err
}
vpc := cachedVpc.DeepCopy()

for _, eip := range ovnEips {
if !eip.Status.Ready || eip.Status.V4Ip == "" {
err := fmt.Errorf("ovn eip %q not ready", eip.Name)
Expand Down

0 comments on commit 01c36d9

Please sign in to comment.