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 24, 2025
1 parent 8d6c084 commit 3cc98bf
Show file tree
Hide file tree
Showing 109 changed files with 1,415 additions and 4,123 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ jobs:

- name: Validate OpenAPI definition By PR
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: char0n/swagger-editor-validate@v1
uses: char0n/swagger-editor-validate@v1.4.0
with:
definition-file: ${{ matrix.openapifilepath }}

- name: Validate OpenAPI definition By Command
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: char0n/swagger-editor-validate@v1
uses: char0n/swagger-editor-validate@v1.4.0
with:
definition-file: ${{ github.event.inputs.path }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ check_test_label:
.PHONY: unittest-tests
unittest-tests: check_test_label
@echo "run unittest-tests"
$(QUIET) $(ROOT_DIR)/tools/scripts/ginkgo.sh \
sudo $(QUIET) $(ROOT_DIR)/tools/scripts/ginkgo.sh \
--cover --coverprofile=./coverage.out --covermode set \
--json-report unittestreport.json \
-randomize-suites -randomize-all --keep-going --timeout=1h -p \
Expand Down
2 changes: 1 addition & 1 deletion README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ We are a [Cloud Native Computing Foundation](https://www.cncf.io) [sandbox proje
The Linux Foundation® (TLF) has registered trademarks and uses trademarks. For a list of TLF trademarks, see [Trademark Usage](https://www.linuxfoundation.org/legal/trademark-usage).

<p align="center">
<img src="https://landscape.cncf.io/images/cncf-landscape-horizontal-color.svg" width="300"/>&nbsp
<img src="https://landscape.cncf.io/images/cncf-landscape-horizontal-color.svg" alt="CNCF Landscape" width="300"/>&nbsp
<br/><br/>
</p>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,6 @@ We are a [Cloud Native Computing Foundation](https://www.cncf.io) [sandbox proje
The Linux Foundation® (TLF) has registered trademarks and uses trademarks. For a list of TLF trademarks, see [Trademark Usage](https://www.linuxfoundation.org/legal/trademark-usage).

<p align="center">
<img src="https://landscape.cncf.io/images/cncf-landscape-horizontal-color.svg" width="300"/>&nbsp
<img src="https://landscape.cncf.io/images/cncf-landscape-horizontal-color.svg" alt="CNCF Landscape" width="300"/>&nbsp
<br/><br/>
</p>
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.

30 changes: 16 additions & 14 deletions charts/spiderpool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,22 @@ helm install spiderpool spiderpool/spiderpool --wait --namespace kube-system \

### ipam parameters

| Name | Description | Value |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ------ |
| `ipam.enableIPv4` | enable ipv4 | `true` |
| `ipam.enableIPv6` | enable ipv6 | `true` |
| `ipam.enableStatefulSet` | the network mode | `true` |
| `ipam.enableKubevirtStaticIP` | the feature to keep kubevirt vm pod static IP | `true` |
| `ipam.spiderSubnet.enable` | SpiderSubnet feature. | `true` |
| `ipam.spiderSubnet.autoPool.enable` | SpiderSubnet Auto IPPool feature. | `true` |
| `ipam.spiderSubnet.autoPool.defaultRedundantIPNumber` | the default redundant IP number of SpiderSubnet feature auto-created IPPools | `1` |
| `ipam.gc.enabled` | enable retrieve IP in spiderippool CR | `true` |
| `ipam.gc.gcAll.intervalInSecond` | the gc all interval duration | `600` |
| `ipam.gc.statelessPod.zombieOnReadyNode` | enable reclaim IP for the stateless pod who is over deleting graceful period on a ready node | `true` |
| `ipam.gc.statelessPod.zombieOnNotReadyNode` | enable reclaim IP for the stateless pod who is over deleting graceful period on a not-ready node | `true` |
| `ipam.gc.gcDeletingTimeOutPodDelay` | the gc delay seconds after the pod times out of deleting graceful period | `0` |
| Name | Description | Value |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ------- |
| `ipam.enableIPv4` | enable ipv4 | `true` |
| `ipam.enableIPv6` | enable ipv6 | `true` |
| `ipam.enableStatefulSet` | the network mode | `true` |
| `ipam.enableKubevirtStaticIP` | the feature to keep kubevirt vm pod static IP | `true` |
| `ipam.enableIPConflictDetection` | enable IP conflict detection | `false` |
| `ipam.enableGatewayDetection` | enable gateway detection | `false` |
| `ipam.spiderSubnet.enable` | SpiderSubnet feature. | `true` |
| `ipam.spiderSubnet.autoPool.enable` | SpiderSubnet Auto IPPool feature. | `true` |
| `ipam.spiderSubnet.autoPool.defaultRedundantIPNumber` | the default redundant IP number of SpiderSubnet feature auto-created IPPools | `1` |
| `ipam.gc.enabled` | enable retrieve IP in spiderippool CR | `true` |
| `ipam.gc.gcAll.intervalInSecond` | the gc all interval duration | `600` |
| `ipam.gc.statelessPod.zombieOnReadyNode` | enable reclaim IP for the stateless pod who is over deleting graceful period on a ready node | `true` |
| `ipam.gc.statelessPod.zombieOnNotReadyNode` | enable reclaim IP for the stateless pod who is over deleting graceful period on a not-ready node | `true` |
| `ipam.gc.gcDeletingTimeOutPodDelay` | the gc delay seconds after the pod times out of deleting graceful period | `0` |

### grafanaDashboard parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ spec:
properties:
detectGateway:
default: false
description: DetectGateway to detect the gateway for the pod
description: DetectGateway to detect the gateway for the pod Deprecated,
gateway detection is now done by IPAM, setting this value has no
effect,this will be removed in the future.
type: boolean
detectIPConflict:
default: false
description: DetectIPConflict to detect the ip conflict for the pod
Deprecated, IP conflict detection is now done by IPAM, setting this
value has no effect,this will be removed in the future.
type: boolean
hijackCIDR:
description: HijackCIDR configure static routing tables in the pod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ spec:
properties:
detectGateway:
default: false
description: DetectGateway to detect the gateway for the pod
description: DetectGateway to detect the gateway for the pod Deprecated,
gateway detection is now done by IPAM, setting this value has
no effect,this will be removed in the future.
type: boolean
detectIPConflict:
default: false
description: DetectIPConflict to detect the ip conflict for the
pod
pod Deprecated, IP conflict detection is now done by IPAM, setting
this value has no effect,this will be removed in the future.
type: boolean
hijackCIDR:
description: HijackCIDR configure static routing tables in the
Expand Down
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
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 3cc98bf

Please sign in to comment.