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

[Backport release-1.29] Fix etcd peer URL to support ipv6 #5192

Draft
wants to merge 1 commit into
base: release-1.29
Choose a base branch
from
Draft
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
10 changes: 10 additions & 0 deletions pkg/apis/k0s/v1beta1/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1beta1
import (
"encoding/json"
"fmt"
"net"
"net/url"
"path/filepath"
"strings"
Expand Down Expand Up @@ -161,6 +162,15 @@ func DefaultEtcdConfig() *EtcdConfig {
}
}

// GetPeerURL returns the URL of PeerAddress
func (e *EtcdConfig) GetPeerURL() string {
u := &url.URL{
Scheme: "https",
Host: net.JoinHostPort(e.PeerAddress, "2380"),
}
return u.String()
}

// DefaultKineConfig creates KineConfig with sane defaults
func DefaultKineConfig(dataDir string) *KineConfig {
// https://www.sqlite.org/c3ref/open.html#urifilenamesinsqlite3open
Expand Down
8 changes: 7 additions & 1 deletion pkg/backup/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ package backup
import (
"context"
"fmt"
"net"
"net/url"
"os"
"path/filepath"

Expand Down Expand Up @@ -84,7 +86,11 @@ func (e etcdStep) Restore(restoreFrom, _ string) error {
if err != nil {
return err
}
peerURL := fmt.Sprintf("https://%s:2380", e.peerAddress)
u := &url.URL{
Scheme: "https",
Host: net.JoinHostPort(e.peerAddress, "2380"),
}
peerURL := u.String()
restoreConfig := utilsnapshot.RestoreConfig{
SnapshotPath: snapshotPath,
OutputDataDir: e.etcdDataDir,
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/controller/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (e *Etcd) Start(ctx context.Context) error {
return err
}

peerURL := fmt.Sprintf("https://%s:2380", e.Config.PeerAddress)
peerURL := e.Config.GetPeerURL()

args := stringmap.StringMap{
"--data-dir": e.K0sVars.EtcdDataDir,
Expand Down
Loading