-
Notifications
You must be signed in to change notification settings - Fork 799
Add chaining tuning plugin #3587
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,6 +84,7 @@ const ( | |
| defaultIPCooldownPeriod = 30 | ||
| defaultDisablePodV6 = false | ||
| defaultEnableMultiNICSupport = false | ||
| defaultEnableTuningPlugin = false | ||
|
|
||
| envHostCniBinPath = "HOST_CNI_BIN_PATH" | ||
| envHostCniConfDirPath = "HOST_CNI_CONFDIR_PATH" | ||
|
|
@@ -108,6 +109,8 @@ const ( | |
| envIPCooldownPeriod = "IP_COOLDOWN_PERIOD" | ||
| envDisablePodV6 = "DISABLE_POD_V6" | ||
| envEnableMultiNICSupport = "ENABLE_MULTI_NIC" | ||
| envEnableTuningPlugin = "ENABLE_TUNING_PLUGIN" | ||
| envTuningSysctls = "TUNING_SYSCTLS" | ||
| ) | ||
|
|
||
| // NetConfList describes an ordered list of networks. | ||
|
|
@@ -288,7 +291,13 @@ func generateJSON(jsonFile string, outFile string, getPrimaryIP func(ipv4 bool) | |
| // Chain any requested CNI plugins | ||
| enBandwidthPlugin := utils.GetBoolAsStringEnvVar(envEnBandwidthPlugin, defaultEnBandwidthPlugin) | ||
| disablePodV6 := utils.GetBoolAsStringEnvVar(envDisablePodV6, defaultDisablePodV6) | ||
| if enBandwidthPlugin || disablePodV6 { | ||
| enableTuningPlugin := utils.GetBoolAsStringEnvVar(envEnableTuningPlugin, defaultEnableTuningPlugin) | ||
| tuningSysctls := utils.GetEnv(envTuningSysctls, "") | ||
|
|
||
| // Determine if we need to chain the tuning plugin | ||
| chainTuningPlugin := disablePodV6 || enableTuningPlugin || tuningSysctls != "" | ||
|
|
||
| if enBandwidthPlugin || chainTuningPlugin { | ||
| // Unmarshall current conflist into data | ||
| data := NetConfList{} | ||
| err = json.Unmarshal(byteValue, &data) | ||
|
|
@@ -305,15 +314,33 @@ func generateJSON(jsonFile string, outFile string, getPrimaryIP func(ipv4 bool) | |
| data.Plugins = append(data.Plugins, &bwPlugin) | ||
| } | ||
|
|
||
| // Chain the tuning plugin (configured to disable IPv6 in pod network namespace) when requested | ||
| if disablePodV6 { | ||
| // Chain the tuning plugin when enabled via DISABLE_POD_V6, ENABLE_TUNING_PLUGIN, or TUNING_SYSCTLS | ||
| if chainTuningPlugin { | ||
| sysctls := make(map[string]string) | ||
|
|
||
| // Add IPv6 disable sysctls when DISABLE_POD_V6 is enabled | ||
| if disablePodV6 { | ||
| sysctls["net.ipv6.conf.all.disable_ipv6"] = "1" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need to explicitly add these?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because VPC CNI currently use tuning CN plugin to disable ipv6. This is just keeping that feature
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i wonder if i need to move this lower and override any tuning configs |
||
| sysctls["net.ipv6.conf.default.disable_ipv6"] = "1" | ||
| sysctls["net.ipv6.conf.lo.disable_ipv6"] = "1" | ||
| } | ||
|
|
||
| // Parse and merge custom sysctls from TUNING_SYSCTLS environment variable | ||
| if tuningSysctls != "" { | ||
| customSysctls := make(map[string]string) | ||
| err = json.Unmarshal([]byte(tuningSysctls), &customSysctls) | ||
| if err != nil { | ||
| log.Errorf("Failed to parse TUNING_SYSCTLS: %v", err) | ||
| return err | ||
| } | ||
| for k, v := range customSysctls { | ||
| sysctls[k] = v | ||
| } | ||
| } | ||
|
|
||
| tuningPlugin := NetConf{ | ||
| Type: "tuning", | ||
| Sysctl: map[string]string{ | ||
| "net.ipv6.conf.all.disable_ipv6": "1", | ||
| "net.ipv6.conf.default.disable_ipv6": "1", | ||
| "net.ipv6.conf.lo.disable_ipv6": "1", | ||
| }, | ||
| Type: "tuning", | ||
| Sysctl: sysctls, | ||
| } | ||
| data.Plugins = append(data.Plugins, &tuningPlugin) | ||
| } | ||
|
|
||
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.
TOL does user have to provide value through env var? what will be experience if we had config map?
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.
This wasn't completely sure about. I was thinking env var however config map could work too however I didn't want to add a whole new config map just for this because it seems over kill