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

Dual-stack Handling #612

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Dual-stack Handling #612

wants to merge 18 commits into from

Conversation

dbw7
Copy link
Contributor

@dbw7 dbw7 commented Nov 14, 2024

No description provided.

@dbw7 dbw7 requested a review from atanasdinov November 14, 2024 15:38
RELEASE_NOTES.md Outdated Show resolved Hide resolved
docs/building-images.md Outdated Show resolved Hide resolved
pkg/kubernetes/cluster.go Outdated Show resolved Hide resolved
pkg/combustion/templates/k3s-single-node-installer.sh.tpl Outdated Show resolved Hide resolved
pkg/combustion/templates/set-node-ip.sh.tpl Outdated Show resolved Hide resolved
pkg/combustion/templates/set-node-ip.sh.tpl Outdated Show resolved Hide resolved
pkg/kubernetes/cluster.go Show resolved Hide resolved
pkg/kubernetes/cluster.go Outdated Show resolved Hide resolved
pkg/kubernetes/cluster.go Outdated Show resolved Hide resolved
RELEASE_NOTES.md Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
@dbw7 dbw7 marked this pull request as ready for review December 4, 2024 17:31
RELEASE_NOTES.md Outdated Show resolved Hide resolved
docs/building-images.md Outdated Show resolved Hide resolved
RELEASE_NOTES.md Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
@@ -213,14 +213,14 @@ func TestConfigureKubernetes_ArtefactDownloaderErrorRKE2(t *testing.T) {
assert.Nil(t, scripts)
}

func TestConfigureKubernetes_SuccessfulSingleNodeK3sCluster(t *testing.T) {
func TestConfigureKubernetes_SuccessfulSingleNodeK3sClusterIPv4(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can afford to stretch these test cases that much. It's arguably similar to how we don't replicate these tests for all different CNIs. Do you mind discussing this offline?

"registryMirrors": prependArtefactPath(filepath.Join(k8sDir, registryMirrorsFileName)),
"configFilePath": prependArtefactPath(K8sDir),
"registryMirrors": prependArtefactPath(filepath.Join(K8sDir, registryMirrorsFileName)),
"setNodeIPScript": setNodeIPScript,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get this value from somewhere else? It's better to "tie" it with the rest of the code, where this is a variable that's returned by the function which has created it. Not an arbitrary constant.

pkg/kubernetes/cluster.go Outdated Show resolved Hide resolved
pkg/kubernetes/cluster.go Outdated Show resolved Hide resolved
Comment on lines +239 to +246
switch {
case ip6 != nil && prioritizeIPv6:
config[serverKey] = fmt.Sprintf("https://%s", netip.AddrPortFrom(*ip6, port).String())
case ip6 != nil && ip4 == nil:
config[serverKey] = fmt.Sprintf("https://%s", netip.AddrPortFrom(*ip6, port).String())
default:
config[serverKey] = fmt.Sprintf("https://%s", netip.AddrPortFrom(*ip4, port).String())
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I had to improve, I'd go with this. But I'm not convinced it should be part of this function. The code is the same for both so the checks could be extracted out of this and only a single address could be passed.

Suggested change
switch {
case ip6 != nil && prioritizeIPv6:
config[serverKey] = fmt.Sprintf("https://%s", netip.AddrPortFrom(*ip6, port).String())
case ip6 != nil && ip4 == nil:
config[serverKey] = fmt.Sprintf("https://%s", netip.AddrPortFrom(*ip6, port).String())
default:
config[serverKey] = fmt.Sprintf("https://%s", netip.AddrPortFrom(*ip4, port).String())
}
if ip6 != nil && (prioritizeIPv6 || ip4 == nil) {
config[serverKey] = fmt.Sprintf("https://%s", netip.AddrPortFrom(*ip6, port).String())
return
}
config[serverKey] = fmt.Sprintf("https://%s", netip.AddrPortFrom(*ip4, port).String())

return failures
}

func checkCIDR(cidrs []string) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we handle single-stack IPv6?

@dbw7 dbw7 requested a review from atanasdinov December 12, 2024 04:00
pkg/combustion/kubernetes.go Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
Comment on lines 237 to 239
if len(parsedClusterCIDRs) == 0 && len(parsedServiceCIDRs) == 0 {
return failures
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This essentially means that we're unable to catch bootstrap dual-stack config issues.

Comment on lines 241 to 253
if len(parsedServiceCIDRs) != 0 && len(parsedClusterCIDRs) == 0 {
failures = append(failures, FailedValidation{
UserMessage: "Kubernetes server config cluster-cidr must be defined when service-cidr is defined",
})

return failures
} else if len(parsedServiceCIDRs) == 0 && len(parsedClusterCIDRs) != 0 {
failures = append(failures, FailedValidation{
UserMessage: "Kubernetes server config service-cidr must be defined when cluster-cidr is defined",
})

return failures
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general (outside of dual-stack context), either of those should be configurable.

pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
pkg/combustion/kubernetes.go Outdated Show resolved Hide resolved
@dbw7 dbw7 requested a review from atanasdinov December 13, 2024 02:14
Copy link
Contributor

@atanasdinov atanasdinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another missing piece here is a bump of the apiVersion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants