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
6fad6358
Commit
6fad6358
authored
May 05, 2022
by
Brad Davidson
Committed by
Brad Davidson
Jun 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only listen on loopback when resetting
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
3399afed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
14 deletions
+38
-14
etcd.go
pkg/etcd/etcd.go
+38
-14
No files found.
pkg/etcd/etcd.go
View file @
6fad6358
...
...
@@ -756,35 +756,57 @@ func (e *ETCD) migrateFromSQLite(ctx context.Context) error {
return
os
.
Rename
(
sqliteFile
(
e
.
config
),
sqliteFile
(
e
.
config
)
+
".migrated"
)
}
// peerURL returns the
peer access address for the local node
// peerURL returns the
external peer access address for the local node.
func
(
e
*
ETCD
)
peerURL
()
string
{
return
fmt
.
Sprintf
(
"https://%s"
,
net
.
JoinHostPort
(
e
.
address
,
"2380"
))
}
// clientURL returns the client access address for the local node
// listenClientURLs returns a list of URLs to bind to for peer connections.
// During cluster reset/restore, we only listen on loopback to avoid having peers
// connect mid-process.
func
(
e
*
ETCD
)
listenPeerURLs
(
reset
bool
)
string
{
peerURLs
:=
fmt
.
Sprintf
(
"https://%s:2380"
,
e
.
config
.
Loopback
())
if
!
reset
{
peerURLs
+=
","
+
e
.
peerURL
()
}
return
peerURLs
}
// clientURL returns the external client access address for the local node.
func
(
e
*
ETCD
)
clientURL
()
string
{
return
fmt
.
Sprintf
(
"https://%s"
,
net
.
JoinHostPort
(
e
.
address
,
"2379"
))
}
// metricsURL returns the metrics access address
func
(
e
*
ETCD
)
metricsURL
(
expose
bool
)
string
{
address
:=
fmt
.
Sprintf
(
"http://%s:2381"
,
e
.
config
.
Loopback
())
if
expose
{
address
=
fmt
.
Sprintf
(
"http://%s,%s"
,
net
.
JoinHostPort
(
e
.
address
,
"2381"
),
address
)
// 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
// connect mid-process.
func
(
e
*
ETCD
)
listenClientURLs
(
reset
bool
)
string
{
clientURLs
:=
fmt
.
Sprintf
(
"https://%s:2379"
,
e
.
config
.
Loopback
())
if
!
reset
{
clientURLs
+=
","
+
e
.
clientURL
()
}
return
clientURLs
}
// listenMetricsURLs returns a list of URLs to bind to for metrics connections.
func
(
e
*
ETCD
)
listenMetricsURLs
(
reset
bool
)
string
{
metricsURLs
:=
fmt
.
Sprintf
(
"http://%s:2381"
,
e
.
config
.
Loopback
())
if
!
reset
&&
e
.
config
.
EtcdExposeMetrics
{
metricsURLs
+=
","
+
fmt
.
Sprintf
(
"http://%s"
,
net
.
JoinHostPort
(
e
.
address
,
"2381"
))
}
return
addres
s
return
metricsURL
s
}
// cluster
returns ETCDConfig for a cluster
func
(
e
*
ETCD
)
cluster
(
ctx
context
.
Context
,
forceNew
bool
,
options
executor
.
InitialOptions
)
error
{
// cluster
calls the executor to start etcd running with the provided configuration.
func
(
e
*
ETCD
)
cluster
(
ctx
context
.
Context
,
reset
bool
,
options
executor
.
InitialOptions
)
error
{
ctx
,
e
.
cancel
=
context
.
WithCancel
(
ctx
)
return
executor
.
ETCD
(
ctx
,
executor
.
ETCDConfig
{
Name
:
e
.
name
,
InitialOptions
:
options
,
ForceNewCluster
:
forceNew
,
ListenClientURLs
:
e
.
clientURL
()
+
","
+
fmt
.
Sprintf
(
"https://%s:2379"
,
e
.
config
.
Loopback
()
),
ListenMetricsURLs
:
e
.
metricsURL
(
e
.
config
.
EtcdExposeMetrics
),
ListenPeerURLs
:
e
.
peerURL
(
),
ForceNewCluster
:
reset
,
ListenClientURLs
:
e
.
listenClientURLs
(
reset
),
ListenMetricsURLs
:
e
.
listenMetricsURLs
(
reset
),
ListenPeerURLs
:
e
.
listenPeerURLs
(
reset
),
AdvertiseClientURLs
:
e
.
clientURL
(),
DataDir
:
DBDir
(
e
.
config
),
ServerTrust
:
executor
.
ServerTrust
{
...
...
@@ -799,6 +821,7 @@ func (e *ETCD) cluster(ctx context.Context, forceNew bool, options executor.Init
ClientCertAuth
:
true
,
TrustedCAFile
:
e
.
config
.
Runtime
.
ETCDPeerCA
,
},
SnapshotCount
:
10000
,
ElectionTimeout
:
5000
,
HeartbeatInterval
:
500
,
Logger
:
"zap"
,
...
...
@@ -842,6 +865,7 @@ func (e *ETCD) StartEmbeddedTemporary(ctx context.Context) error {
Logger
:
"zap"
,
HeartbeatInterval
:
500
,
ElectionTimeout
:
5000
,
SnapshotCount
:
10000
,
Name
:
e
.
name
,
LogOutputs
:
[]
string
{
"stderr"
},
ExperimentalInitialCorruptCheck
:
true
,
...
...
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