Skip to content

Commit

Permalink
Merge pull request #4459 from cyclinder/0.8_cp/cilium_multi_pool
Browse files Browse the repository at this point in the history
Fix controller panic in cilium ipam is multi-pool
  • Loading branch information
weizhoublue authored Dec 30, 2024
2 parents 9edd63e + 8f0ac53 commit 7a0dd79
Show file tree
Hide file tree
Showing 4 changed files with 285 additions and 190 deletions.
10 changes: 8 additions & 2 deletions pkg/coordinatormanager/coordinator_informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,18 +705,24 @@ func (cc *CoordinatorController) fetchCiliumIPPools(coordinator *spiderpoolv2bet

podCIDR := make([]string, 0, len(ipPoolList))
for _, p := range ipPoolList {
if p.DeletionTimestamp == nil {
if p.DeletionTimestamp != nil {
continue
}

if p.Spec.IPv4 != nil {
for _, cidr := range p.Spec.IPv4.CIDRs {
podCIDR = append(podCIDR, string(cidr))
}
}

if p.Spec.IPv6 != nil {
for _, cidr := range p.Spec.IPv6.CIDRs {
podCIDR = append(podCIDR, string(cidr))
}
}
}

InformerLogger.Sugar().Debugf("Cilium IPPools CIDR: %v", ipPoolList)
InformerLogger.Sugar().Debugf("Cilium IPPools CIDR: %v", podCIDR)
if coordinator.Status.Phase == Synced && reflect.DeepEqual(coordinator.Status.OverlayPodCIDR, podCIDR) {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion test/Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ K8S_IPV4_SERVICE_CIDR = 10.233.0.0/18
K8S_IPV6_SERVICE_CIDR = fd00:10:233::/116

CLUSTER_POD_SUBNET_V4 = 10.233.64.0/18
CLUSTER_POD_SUBNET_V6 = fd00:10:233:64::/64
CLUSTER_POD_SUBNET_V6 = fd00:10:233:64::/60
CALICO_CLUSTER_POD_SUBNET_V4 = 10.243.64.0/18
CALICO_CLUSTER_POD_SUBNET_V6 = fd00:10:243::/112
CILIUM_CLUSTER_POD_SUBNET_V4 = 10.244.64.0/18
Expand Down
13 changes: 12 additions & 1 deletion test/e2e/common/spiderpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"github.com/spidernet-io/spiderpool/pkg/constant"
ip "github.com/spidernet-io/spiderpool/pkg/ip"
"github.com/spidernet-io/spiderpool/pkg/types"

corev1 "k8s.io/api/core/v1"

api_errors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand Down Expand Up @@ -423,6 +423,17 @@ func GenerateExampleIpv4poolObject(ipNum int) (string, *v1.SpiderIPPool) {
return v4PoolName, iPv4PoolObj
}

func PatchConfigMap(f *frame.Framework, oldcm, newcm *corev1.ConfigMap, opts ...client.PatchOption) error {
mergePatch := client.MergeFrom(oldcm)
d, err := mergePatch.Data(newcm)
GinkgoWriter.Printf("patch configMap: %v. \n", string(d))
if err != nil {
return fmt.Errorf("failed to generate patch, err is %v", err)
}

return f.PatchResource(newcm, mergePatch, opts...)
}

func GenerateExampleIpv6poolObject(ipNum int) (string, *v1.SpiderIPPool) {
if ipNum < 1 || ipNum > 65533 {
GinkgoWriter.Println("the IP range should be between 1 and 65533")
Expand Down
Loading

0 comments on commit 7a0dd79

Please sign in to comment.