Skip to content

Commit 97fa9e8

Browse files
authored
SpiderMultusConfig: Fix error json tag for min/maxTxRateMbps (#4716)
Signed-off-by: Cyclinder Kuo <[email protected]> Signed-off-by: cyclinder <[email protected]>
1 parent 81ae7e5 commit 97fa9e8

File tree

5 files changed

+35
-12
lines changed

5 files changed

+35
-12
lines changed

docs/usage/spider-multus-config-zh_CN.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ spec:
387387
config: '{"cniVersion":"0.3.1","name":"sriov-rdma","plugins":[{"vlan":100,"type":"sriov","ipam":{"type":"spiderpool"}},{"type":"rdma"},{"type":"coordinator"}]}'
388388
```
389389

390-
- 配置 Sriov 网络带宽
390+
- 限制 Sriov VF 传输带宽
391391

392-
我们可通过 SpiderMultusConfig 配置 Sriov 的网络带宽:
392+
我们可通过 SpiderMultusConfig 限制 Sriov VF 传输带宽:
393393

394394
```bash
395395
cat <<EOF | kubectl apply -f -
@@ -405,11 +405,11 @@ spec:
405405
resourceName: spidernet.io/sriov_netdeivce
406406
vlanID: 100
407407
minTxRateMbps: 100
408-
MaxTxRateMbps: 1000
408+
maxTxRateMbps: 1000
409409
EOF
410410
```
411411

412-
> `minTxRateMbps``MaxTxRateMbps` 配置此 CNI 配置文件的网络传输带宽范围为: [100,1000]
412+
> `minTxRateMbps``maxTxRateMbps` 配置此 CNI 配置文件的网络传输带宽范围为: [100,1000]
413413

414414
创建后,查看对应的 Multus NetworkAttachmentDefinition CR:
415415

@@ -430,7 +430,7 @@ metadata:
430430
name: sriov-bandwidth
431431
uid: b08ce054-1ae8-414a-b37c-7fd6988b1b8e
432432
spec:
433-
config: '{"cniVersion":"0.3.1","name":"sriov-bandwidth","plugins":[{"vlan":100,"type":"sriov","minTxRate": 100, "maxTxRate": 1000,"ipam":{"type":"spiderpool"}},{"type":"rdma"},{"type":"coordinator"}]}'
433+
config: '{"cniVersion":"0.3.1","name":"sriov-bandwidth","plugins":[{"vlan":100,"type":"sriov","min_tx_rate": 100, "max_tx_rate": 1000,"ipam":{"type":"spiderpool"}},{"type":"rdma"},{"type":"coordinator"}]}'
434434
```
435435

436436
- 配置 Sriov VF 的 MTU 大小
@@ -475,7 +475,7 @@ metadata:
475475
name: sriov-bandwidth
476476
uid: b08ce054-1ae8-414a-b37c-7fd6988b1b8e
477477
spec:
478-
config: '{"cniVersion":"0.3.1","name":"sriov-bandwidth","plugins":[{"vlan":100,"type":"sriov","minTxRate": 100, "maxTxRate": 1000,"ipam":{"type":"spiderpool"}},{"type":"rdma"},{"type":"coordinator"},{"type":"tuning","mtu":8000}]}'
478+
config: '{"cniVersion":"0.3.1","name":"sriov-bandwidth","plugins":[{"vlan":100,"type":"sriov","min_tx_rate": 0, "max_tx_rate": 0,"ipam":{"type":"spiderpool"}},{"type":"rdma"},{"type":"coordinator"},{"type":"tuning","mtu":8000}]}'
479479
```
480480

481481
### Ifacer 使用配置

docs/usage/spider-multus-config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ spec:
411411
EOF
412412
```
413413
414-
> minTxRateMbps and MaxTxRateMbps configure the transmission bandwidth range for pods created with this configuration: [100,1000].
414+
> minTxRateMbps and maxTxRateMbps configure the transmission bandwidth range for pods created with this configuration: [100,1000].
415415
416416
After creation, check the corresponding Multus NetworkAttachmentDefinition CR:
417417
@@ -432,7 +432,7 @@ metadata:
432432
name: sriov-bandwidth
433433
uid: b08ce054-1ae8-414a-b37c-7fd6988b1b8e
434434
spec:
435-
config: '{"cniVersion":"0.3.1","name":"sriov-bandwidth","plugins":[{"vlan":100,"type":"sriov","minTxRate": 100, "maxTxRate": 1000,"ipam":{"type":"spiderpool"}},{"type":"rdma"},{"type":"coordinator"}]}'
435+
config: '{"cniVersion":"0.3.1","name":"sriov-bandwidth","plugins":[{"vlan":100,"type":"sriov","min_tx_rate": 100, "max_tx_rate": 1000,"ipam":{"type":"spiderpool"}},{"type":"rdma"},{"type":"coordinator"}]}'
436436
```
437437
438438
- Configure the mtu size of the Sriov VF

pkg/constant/k8s.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ const (
170170
IPoIBCNI = "ipoib"
171171
OvsCNI = "ovs"
172172
CustomCNI = "custom"
173+
TuningCNI = "tuning"
173174
)
174175

175176
const WebhookMutateRoute = "/webhook-health-check"

pkg/multuscniconfig/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ type IPvlanNetConf struct {
5252
type SRIOVNetConf struct {
5353
Vlan *int32 `json:"vlan,omitempty"`
5454
// Mbps, 0 = disable rate limiting
55-
MinTxRate *int `json:"minTxRate,omitempty"`
55+
MinTxRate *int `json:"min_tx_rate,omitempty"`
5656
// Mbps, 0 = disable rate limiting
57-
MaxTxRate *int `json:"maxTxRate,omitempty"`
57+
MaxTxRate *int `json:"max_tx_rate,omitempty"`
5858
Type string `json:"type"`
5959
DeviceID string `json:"deviceID,omitempty"`
6060
IPAM *spiderpoolcmd.IPAMConfig `json:"ipam,omitempty"`

test/e2e/spidermultus/spidermultus_test.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() {
11951195
}, common.SpiderSyncMultusTime, common.ForcedWaitingTime).Should(BeTrue())
11961196
})
11971197

1198-
It("test the multusConfig with mtu size for sriov", Label("M00035"), func() {
1198+
It("test the multusConfig with for sriov", Label("M00035"), func() {
11991199
smcName := "mtu" + common.GenerateString(10, true)
12001200
smc := &v2beta1.SpiderMultusConfig{
12011201
ObjectMeta: metav1.ObjectMeta{
@@ -1208,6 +1208,8 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() {
12081208
MTU: ptr.To(int32(-1)),
12091209
ResourceName: ptr.To("spidernet.io/test"),
12101210
RdmaIsolation: ptr.To(true),
1211+
MinTxRateMbps: ptr.To(int(10)),
1212+
MaxTxRateMbps: ptr.To(int(30)),
12111213
},
12121214
},
12131215
}
@@ -1225,7 +1227,27 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() {
12251227
nad, err := frame.GetMultusInstance(smcName, namespace)
12261228
if err == nil {
12271229
GinkgoWriter.Printf("Multus Nad created: %+v \n", nad.Spec.Config)
1228-
return true
1230+
config, err := libcni.ConfListFromBytes([]byte(nad.Spec.Config))
1231+
Expect(err).NotTo(HaveOccurred())
1232+
1233+
sriov, tuning := false, false
1234+
for _, p := range config.Plugins {
1235+
c := make(map[string]interface{})
1236+
err = json.Unmarshal(p.Bytes, &c)
1237+
Expect(err).NotTo(HaveOccurred())
1238+
1239+
if c["type"] == constant.SriovCNI {
1240+
Expect(c["min_tx_rate"]).To(Equal(float64(10)))
1241+
Expect(c["max_tx_rate"]).To(Equal(float64(30)))
1242+
sriov = true
1243+
}
1244+
1245+
if c["type"] == constant.TuningCNI {
1246+
Expect(c["mtu"]).To(Equal(float64(1400)))
1247+
tuning = true
1248+
}
1249+
}
1250+
return sriov && tuning
12291251
}
12301252

12311253
Expect(err.Error()).To(ContainSubstring("not found"))

0 commit comments

Comments
 (0)