Skip to content
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

don't update multus configMap if multus don't install #2759

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions charts/spiderpool/templates/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ spec:
{{- end }}
- name: SPIDERPOOL_INIT_ENABLE_MULTUS_CONFIG
value: {{ .Values.multus.enableMultusConfig | quote }}
- name: SPIDERPOOL_INIT_INSTALL_MULTUS
value: {{ .Values.multus.multusCNI.install | quote }}
- name: SPIDERPOOL_INIT_DEFAULT_CNI_NAME
value: {{ .Values.multus.multusCNI.defaultCniCRName | quote }}
- name: SPIDERPOOL_INIT_DEFAULT_CNI_NAMESPACE
Expand Down
8 changes: 8 additions & 0 deletions cmd/spiderpool-init/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
ENVDefaultIPv6Gateway = "SPIDERPOOL_INIT_DEFAULT_IPV6_IPPOOL_GATEWAY"

ENVEnableMultusConfig = "SPIDERPOOL_INIT_ENABLE_MULTUS_CONFIG"
ENVInstallMultusCNI = "SPIDERPOOL_INIT_INSTALL_MULTUS"
ENVDefaultCNIDir = "SPIDERPOOL_INIT_DEFAULT_CNI_DIR"
ENVDefaultCNIName = "SPIDERPOOL_INIT_DEFAULT_CNI_NAME"
ENVDefaultCNINamespace = "SPIDERPOOL_INIT_DEFAULT_CNI_NAMESPACE"
Expand Down Expand Up @@ -89,6 +90,7 @@ type InitDefaultConfig struct {

// multuscniconfig
enableMultusConfig bool
installMultusCNI bool
DefaultCNIDir string
DefaultCNIName string
DefaultCNINamespace string
Expand Down Expand Up @@ -276,6 +278,12 @@ func parseENVAsDefault() InitDefaultConfig {
logger.Sugar().Fatalf("ENV %s: %s invalid: %v", ENVEnableMultusConfig, enableMultusConfig, err)
}

installMultusCNI := strings.ReplaceAll(os.Getenv(ENVInstallMultusCNI), "\"", "")
config.installMultusCNI, err = strconv.ParseBool(installMultusCNI)
if err != nil {
logger.Sugar().Fatalf("ENV %s: %s invalid: %v", ENVInstallMultusCNI, installMultusCNI, err)
}

config.DefaultCNIDir = strings.ReplaceAll(os.Getenv(ENVDefaultCNIDir), "\"", "")
if config.DefaultCNIDir != "" {
_, err = os.ReadDir(config.DefaultCNIDir)
Expand Down
5 changes: 5 additions & 0 deletions cmd/spiderpool-init/cmd/multus.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func InitMultusDefaultCR(ctx context.Context, config *InitDefaultConfig, client
return err
}

if !config.installMultusCNI {
logger.Sugar().Infof("No install MultusCNI, Ignore update clusterNetwork for multus configMap")
return nil
}

// get multus configMap
cm, err := getConfigMap(ctx, client, config.DefaultCNINamespace, config.MultusConfigMap)
if err != nil {
Expand Down
Loading