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
a1b800f0
Commit
a1b800f0
authored
Feb 25, 2022
by
Brad Davidson
Committed by
Brad Davidson
Feb 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary copies of etcdconfig struct
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
2989b8b2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
11 additions
and
20 deletions
+11
-20
bootstrap.go
pkg/cluster/bootstrap.go
+1
-1
bootstrap_test.go
pkg/cluster/bootstrap_test.go
+0
-6
cluster.go
pkg/cluster/cluster.go
+3
-4
storage.go
pkg/cluster/storage.go
+3
-4
server.go
pkg/daemons/control/server.go
+0
-1
controller.go
pkg/secretsencrypt/controller.go
+1
-1
secrets-encrypt.go
pkg/server/secrets-encrypt.go
+3
-3
No files found.
pkg/cluster/bootstrap.go
View file @
a1b800f0
...
@@ -386,7 +386,7 @@ func (c *Cluster) ReconcileBootstrapData(ctx context.Context, buf io.ReadSeeker,
...
@@ -386,7 +386,7 @@ func (c *Cluster) ReconcileBootstrapData(ctx context.Context, buf io.ReadSeeker,
if
ec
!=
nil
{
if
ec
!=
nil
{
etcdConfig
=
*
ec
etcdConfig
=
*
ec
}
else
{
}
else
{
etcdConfig
=
c
.
EtcdConfig
etcdConfig
=
c
.
config
.
Runtime
.
EtcdConfig
}
}
storageClient
,
err
:=
client
.
New
(
etcdConfig
)
storageClient
,
err
:=
client
.
New
(
etcdConfig
)
...
...
pkg/cluster/bootstrap_test.go
View file @
a1b800f0
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
"testing"
"testing"
"time"
"time"
"github.com/k3s-io/kine/pkg/endpoint"
"github.com/rancher/k3s/pkg/bootstrap"
"github.com/rancher/k3s/pkg/bootstrap"
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/cluster/managed"
"github.com/rancher/k3s/pkg/cluster/managed"
...
@@ -90,7 +89,6 @@ func TestCluster_certDirsExist(t *testing.T) {
...
@@ -90,7 +89,6 @@ func TestCluster_certDirsExist(t *testing.T) {
clientAccessInfo
*
clientaccess
.
Info
clientAccessInfo
*
clientaccess
.
Info
config
*
config
.
Control
config
*
config
.
Control
managedDB
managed
.
Driver
managedDB
managed
.
Driver
etcdConfig
endpoint
.
ETCDConfig
shouldBootstrap
bool
shouldBootstrap
bool
storageStarted
bool
storageStarted
bool
saveBootstrap
bool
saveBootstrap
bool
...
@@ -131,7 +129,6 @@ func TestCluster_certDirsExist(t *testing.T) {
...
@@ -131,7 +129,6 @@ func TestCluster_certDirsExist(t *testing.T) {
clientAccessInfo
:
tt
.
fields
.
clientAccessInfo
,
clientAccessInfo
:
tt
.
fields
.
clientAccessInfo
,
config
:
tt
.
fields
.
config
,
config
:
tt
.
fields
.
config
,
managedDB
:
tt
.
fields
.
managedDB
,
managedDB
:
tt
.
fields
.
managedDB
,
EtcdConfig
:
tt
.
fields
.
etcdConfig
,
storageStarted
:
tt
.
fields
.
storageStarted
,
storageStarted
:
tt
.
fields
.
storageStarted
,
saveBootstrap
:
tt
.
fields
.
saveBootstrap
,
saveBootstrap
:
tt
.
fields
.
saveBootstrap
,
}
}
...
@@ -152,7 +149,6 @@ func TestCluster_migrateBootstrapData(t *testing.T) {
...
@@ -152,7 +149,6 @@ func TestCluster_migrateBootstrapData(t *testing.T) {
clientAccessInfo
*
clientaccess
.
Info
clientAccessInfo
*
clientaccess
.
Info
config
*
config
.
Control
config
*
config
.
Control
managedDB
managed
.
Driver
managedDB
managed
.
Driver
etcdConfig
endpoint
.
ETCDConfig
joining
bool
joining
bool
storageStarted
bool
storageStarted
bool
saveBootstrap
bool
saveBootstrap
bool
...
@@ -207,7 +203,6 @@ func TestCluster_Snapshot(t *testing.T) {
...
@@ -207,7 +203,6 @@ func TestCluster_Snapshot(t *testing.T) {
clientAccessInfo
*
clientaccess
.
Info
clientAccessInfo
*
clientaccess
.
Info
config
*
config
.
Control
config
*
config
.
Control
managedDB
managed
.
Driver
managedDB
managed
.
Driver
etcdConfig
endpoint
.
ETCDConfig
joining
bool
joining
bool
storageStarted
bool
storageStarted
bool
saveBootstrap
bool
saveBootstrap
bool
...
@@ -238,7 +233,6 @@ func TestCluster_Snapshot(t *testing.T) {
...
@@ -238,7 +233,6 @@ func TestCluster_Snapshot(t *testing.T) {
clientAccessInfo
:
tt
.
fields
.
clientAccessInfo
,
clientAccessInfo
:
tt
.
fields
.
clientAccessInfo
,
config
:
tt
.
fields
.
config
,
config
:
tt
.
fields
.
config
,
managedDB
:
tt
.
fields
.
managedDB
,
managedDB
:
tt
.
fields
.
managedDB
,
EtcdConfig
:
tt
.
fields
.
etcdConfig
,
joining
:
tt
.
fields
.
joining
,
joining
:
tt
.
fields
.
joining
,
storageStarted
:
tt
.
fields
.
storageStarted
,
storageStarted
:
tt
.
fields
.
storageStarted
,
saveBootstrap
:
tt
.
fields
.
saveBootstrap
,
saveBootstrap
:
tt
.
fields
.
saveBootstrap
,
...
...
pkg/cluster/cluster.go
View file @
a1b800f0
...
@@ -19,7 +19,6 @@ type Cluster struct {
...
@@ -19,7 +19,6 @@ type Cluster struct {
clientAccessInfo
*
clientaccess
.
Info
clientAccessInfo
*
clientaccess
.
Info
config
*
config
.
Control
config
*
config
.
Control
managedDB
managed
.
Driver
managedDB
managed
.
Driver
EtcdConfig
endpoint
.
ETCDConfig
joining
bool
joining
bool
storageStarted
bool
storageStarted
bool
saveBootstrap
bool
saveBootstrap
bool
...
@@ -84,7 +83,7 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) {
...
@@ -84,7 +83,7 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) {
// if necessary, store bootstrap data to datastore
// if necessary, store bootstrap data to datastore
if
c
.
saveBootstrap
{
if
c
.
saveBootstrap
{
if
err
:=
Save
(
ctx
,
c
.
config
,
c
.
EtcdConfig
,
false
);
err
!=
nil
{
if
err
:=
Save
(
ctx
,
c
.
config
,
false
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
}
}
...
@@ -98,7 +97,7 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) {
...
@@ -98,7 +97,7 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) {
for
{
for
{
select
{
select
{
case
<-
ready
:
case
<-
ready
:
if
err
:=
Save
(
ctx
,
c
.
config
,
c
.
EtcdConfig
,
false
);
err
!=
nil
{
if
err
:=
Save
(
ctx
,
c
.
config
,
false
);
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
...
@@ -138,7 +137,7 @@ func (c *Cluster) startStorage(ctx context.Context) error {
...
@@ -138,7 +137,7 @@ func (c *Cluster) startStorage(ctx context.Context) error {
// Persist the returned etcd configuration. We decide if we're doing leader election for embedded controllers
// Persist the returned etcd configuration. We decide if we're doing leader election for embedded controllers
// based on what the kine wrapper tells us about the datastore. Single-node datastores like sqlite don't require
// based on what the kine wrapper tells us about the datastore. Single-node datastores like sqlite don't require
// leader election, while basically all others (etcd, external database, etc) do since they allow multiple servers.
// leader election, while basically all others (etcd, external database, etc) do since they allow multiple servers.
c
.
EtcdConfig
=
etcdConfig
c
.
config
.
Runtime
.
EtcdConfig
=
etcdConfig
c
.
config
.
Datastore
.
BackendTLSConfig
=
etcdConfig
.
TLSConfig
c
.
config
.
Datastore
.
BackendTLSConfig
=
etcdConfig
.
TLSConfig
c
.
config
.
Datastore
.
Endpoint
=
strings
.
Join
(
etcdConfig
.
Endpoints
,
","
)
c
.
config
.
Datastore
.
Endpoint
=
strings
.
Join
(
etcdConfig
.
Endpoints
,
","
)
c
.
config
.
NoLeaderElect
=
!
etcdConfig
.
LeaderElect
c
.
config
.
NoLeaderElect
=
!
etcdConfig
.
LeaderElect
...
...
pkg/cluster/storage.go
View file @
a1b800f0
...
@@ -10,7 +10,6 @@ import (
...
@@ -10,7 +10,6 @@ import (
"strings"
"strings"
"github.com/k3s-io/kine/pkg/client"
"github.com/k3s-io/kine/pkg/client"
"github.com/k3s-io/kine/pkg/endpoint"
"github.com/rancher/k3s/pkg/bootstrap"
"github.com/rancher/k3s/pkg/bootstrap"
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/daemons/config"
...
@@ -21,7 +20,7 @@ import (
...
@@ -21,7 +20,7 @@ import (
// snapshot of the cluster's CA certs and keys, encryption passphrases, etc - encrypted with the join token.
// snapshot of the cluster's CA certs and keys, encryption passphrases, etc - encrypted with the join token.
// This is used when bootstrapping a cluster from a managed database or external etcd cluster.
// This is used when bootstrapping a cluster from a managed database or external etcd cluster.
// This is NOT used with embedded etcd, which bootstraps over HTTP.
// This is NOT used with embedded etcd, which bootstraps over HTTP.
func
Save
(
ctx
context
.
Context
,
config
*
config
.
Control
,
etcdConfig
endpoint
.
ETCDConfig
,
override
bool
)
error
{
func
Save
(
ctx
context
.
Context
,
config
*
config
.
Control
,
override
bool
)
error
{
buf
:=
&
bytes
.
Buffer
{}
buf
:=
&
bytes
.
Buffer
{}
if
err
:=
bootstrap
.
ReadFromDisk
(
buf
,
&
config
.
Runtime
.
ControlRuntimeBootstrap
);
err
!=
nil
{
if
err
:=
bootstrap
.
ReadFromDisk
(
buf
,
&
config
.
Runtime
.
ControlRuntimeBootstrap
);
err
!=
nil
{
return
err
return
err
...
@@ -44,7 +43,7 @@ func Save(ctx context.Context, config *config.Control, etcdConfig endpoint.ETCDC
...
@@ -44,7 +43,7 @@ func Save(ctx context.Context, config *config.Control, etcdConfig endpoint.ETCDC
return
err
return
err
}
}
storageClient
,
err
:=
client
.
New
(
e
tcdConfig
)
storageClient
,
err
:=
client
.
New
(
config
.
Runtime
.
E
tcdConfig
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -99,7 +98,7 @@ func (c *Cluster) storageBootstrap(ctx context.Context) error {
...
@@ -99,7 +98,7 @@ func (c *Cluster) storageBootstrap(ctx context.Context) error {
return
err
return
err
}
}
storageClient
,
err
:=
client
.
New
(
c
.
EtcdConfig
)
storageClient
,
err
:=
client
.
New
(
c
.
config
.
Runtime
.
EtcdConfig
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/daemons/control/server.go
View file @
a1b800f0
...
@@ -262,7 +262,6 @@ func prepare(ctx context.Context, config *config.Control) error {
...
@@ -262,7 +262,6 @@ func prepare(ctx context.Context, config *config.Control) error {
}
}
config
.
Runtime
.
ETCDReady
=
ready
config
.
Runtime
.
ETCDReady
=
ready
config
.
Runtime
.
EtcdConfig
=
cluster
.
EtcdConfig
return
nil
return
nil
}
}
...
...
pkg/secretsencrypt/controller.go
View file @
a1b800f0
...
@@ -120,7 +120,7 @@ func (h *handler) onChangeNode(key string, node *corev1.Node) (*corev1.Node, err
...
@@ -120,7 +120,7 @@ func (h *handler) onChangeNode(key string, node *corev1.Node) (*corev1.Node, err
h
.
recorder
.
Event
(
node
,
corev1
.
EventTypeWarning
,
secretsUpdateErrorEvent
,
err
.
Error
())
h
.
recorder
.
Event
(
node
,
corev1
.
EventTypeWarning
,
secretsUpdateErrorEvent
,
err
.
Error
())
return
node
,
err
return
node
,
err
}
}
if
err
:=
cluster
.
Save
(
h
.
ctx
,
h
.
controlConfig
,
h
.
controlConfig
.
Runtime
.
EtcdConfig
,
true
);
err
!=
nil
{
if
err
:=
cluster
.
Save
(
h
.
ctx
,
h
.
controlConfig
,
true
);
err
!=
nil
{
h
.
recorder
.
Event
(
node
,
corev1
.
EventTypeWarning
,
secretsUpdateErrorEvent
,
err
.
Error
())
h
.
recorder
.
Event
(
node
,
corev1
.
EventTypeWarning
,
secretsUpdateErrorEvent
,
err
.
Error
())
return
node
,
err
return
node
,
err
}
}
...
...
pkg/server/secrets-encrypt.go
View file @
a1b800f0
...
@@ -148,7 +148,7 @@ func encryptionEnable(ctx context.Context, server *config.Control, enable bool)
...
@@ -148,7 +148,7 @@ func encryptionEnable(ctx context.Context, server *config.Control, enable bool)
}
else
{
}
else
{
return
fmt
.
Errorf
(
"unable to enable/disable secrets encryption, unknown configuration"
)
return
fmt
.
Errorf
(
"unable to enable/disable secrets encryption, unknown configuration"
)
}
}
return
cluster
.
Save
(
ctx
,
server
,
server
.
Runtime
.
EtcdConfig
,
true
)
return
cluster
.
Save
(
ctx
,
server
,
true
)
}
}
func
encryptionConfigHandler
(
ctx
context
.
Context
,
server
*
config
.
Control
)
http
.
Handler
{
func
encryptionConfigHandler
(
ctx
context
.
Context
,
server
*
config
.
Control
)
http
.
Handler
{
...
@@ -217,7 +217,7 @@ func encryptionPrepare(ctx context.Context, server *config.Control, force bool)
...
@@ -217,7 +217,7 @@ func encryptionPrepare(ctx context.Context, server *config.Control, force bool)
if
err
=
secretsencrypt
.
WriteEncryptionHashAnnotation
(
server
.
Runtime
,
node
,
secretsencrypt
.
EncryptionPrepare
);
err
!=
nil
{
if
err
=
secretsencrypt
.
WriteEncryptionHashAnnotation
(
server
.
Runtime
,
node
,
secretsencrypt
.
EncryptionPrepare
);
err
!=
nil
{
return
err
return
err
}
}
return
cluster
.
Save
(
ctx
,
server
,
server
.
Runtime
.
EtcdConfig
,
true
)
return
cluster
.
Save
(
ctx
,
server
,
true
)
}
}
func
encryptionRotate
(
ctx
context
.
Context
,
server
*
config
.
Control
,
force
bool
)
error
{
func
encryptionRotate
(
ctx
context
.
Context
,
server
*
config
.
Control
,
force
bool
)
error
{
...
@@ -246,7 +246,7 @@ func encryptionRotate(ctx context.Context, server *config.Control, force bool) e
...
@@ -246,7 +246,7 @@ func encryptionRotate(ctx context.Context, server *config.Control, force bool) e
if
err
:=
secretsencrypt
.
WriteEncryptionHashAnnotation
(
server
.
Runtime
,
node
,
secretsencrypt
.
EncryptionRotate
);
err
!=
nil
{
if
err
:=
secretsencrypt
.
WriteEncryptionHashAnnotation
(
server
.
Runtime
,
node
,
secretsencrypt
.
EncryptionRotate
);
err
!=
nil
{
return
err
return
err
}
}
return
cluster
.
Save
(
ctx
,
server
,
server
.
Runtime
.
EtcdConfig
,
true
)
return
cluster
.
Save
(
ctx
,
server
,
true
)
}
}
func
encryptionReencrypt
(
ctx
context
.
Context
,
server
*
config
.
Control
,
force
bool
,
skip
bool
)
error
{
func
encryptionReencrypt
(
ctx
context
.
Context
,
server
*
config
.
Control
,
force
bool
,
skip
bool
)
error
{
...
...
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