-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
supplement spidermultusconfig default value #2622
Conversation
2379b7d
to
9d703c9
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2622 +/- ##
==========================================
- Coverage 80.87% 80.82% -0.06%
==========================================
Files 49 49
Lines 5303 5303
==========================================
- Hits 4289 4286 -3
- Misses 857 859 +2
- Partials 157 158 +1
Flags with carried forward coverage won't be shown. Click here to find out more. |
plugins = append([]interface{}{macvlanCNIConf}, plugins...) | ||
if len(multusConfSpec.MacvlanConfig.Master) > 0 || (multusConfSpec.MacvlanConfig.VlanID != nil && *multusConfSpec.MacvlanConfig.VlanID != 0) { | ||
if multusConfSpec.MacvlanConfig.VlanID != nil && *multusConfSpec.MacvlanConfig.VlanID != 0 { | ||
// we need to set Subvlan as first at the CNI plugin chain | ||
subVlanCNIConf := generateIfacer(multusConfSpec.MacvlanConfig.Master, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要ifacer的情况:
- 指定了单卡 + vlan
- 指定了多网卡组bond + vlan (ifacer代码中bond需要结合vlan一起使用)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
指定了多网卡组bond + vlan (ifacer代码中bond需要结合vlan一起使用)
多卡 或 vlanId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spiderpool/cmd/ifacer/cmd/cmd_add.go
Lines 44 to 56 in d97cc55
default: | |
if conf.Bond == nil { | |
return types.PrintResult(result, conf.CNIVersion) | |
} | |
bond, err := createBondDevice(conf) | |
if err != nil { | |
return fmt.Errorf("failed to createBondDevice: %v", err) | |
} | |
if conf.VlanID == 0 { | |
return types.PrintResult(result, conf.CNIVersion) | |
} |
多卡下vlan为0,直接return了。因此此处只需要判断vlan是否被设置才调用ifacer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多网卡时需要 ifacer 创建bond
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以此处54-56行有bug?
设置了多网卡,但是又没有设置vlan。 然后ifacer单纯的就创建了一个bond网卡(没有slave指定网卡),就因为vlan==0就return了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
逻辑没问题,没vlan 就建bond就行了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @weizhoublue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len(multusConfSpec.MacvlanConfig.Master) > 0 这个逻辑 应该在的吧 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多网卡组bond可以使用vlan0,因此此处判断为len(multusConfSpec.MacvlanConfig.Master) >= 2
此处ifacer有bug,已关联issue:#2638
func setBondDefaultConfig(bond *spiderpoolv2beta1.BondConfig) *spiderpoolv2beta1.BondConfig { | ||
if bond == nil { | ||
return &spiderpoolv2beta1.BondConfig{ | ||
Name: "", | ||
Mode: 0, | ||
Options: pointer.String(""), | ||
} | ||
} | ||
|
||
if bond.Options == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无需给bond赋空值。
webhook validate已做校验,若指定了多网卡但未设置bond会报错。
此处,单网卡下就无需展示bond
plugins = append([]interface{}{macvlanCNIConf}, plugins...) | ||
if len(multusConfSpec.MacvlanConfig.Master) > 0 || (multusConfSpec.MacvlanConfig.VlanID != nil && *multusConfSpec.MacvlanConfig.VlanID != 0) { | ||
if multusConfSpec.MacvlanConfig.VlanID != nil && *multusConfSpec.MacvlanConfig.VlanID != 0 { | ||
// we need to set Subvlan as first at the CNI plugin chain | ||
subVlanCNIConf := generateIfacer(multusConfSpec.MacvlanConfig.Master, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
指定了多网卡组bond + vlan (ifacer代码中bond需要结合vlan一起使用)
多卡 或 vlanId
9d703c9
to
0fd6c10
Compare
Signed-off-by: Icarus9913 <icaruswu66@qq.com>
0fd6c10
to
8c4d334
Compare
supplement spidermultusconfig default value
omitempty
tagenhancement for #2603
Signed-off-by: Icarus9913 icaruswu66@qq.com