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

clarify error getting ipv6 address on node #1960

Merged
merged 1 commit into from
Dec 4, 2020
Merged
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
12 changes: 7 additions & 5 deletions pkg/cluster/internal/create/actions/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package config
import (
"bytes"
"fmt"
"net"
"strings"

"sigs.k8s.io/kind/pkg/cluster/constants"
Expand Down Expand Up @@ -60,8 +61,9 @@ func (a *Action) Execute(ctx *actions.ActionContext) error {
// create kubeadm init config
fns := []func() error{}

provider := fmt.Sprintf("%s", ctx.Provider)
BenTheElder marked this conversation as resolved.
Show resolved Hide resolved
configData := kubeadm.ConfigData{
NodeProvider: fmt.Sprintf("%s", ctx.Provider),
NodeProvider: provider,
ClusterName: ctx.Config.Name,
ControlPlaneEndpoint: controlPlaneEndpoint,
APIBindPort: common.APIServerInternalPort,
Expand All @@ -79,7 +81,7 @@ func (a *Action) Execute(ctx *actions.ActionContext) error {
kubeadmConfigPlusPatches := func(node nodes.Node, data kubeadm.ConfigData) func() error {
return func() error {
data.NodeName = node.String()
kubeadmConfig, err := getKubeadmConfig(ctx.Config, data, node)
kubeadmConfig, err := getKubeadmConfig(ctx.Config, data, node, provider)
if err != nil {
// TODO(bentheelder): logging here
return errors.Wrap(err, "failed to generate kubeadm config content")
Expand Down Expand Up @@ -166,7 +168,7 @@ func (a *Action) Execute(ctx *actions.ActionContext) error {

// getKubeadmConfig generates the kubeadm config contents for the cluster
// by running data through the template and applying patches as needed.
func getKubeadmConfig(cfg *config.Cluster, data kubeadm.ConfigData, node nodes.Node) (path string, err error) {
func getKubeadmConfig(cfg *config.Cluster, data kubeadm.ConfigData, node nodes.Node, provider string) (path string, err error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I doubted between passing the whole context or adding a new argument, since it is only a string and doesn't look like this is going to grow much, I pick the later

Copy link
Member

Choose a reason for hiding this comment

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

I still need to take a sledgehammer to this code anyhow :-)

this is a reasonable approach for now 👍

kubeVersion, err := nodeutils.KubeVersion(node)
if err != nil {
// TODO(bentheelder): logging here
Expand Down Expand Up @@ -200,8 +202,8 @@ func getKubeadmConfig(cfg *config.Cluster, data kubeadm.ConfigData, node nodes.N
data.NodeAddress = nodeAddress
// configure the right protocol addresses
if cfg.Networking.IPFamily == "ipv6" {
if nodeAddressIPv6 == "" {
return "", errors.Errorf("failed to get IPV6 address; is the container provider (docker,podman) configured to use IPV6 correctly?")
if ip := net.ParseIP(nodeAddressIPv6); ip.To16() == nil {
return "", errors.Errorf("failed to get IPv6 address for node %s; is %s configured to use IPv6 correctly?", node.String(), provider)
}
data.NodeAddress = nodeAddressIPv6
}
Expand Down