Skip to content

Commit

Permalink
fix coordinator listen calico resource (#2285)
Browse files Browse the repository at this point in the history
Signed-off-by: Icarus9913 <[email protected]>
  • Loading branch information
Icarus9913 authored Aug 31, 2023
1 parent 56e6dad commit 99e8fe7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
2 changes: 2 additions & 0 deletions cmd/spiderpool-controller/cmd/crd_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

multusv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
calicov1 "github.com/tigera/operator/pkg/apis/crd.projectcalico.org/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
Expand All @@ -28,6 +29,7 @@ func init() {
utilruntime.Must(spiderpoolv2beta1.AddToScheme(scheme))
utilruntime.Must(calicov1.AddToScheme(scheme))
utilruntime.Must(multusv1.AddToScheme(scheme))
utilruntime.Must(apiextensionsv1.AddToScheme(scheme))
}

func newCRDManager() (ctrl.Manager, error) {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ require (
github.com/prometheus/client_golang v1.15.1
github.com/spidernet-io/e2eframework v0.0.0-20230724150324-2eee77078275
github.com/spidernet-io/spiderdoctor v0.3.0
github.com/tigera/operator v1.30.4
github.com/tigera/operator v1.30.5
github.com/vishvananda/netlink v1.2.1-beta.2
go.uber.org/multierr v1.11.0
golang.org/x/sync v0.3.0
golang.org/x/sys v0.10.0
k8s.io/apiextensions-apiserver v0.26.3
k8s.io/kubernetes v1.27.4
)

Expand Down Expand Up @@ -155,7 +156,6 @@ require (
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
k8s.io/apiextensions-apiserver v0.26.3 // indirect
k8s.io/component-base v0.26.3 // indirect
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect
k8s.io/klog/v2 v2.90.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@ github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tigera/api v0.0.0-20230406222214-ca74195900cb h1:Y7r5Al3V235KaEoAzGBz9RYXEbwDu8CPaZoCq2PlD8w=
github.com/tigera/api v0.0.0-20230406222214-ca74195900cb/go.mod h1:ZZghiX3CUsBAc0osBjRvV6y/eun2ObYdvSbjqXAoj/w=
github.com/tigera/operator v1.30.4 h1:Ynbnf+DmqX2Fl6GsS5WG9pIHKFMtufSWv/N+3texq/I=
github.com/tigera/operator v1.30.4/go.mod h1:Lg570QCYYCcB9NkOQ2NWcOOyNsc4KDFttuxcJwuTq7k=
github.com/tigera/operator v1.30.5 h1:uKWVbr5wDt5PZjcpjKqYSq/KudIiqR73qOFv4LRqkvQ=
github.com/tigera/operator v1.30.5/go.mod h1:VB9YGUZymXwhZzgcoAa+B4IxV0D4eUPc0AKIV1l5RNU=
github.com/toqueteos/webbrowser v1.2.0 h1:tVP/gpK69Fx+qMJKsLE7TD8LuGWPnEV71wBN9rrstGQ=
github.com/toqueteos/webbrowser v1.2.0/go.mod h1:XWoZq4cyp9WeUeak7w7LXRUQf1F1ATJMir8RTqb4ayM=
github.com/vishvananda/netlink v1.2.1-beta.2 h1:Llsql0lnQEbHj0I1OuKyp8otXp0r3q0mPkuhwHfStVs=
Expand Down
13 changes: 10 additions & 3 deletions pkg/coordinatormanager/coordinator_informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import (

"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/informers"
coreinformers "k8s.io/client-go/informers/core/v1"
Expand Down Expand Up @@ -49,8 +51,8 @@ const (
var SupportedPodCIDRType = []string{cluster, calico, cilium, none}

const (
calicoConfig = "calico-config"
ciliumConfig = "cilium-config"
calicoIPPoolCRDName = "ippools.crd.projectcalico.org"
ciliumConfig = "cilium-config"
)

const (
Expand Down Expand Up @@ -356,8 +358,11 @@ func (cc *CoordinatorController) syncHandler(ctx context.Context, coordinatorNam
}
coordCopy.Status.Phase = Synced
coordCopy.Status.OverlayPodCIDR = k8sPodCIDR

case calico:
if _, err := cc.ConfigmapLister.ConfigMaps(metav1.NamespaceSystem).Get(calicoConfig); err != nil {
var crd apiextensionsv1.CustomResourceDefinition
err := cc.APIReader.Get(ctx, types.NamespacedName{Name: calicoIPPoolCRDName}, &crd)
if nil != err {
if apierrors.IsNotFound(err) {
event.EventRecorder.Eventf(
coordCopy,
Expand Down Expand Up @@ -398,6 +403,7 @@ func (cc *CoordinatorController) syncHandler(ctx context.Context, coordinatorNam
cc.caliCtrlCanncel = nil
}
}()

case cilium:
if cc.caliCtrlCanncel != nil {
cc.caliCtrlCanncel()
Expand Down Expand Up @@ -442,6 +448,7 @@ func (cc *CoordinatorController) syncHandler(ctx context.Context, coordinatorNam
if ipam == "kubernetes" {
coordCopy.Status.OverlayPodCIDR = k8sPodCIDR
}

case none:
coordCopy.Status.Phase = Synced
coordCopy.Status.OverlayPodCIDR = []string{}
Expand Down
8 changes: 7 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,14 @@ setup_spiderpool:
else \
HELM_OPTION+=" --set coordinator.enabled=false " ; \
fi ; \
if [ "$(INSTALL_OVERLAY_CNI)" == "true" ] && [ "$(INSTALL_CILIUM)" == "true" ] ; then \
if [ "$(INSTALL_OVERLAY_CNI)" == "true" ]; then \
if [ "$(INSTALL_CILIUM)" == "true" ] ; then \
HELM_OPTION+=" --set coordinator.podCIDRType=cilium " ; \
elif [ "$(INSTALL_CALICO)" == "true" ]; then \
HELM_OPTION+=" --set coordinator.podCIDRType=calico " ; \
else \
HELM_OPTION+=" --set coordinator.podCIDRType=cluster " ; \
fi ; \
fi ; \
if [ "$(INSTALL_MULTUS)" == "true" ] ; then \
HELM_OPTION+=" --set multus.multusCNI.install=true " ; \
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ github.com/subosito/gotenv
# github.com/tigera/api v0.0.0-20230406222214-ca74195900cb
## explicit; go 1.18
github.com/tigera/api/pkg/lib/numorstring
# github.com/tigera/operator v1.30.4
# github.com/tigera/operator v1.30.5
## explicit; go 1.20
github.com/tigera/operator/pkg/apis/crd.projectcalico.org/v1
# github.com/toqueteos/webbrowser v1.2.0
Expand Down

0 comments on commit 99e8fe7

Please sign in to comment.