Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b010db0c
Commit
b010db0c
authored
Mar 24, 2023
by
Brad Davidson
Committed by
Brad Davidson
Apr 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that loopback is used for the advertised address when resetting
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
877247a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
etcd.go
pkg/etcd/etcd.go
+17
-7
No files found.
pkg/etcd/etcd.go
View file @
b010db0c
...
@@ -182,7 +182,7 @@ func (e *ETCD) SetControlConfig(ctx context.Context, config *config.Control) err
...
@@ -182,7 +182,7 @@ func (e *ETCD) SetControlConfig(ctx context.Context, config *config.Control) err
e
.
client
.
Close
()
e
.
client
.
Close
()
}()
}()
address
,
err
:=
G
etAdvertiseAddress
(
config
.
PrivateIP
)
address
,
err
:=
g
etAdvertiseAddress
(
config
.
PrivateIP
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -537,7 +537,7 @@ func (e *ETCD) Register(ctx context.Context, config *config.Control, handler htt
...
@@ -537,7 +537,7 @@ func (e *ETCD) Register(ctx context.Context, config *config.Control, handler htt
e
.
client
.
Close
()
e
.
client
.
Close
()
}()
}()
address
,
err
:=
G
etAdvertiseAddress
(
config
.
PrivateIP
)
address
,
err
:=
g
etAdvertiseAddress
(
config
.
PrivateIP
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -708,7 +708,7 @@ func toTLSConfig(runtime *config.ControlRuntime) (*tls.Config, error) {
...
@@ -708,7 +708,7 @@ func toTLSConfig(runtime *config.ControlRuntime) (*tls.Config, error) {
}
}
// getAdvertiseAddress returns the IP address best suited for advertising to clients
// getAdvertiseAddress returns the IP address best suited for advertising to clients
func
G
etAdvertiseAddress
(
advertiseIP
string
)
(
string
,
error
)
{
func
g
etAdvertiseAddress
(
advertiseIP
string
)
(
string
,
error
)
{
ip
:=
advertiseIP
ip
:=
advertiseIP
if
ip
==
""
{
if
ip
==
""
{
ipAddr
,
err
:=
utilnet
.
ChooseHostInterface
()
ipAddr
,
err
:=
utilnet
.
ChooseHostInterface
()
...
@@ -809,9 +809,19 @@ func (e *ETCD) clientURL() string {
...
@@ -809,9 +809,19 @@ func (e *ETCD) clientURL() string {
return
fmt
.
Sprintf
(
"https://%s"
,
net
.
JoinHostPort
(
e
.
address
,
"2379"
))
return
fmt
.
Sprintf
(
"https://%s"
,
net
.
JoinHostPort
(
e
.
address
,
"2379"
))
}
}
// advertiseClientURLs returns the advertised addresses for the local node.
// During cluster reset/restore we only listen on loopback to avoid having apiservers
// on other nodes connect mid-process.
func
(
e
*
ETCD
)
advertiseClientURLs
(
reset
bool
)
string
{
if
reset
{
return
fmt
.
Sprintf
(
"https://%s"
,
net
.
JoinHostPort
(
e
.
config
.
Loopback
(
true
),
"2379"
))
}
return
e
.
clientURL
()
}
// listenClientURLs returns a list of URLs to bind to for client connections.
// listenClientURLs returns a list of URLs to bind to for client connections.
// During cluster reset/restore, we only listen on loopback to avoid having
the apiserver
// During cluster reset/restore, we only listen on loopback to avoid having
apiservers
// connect mid-process.
//
on other nodes
connect mid-process.
func
(
e
*
ETCD
)
listenClientURLs
(
reset
bool
)
string
{
func
(
e
*
ETCD
)
listenClientURLs
(
reset
bool
)
string
{
clientURLs
:=
fmt
.
Sprintf
(
"https://%s:2379"
,
e
.
config
.
Loopback
(
true
))
clientURLs
:=
fmt
.
Sprintf
(
"https://%s:2379"
,
e
.
config
.
Loopback
(
true
))
if
!
reset
{
if
!
reset
{
...
@@ -839,7 +849,7 @@ func (e *ETCD) cluster(ctx context.Context, reset bool, options executor.Initial
...
@@ -839,7 +849,7 @@ func (e *ETCD) cluster(ctx context.Context, reset bool, options executor.Initial
ListenClientURLs
:
e
.
listenClientURLs
(
reset
),
ListenClientURLs
:
e
.
listenClientURLs
(
reset
),
ListenMetricsURLs
:
e
.
listenMetricsURLs
(
reset
),
ListenMetricsURLs
:
e
.
listenMetricsURLs
(
reset
),
ListenPeerURLs
:
e
.
listenPeerURLs
(
reset
),
ListenPeerURLs
:
e
.
listenPeerURLs
(
reset
),
AdvertiseClientURLs
:
e
.
clientURL
(
),
AdvertiseClientURLs
:
e
.
advertiseClientURLs
(
reset
),
DataDir
:
DBDir
(
e
.
config
),
DataDir
:
DBDir
(
e
.
config
),
ServerTrust
:
executor
.
ServerTrust
{
ServerTrust
:
executor
.
ServerTrust
{
CertFile
:
e
.
config
.
Runtime
.
ServerETCDCert
,
CertFile
:
e
.
config
.
Runtime
.
ServerETCDCert
,
...
@@ -1142,7 +1152,7 @@ func ClientURLs(ctx context.Context, clientAccessInfo *clientaccess.Info, selfIP
...
@@ -1142,7 +1152,7 @@ func ClientURLs(ctx context.Context, clientAccessInfo *clientaccess.Info, selfIP
if
err
:=
json
.
Unmarshal
(
resp
,
&
memberList
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
resp
,
&
memberList
);
err
!=
nil
{
return
nil
,
memberList
,
err
return
nil
,
memberList
,
err
}
}
ip
,
err
:=
G
etAdvertiseAddress
(
selfIP
)
ip
,
err
:=
g
etAdvertiseAddress
(
selfIP
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
memberList
,
err
return
nil
,
memberList
,
err
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment