Skip to content

Commit

Permalink
Detect IPConflicting and gatewayReachable in ipam without coordinator
Browse files Browse the repository at this point in the history
Signed-off-by: Cyclinder Kuo <[email protected]>
  • Loading branch information
cyclinder committed Jan 16, 2025
1 parent eaabcbf commit 4ee161a
Show file tree
Hide file tree
Showing 29 changed files with 754 additions and 688 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,12 @@ e2e_init_cilium_ebpfservice:
.PHONY: e2e_init_calico
e2e_init_calico:
$(QUIET) make e2e_init -e INSTALL_OVERLAY_CNI=true -e INSTALL_CALICO=true -e INSTALL_CILIUM=false -e E2E_SPIDERPOOL_ENABLE_SUBNET=false \
-e E2E_SPIDERPOOL_ENABLE_DRA=true -e INSTALL_OVS=false
-e E2E_SPIDERPOOL_ENABLE_DRA=true -e INSTALL_OVS=false -e E2E_SPIDERPOOL_ENABLE_IPAM_DETECTION=true

.PHONY: e2e_init_cilium_legacyservice
e2e_init_cilium_legacyservice:
$(QUIET) make e2e_init -e INSTALL_OVERLAY_CNI=true -e INSTALL_CALICO=false -e INSTALL_CILIUM=true -e DISABLE_KUBE_PROXY=false \
-e E2E_SPIDERPOOL_ENABLE_SUBNET=false -e INSTALL_OVS=false
-e E2E_SPIDERPOOL_ENABLE_SUBNET=false -e INSTALL_OVS=false -e -e E2E_SPIDERPOOL_ENABLE_IPAM_DETECTION=true

.PHONY: e2e_test
e2e_test:
Expand Down
6 changes: 0 additions & 6 deletions api/v1/agent/models/coordinator_config.go

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

6 changes: 6 additions & 0 deletions api/v1/agent/models/ip_config.go

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

8 changes: 4 additions & 4 deletions api/v1/agent/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ definitions:
type: string
vlan:
type: integer
enableGatewayDetection:
type: boolean
enableIPConflictDetection:
type: boolean
required:
- version
- address
Expand Down Expand Up @@ -340,10 +344,6 @@ definitions:
type: integer
txQueueLen:
type: integer
detectIPConflict:
type: boolean
detectGateway:
type: boolean
vethLinkAddress:
type: string
required:
Expand Down
24 changes: 12 additions & 12 deletions api/v1/agent/server/embedded_spec.go

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

2 changes: 2 additions & 0 deletions charts/spiderpool/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ data:
enableKubevirtStaticIP: {{ .Values.ipam.enableKubevirtStaticIP }}
enableSpiderSubnet: {{ .Values.ipam.spiderSubnet.enable }}
enableAutoPoolForApplication: {{ .Values.ipam.spiderSubnet.autoPool.enable }}
enableIPConflictDetection: {{ .Values.ipam.enableIPConflictDetection }}
enableGatewayDetection: {{ .Values.ipam.enableGatewayDetection }}
{{- if and .Values.ipam.spiderSubnet.enable .Values.ipam.spiderSubnet.autoPool.enable }}
clusterSubnetDefaultFlexibleIPNumber: {{ .Values.ipam.spiderSubnet.autoPool.defaultRedundantIPNumber }}
{{- else}}
Expand Down
6 changes: 6 additions & 0 deletions charts/spiderpool/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ ipam:
## @param ipam.enableKubevirtStaticIP the feature to keep kubevirt vm pod static IP
enableKubevirtStaticIP: true

## @param ipam.enableIPConflictDetection enable IP conflict detection

Check failure on line 56 in charts/spiderpool/values.yaml

View workflow job for this annotation

GitHub Actions / lint_chart_against_release_image / chart-lint-test

56:72 [trailing-spaces] trailing spaces
enableIPConflictDetection: false

## @param ipam.enableGatewayDetection enable gateway detection
enableGatewayDetection: false

spiderSubnet:
## @param ipam.spiderSubnet.enable SpiderSubnet feature.
enable: true
Expand Down
81 changes: 15 additions & 66 deletions cmd/coordinator/cmd/cni_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"path/filepath"
"regexp"
"strings"
"time"

