fix: add ipv6 support in cri-dockerd#3125
Conversation
Signed-off-by: redscholar <blacktiledhouse@gmail.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: redscholar The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
There was a problem hiding this comment.
Code Review
This pull request moves CNI configuration variables to the default CNI configuration file, adds dual-stack support to the cri-dockerd service when IPv6 is enabled, and fixes a duplicated https:// prefix in the etcd IPv6 endpoint templates for kubeadm. The reviewer provided feedback on improving template robustness: first, by explicitly checking .cni.ipv6_support against the string "true" to prevent incorrect evaluation of non-empty strings in Go templates; second, by adding default guards to the IPv4 CNI configuration fields to prevent template rendering failures when .cni.pod_cidr is undefined.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| [Service] | ||
| Type=notify | ||
| ExecStart=/usr/local/bin/cri-dockerd --pod-infra-container-image "{{ .kubernetes.sandbox_image.registry }}/{{ .kubernetes.sandbox_image.repository }}:{{ .kubernetes.sandbox_image.tag }}" | ||
| ExecStart=/usr/local/bin/cri-dockerd --pod-infra-container-image "{{ .kubernetes.sandbox_image.registry }}/{{ .kubernetes.sandbox_image.repository }}:{{ .kubernetes.sandbox_image.tag }}"{{if .cni.ipv6_support }} --ipv6-dual-stack{{ end }} |
There was a problem hiding this comment.
In Go templates, any non-empty string is evaluated as true by the if action. If .cni.ipv6_support is parsed or overridden as a string (e.g., "false"), {{if .cni.ipv6_support}} will evaluate to true, incorrectly enabling --ipv6-dual-stack.
To prevent this, you can use printf "%v" to safely convert the value to a string and compare it to "true":
{{if eq (printf "%v" .cni.ipv6_support) "true"}} --ipv6-dual-stack{{ end }}ExecStart=/usr/local/bin/cri-dockerd --pod-infra-container-image "{{ .kubernetes.sandbox_image.registry }}/{{ .kubernetes.sandbox_image.repository }}:{{ .kubernetes.sandbox_image.tag }}"{{if eq (printf "%v" .cni.ipv6_support) "true" }} --ipv6-dual-stack{{ end }}
| ipv4_support: >- | ||
| {{ eq (.cni.pod_cidr | splitList "," | first | ipFamily) "IPv4" }} | ||
| ipv4_pods_cidr: >- | ||
| {{- if eq (.cni.pod_cidr | splitList "," | first | ipFamily) "IPv4" -}} | ||
| {{ .cni.pod_cidr | splitList "," | first }} | ||
| {{- end -}} |
There was a problem hiding this comment.
The ipv6_support and ipv6_pods_cidr fields use default "10.233.64.0/18" to guard against an empty or undefined .cni.pod_cidr. However, ipv4_support and ipv4_pods_cidr do not have this default guard. If .cni.pod_cidr is empty or undefined, ipFamily will be called with an empty string, returning an error and causing the template rendering to fail.
For consistency and robustness, please add the default guard to the IPv4 fields as well.
ipv4_support: >-
{{ eq (.cni.pod_cidr | default "10.233.64.0/18" | splitList "," | first | ipFamily) "IPv4" }}
ipv4_pods_cidr: >-
{{- if eq (.cni.pod_cidr | default "10.233.64.0/18" | splitList "," | first | ipFamily) "IPv4" -}}
{{ .cni.pod_cidr | default "10.233.64.0/18" | splitList "," | first }}
{{- end -}}


What type of PR is this?
/kind bug
What this PR does / why we need it:
Fix bugs related to CRI configuration handling and cluster node labeling.
whenconditions for CRI tasks (containerd and docker), ensuring proper file existence checks before generating configuration files.delegate_todirective for the "Add custom labels to the cluster nodes" task increate_cluster.yamlto ensure labels are applied via the correct initialization node.Which issue(s) this PR fixes:
Fixes #
https://github.com/kubesphere/project/issues/7611
Special notes for reviewers:
Does this PR introduced a user-facing change?
Additional documentation, usage docs, etc.: