Skip to content

Commit 655c389

Browse files
authored
Detect IPConflicting and gatewayReachable in ipam without coordinator (spidernet-io#4560)
Signed-off-by: Cyclinder Kuo <[email protected]>
1 parent fd55a2a commit 655c389

File tree

109 files changed

+1405
-4125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1405
-4125
lines changed

.github/workflows/lint-openapi.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ jobs:
4646

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

5353
- name: Validate OpenAPI definition By Command
5454
if: ${{ github.event_name == 'workflow_dispatch' }}
55-
uses: char0n/swagger-editor-validate@v1
55+
uses: char0n/swagger-editor-validate@v1.4.0
5656
with:
5757
definition-file: ${{ github.event.inputs.path }}

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ check_test_label:
277277
.PHONY: unittest-tests
278278
unittest-tests: check_test_label
279279
@echo "run unittest-tests"
280-
$(QUIET) $(ROOT_DIR)/tools/scripts/ginkgo.sh \
280+
sudo $(QUIET) $(ROOT_DIR)/tools/scripts/ginkgo.sh \
281281
--cover --coverprofile=./coverage.out --covermode set \
282282
--json-report unittestreport.json \
283283
-randomize-suites -randomize-all --keep-going --timeout=1h -p \

README-zh_CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,6 @@ We are a [Cloud Native Computing Foundation](https://www.cncf.io) [sandbox proje
173173
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).
174174

175175
<p align="center">
176-
<img src="https://landscape.cncf.io/images/cncf-landscape-horizontal-color.svg" width="300"/>&nbsp
176+
<img src="https://landscape.cncf.io/images/cncf-landscape-horizontal-color.svg" alt="CNCF Landscape" width="300"/>&nbsp
177177
<br/><br/>
178178
</p>

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,6 @@ We are a [Cloud Native Computing Foundation](https://www.cncf.io) [sandbox proje
179179
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).
180180

181181
<p align="center">
182-
<img src="https://landscape.cncf.io/images/cncf-landscape-horizontal-color.svg" width="300"/>&nbsp
182+
<img src="https://landscape.cncf.io/images/cncf-landscape-horizontal-color.svg" alt="CNCF Landscape" width="300"/>&nbsp
183183
<br/><br/>
184184
</p>

api/v1/agent/models/coordinator_config.go

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1/agent/models/ip_config.go

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1/agent/openapi.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ definitions:
306306
type: string
307307
vlan:
308308
type: integer
309+
enableGatewayDetection:
310+
type: boolean
311+
enableIPConflictDetection:
312+
type: boolean
309313
required:
310314
- version
311315
- address
@@ -340,10 +344,6 @@ definitions:
340344
type: integer
341345
txQueueLen:
342346
type: integer
343-
detectIPConflict:
344-
type: boolean
345-
detectGateway:
346-
type: boolean
347347
vethLinkAddress:
348348
type: string
349349
required:

api/v1/agent/server/embedded_spec.go

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/spiderpool/README.md

+16-14
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,22 @@ helm install spiderpool spiderpool/spiderpool --wait --namespace kube-system \
127127

128128
### ipam parameters
129129

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

145147
### grafanaDashboard parameters
146148

charts/spiderpool/crds/spiderpool.spidernet.io_spidercoordinators.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ spec:
4040
properties:
4141
detectGateway:
4242
default: false
43-
description: DetectGateway to detect the gateway for the pod
43+
description: 'DetectGateway to detect the gateway for the pod Deprecated:
44+
gateway detection is now done by IPAM, setting this value has no
45+
effect,this will be removed in the future.'
4446
type: boolean
4547
detectIPConflict:
4648
default: false
47-
description: DetectIPConflict to detect the ip conflict for the pod
49+
description: 'DetectIPConflict to detect the ip conflict for the pod
50+
Deprecated: IP conflict detection is now done by IPAM, setting this
51+
value has no effect,this will be removed in the future.'
4852
type: boolean
4953
hijackCIDR:
5054
description: HijackCIDR configure static routing tables in the pod

charts/spiderpool/crds/spiderpool.spidernet.io_spidermultusconfigs.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,15 @@ spec:
5959
properties:
6060
detectGateway:
6161
default: false
62-
description: DetectGateway to detect the gateway for the pod
62+
description: 'DetectGateway to detect the gateway for the pod
63+
Deprecated: gateway detection is now done by IPAM, setting this
64+
value has no effect,this will be removed in the future.'
6365
type: boolean
6466
detectIPConflict:
6567
default: false
66-
description: DetectIPConflict to detect the ip conflict for the
67-
pod
68+
description: 'DetectIPConflict to detect the ip conflict for the
69+
pod Deprecated: IP conflict detection is now done by IPAM, setting
70+
this value has no effect,this will be removed in the future.'
6871
type: boolean
6972
hijackCIDR:
7073
description: HijackCIDR configure static routing tables in the

charts/spiderpool/templates/configmap.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ data:
2222
enableKubevirtStaticIP: {{ .Values.ipam.enableKubevirtStaticIP }}
2323
enableSpiderSubnet: {{ .Values.ipam.spiderSubnet.enable }}
2424
enableAutoPoolForApplication: {{ .Values.ipam.spiderSubnet.autoPool.enable }}
25+
enableIPConflictDetection: {{ .Values.ipam.enableIPConflictDetection }}
26+
enableGatewayDetection: {{ .Values.ipam.enableGatewayDetection }}
2527
{{- if and .Values.ipam.spiderSubnet.enable .Values.ipam.spiderSubnet.autoPool.enable }}
2628
clusterSubnetDefaultFlexibleIPNumber: {{ .Values.ipam.spiderSubnet.autoPool.defaultRedundantIPNumber }}
2729
{{- else}}

charts/spiderpool/values.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ ipam:
5353
## @param ipam.enableKubevirtStaticIP the feature to keep kubevirt vm pod static IP
5454
enableKubevirtStaticIP: true
5555

56+
## @param ipam.enableIPConflictDetection enable IP conflict detection
57+
enableIPConflictDetection: false
58+
59+
## @param ipam.enableGatewayDetection enable gateway detection
60+
enableGatewayDetection: false
61+
5662
spiderSubnet:
5763
## @param ipam.spiderSubnet.enable SpiderSubnet feature.
5864
enable: true

cmd/coordinator/cmd/cni_types.go

+15-66
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"path/filepath"
1212
"regexp"
1313
"strings"
14-
"time"
1514

1615
"github.com/containernetworking/cni/pkg/types"
1716
"github.com/containernetworking/cni/pkg/version"
@@ -44,24 +43,21 @@ const (
4443

4544
type Config struct {
4645
types.NetConf
47-
DetectGateway *bool `json:"detectGateway,omitempty"`
48-
VethLinkAddress string `json:"vethLinkAddress,omitempty"`
49-
MacPrefix string `json:"podMACPrefix,omitempty"`
50-
MultusNicPrefix string `json:"multusNicPrefix,omitempty"`
51-
PodDefaultCniNic string `json:"podDefaultCniNic,omitempty"`
52-
OverlayPodCIDR []string `json:"overlayPodCIDR,omitempty"`
53-
ServiceCIDR []string `json:"serviceCIDR,omitempty"`
54-
HijackCIDR []string `json:"hijackCIDR,omitempty"`
55-
TunePodRoutes *bool `json:"tunePodRoutes,omitempty"`
56-
PodDefaultRouteNIC string `json:"podDefaultRouteNic,omitempty"`
57-
Mode Mode `json:"mode,omitempty"`
58-
HostRuleTable *int64 `json:"hostRuleTable,omitempty"`
59-
HostRPFilter *int32 `json:"hostRPFilter,omitempty" `
60-
PodRPFilter *int32 `json:"podRPFilter,omitempty" `
61-
TxQueueLen *int64 `json:"txQueueLen,omitempty"`
62-
IPConflict *bool `json:"detectIPConflict,omitempty"`
63-
DetectOptions *DetectOptions `json:"detectOptions,omitempty"`
64-
LogOptions *LogOptions `json:"logOptions,omitempty"`
46+
VethLinkAddress string `json:"vethLinkAddress,omitempty"`
47+
MacPrefix string `json:"podMACPrefix,omitempty"`
48+
MultusNicPrefix string `json:"multusNicPrefix,omitempty"`
49+
PodDefaultCniNic string `json:"podDefaultCniNic,omitempty"`
50+
OverlayPodCIDR []string `json:"overlayPodCIDR,omitempty"`
51+
ServiceCIDR []string `json:"serviceCIDR,omitempty"`
52+
HijackCIDR []string `json:"hijackCIDR,omitempty"`
53+
TunePodRoutes *bool `json:"tunePodRoutes,omitempty"`
54+
PodDefaultRouteNIC string `json:"podDefaultRouteNic,omitempty"`
55+
Mode Mode `json:"mode,omitempty"`
56+
HostRuleTable *int64 `json:"hostRuleTable,omitempty"`
57+
HostRPFilter *int32 `json:"hostRPFilter,omitempty" `
58+
PodRPFilter *int32 `json:"podRPFilter,omitempty" `
59+
TxQueueLen *int64 `json:"txQueueLen,omitempty"`
60+
LogOptions *LogOptions `json:"logOptions,omitempty"`
6561
}
6662

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

145-
if conf.IPConflict == nil && coordinatorConfig.DetectIPConflict {
146-
conf.IPConflict = ptr.To(true)
147-
}
148-
149-
conf.DetectOptions, err = ValidateDelectOptions(conf.DetectOptions)
150-
if err != nil {
151-
return nil, err
152-
}
153-
154141
if conf.HostRuleTable == nil && coordinatorConfig.HostRuleTable > 0 {
155142
conf.HostRuleTable = ptr.To(coordinatorConfig.HostRuleTable)
156143
}
@@ -163,10 +150,6 @@ func ParseConfig(stdin []byte, coordinatorConfig *models.CoordinatorConfig) (*Co
163150
conf.HostRuleTable = ptr.To(int64(500))
164151
}
165152

166-
if conf.DetectGateway == nil {
167-
conf.DetectGateway = ptr.To(coordinatorConfig.DetectGateway)
168-
}
169-
170153
if conf.TunePodRoutes == nil {
171154
conf.TunePodRoutes = coordinatorConfig.TunePodRoutes
172155
}
@@ -270,37 +253,3 @@ func validateRPFilterConfig(rpfilter *int32, coordinatorConfig int64) (*int32, e
270253
}
271254
return rpfilter, nil
272255
}
273-
274-
func ValidateDelectOptions(config *DetectOptions) (*DetectOptions, error) {
275-
if config == nil {
276-
return &DetectOptions{
277-
Interval: "10ms",
278-
TimeOut: "100ms",
279-
Retry: 3,
280-
}, nil
281-
}
282-
283-
if config.Retry == 0 {
284-
config.Retry = 3
285-
}
286-
287-
if config.Interval == "" {
288-
config.Interval = "10ms"
289-
}
290-
291-
if config.TimeOut == "" {
292-
config.TimeOut = "500ms"
293-
}
294-
295-
_, err := time.ParseDuration(config.Interval)
296-
if err != nil {
297-
return nil, fmt.Errorf("invalid detectOptions.interval %s: %v, input like: 1s or 1m", config.Interval, err)
298-
}
299-
300-
_, err = time.ParseDuration(config.TimeOut)
301-
if err != nil {
302-
return nil, fmt.Errorf("invalid detectOptions.timeout %s: %v, input like: 1s or 1m", config.TimeOut, err)
303-
}
304-
305-
return config, nil
306-
}

0 commit comments

Comments
 (0)