"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/version"
Expand Down Expand Up @@ -44,24 +43,21 @@ const (

type Config struct {
types.NetConf
DetectGateway *bool `json:"detectGateway,omitempty"`
VethLinkAddress string `json:"vethLinkAddress,omitempty"`
MacPrefix string `json:"podMACPrefix,omitempty"`
MultusNicPrefix string `json:"multusNicPrefix,omitempty"`
PodDefaultCniNic string `json:"podDefaultCniNic,omitempty"`
OverlayPodCIDR []string `json:"overlayPodCIDR,omitempty"`
ServiceCIDR []string `json:"serviceCIDR,omitempty"`
HijackCIDR []string `json:"hijackCIDR,omitempty"`
TunePodRoutes *bool `json:"tunePodRoutes,omitempty"`
PodDefaultRouteNIC string `json:"podDefaultRouteNic,omitempty"`
Mode Mode `json:"mode,omitempty"`
HostRuleTable *int64 `json:"hostRuleTable,omitempty"`
HostRPFilter *int32 `json:"hostRPFilter,omitempty" `
PodRPFilter *int32 `json:"podRPFilter,omitempty" `
TxQueueLen *int64 `json:"txQueueLen,omitempty"`
IPConflict *bool `json:"detectIPConflict,omitempty"`
DetectOptions *DetectOptions `json:"detectOptions,omitempty"`
LogOptions *LogOptions `json:"logOptions,omitempty"`
VethLinkAddress string `json:"vethLinkAddress,omitempty"`
MacPrefix string `json:"podMACPrefix,omitempty"`
MultusNicPrefix string `json:"multusNicPrefix,omitempty"`
PodDefaultCniNic string `json:"podDefaultCniNic,omitempty"`
OverlayPodCIDR []string `json:"overlayPodCIDR,omitempty"`
ServiceCIDR []string `json:"serviceCIDR,omitempty"`
HijackCIDR []string `json:"hijackCIDR,omitempty"`
TunePodRoutes *bool `json:"tunePodRoutes,omitempty"`
PodDefaultRouteNIC string `json:"podDefaultRouteNic,omitempty"`
Mode Mode `json:"mode,omitempty"`
HostRuleTable *int64 `json:"hostRuleTable,omitempty"`
HostRPFilter *int32 `json:"hostRPFilter,omitempty" `
PodRPFilter *int32 `json:"podRPFilter,omitempty" `
TxQueueLen *int64 `json:"txQueueLen,omitempty"`
LogOptions *LogOptions `json:"logOptions,omitempty"`
}

// DetectOptions enable ip conflicting check for pod's ip
Expand Down Expand Up @@ -142,15 +138,6 @@ func ParseConfig(stdin []byte, coordinatorConfig *models.CoordinatorConfig) (*Co
return nil, err
}

if conf.IPConflict == nil && coordinatorConfig.DetectIPConflict {
conf.IPConflict = ptr.To(true)
}

conf.DetectOptions, err = ValidateDelectOptions(conf.DetectOptions)
if err != nil {
return nil, err
}

if conf.HostRuleTable == nil && coordinatorConfig.HostRuleTable > 0 {
conf.HostRuleTable = ptr.To(coordinatorConfig.HostRuleTable)
}
Expand All @@ -163,10 +150,6 @@ func ParseConfig(stdin []byte, coordinatorConfig *models.CoordinatorConfig) (*Co
conf.HostRuleTable = ptr.To(int64(500))
}

if conf.DetectGateway == nil {
conf.DetectGateway = ptr.To(coordinatorConfig.DetectGateway)
}

if conf.TunePodRoutes == nil {
conf.TunePodRoutes = coordinatorConfig.TunePodRoutes
}
Expand Down Expand Up @@ -270,37 +253,3 @@ func validateRPFilterConfig(rpfilter *int32, coordinatorConfig int64) (*int32, e
}
return rpfilter, nil
}

func ValidateDelectOptions(config *DetectOptions) (*DetectOptions, error) {
if config == nil {
return &DetectOptions{
Interval: "10ms",
TimeOut: "100ms",
Retry: 3,
}, nil
}

if config.Retry == 0 {
config.Retry = 3
}

if config.Interval == "" {
config.Interval = "10ms"
}

if config.TimeOut == "" {
config.TimeOut = "500ms"
}

_, err := time.ParseDuration(config.Interval)
if err != nil {
return nil, fmt.Errorf("invalid detectOptions.interval %s: %v, input like: 1s or 1m", config.Interval, err)
}

_, err = time.ParseDuration(config.TimeOut)
if err != nil {
return nil, fmt.Errorf("invalid detectOptions.timeout %s: %v, input like: 1s or 1m", config.TimeOut, err)
}

return config, nil
}
Loading

0 comments on commit 4ee161a

Please sign in to comment.