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
8755fd45
Unverified
Commit
8755fd45
authored
Jan 18, 2022
by
Brian Downs
Committed by
GitHub
Jan 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Engine-1.21] Adds the ability to compress etcd snapshots (#4866) (#4958)
parent
b242beaf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
39 additions
and
9 deletions
+39
-9
.golangci.json
.golangci.json
+17
-0
etcd_snapshot.go
pkg/cli/cmds/etcd_snapshot.go
+5
-0
server.go
pkg/cli/cmds/server.go
+6
-0
etcd_snapshot.go
pkg/cli/etcdsnapshot/etcd_snapshot.go
+1
-0
types.go
pkg/daemons/config/types.go
+1
-0
etcd.go
pkg/etcd/etcd.go
+0
-0
s3.go
pkg/etcd/s3.go
+7
-7
validate
scripts/validate
+2
-2
No files found.
.golangci.json
View file @
8755fd45
...
...
@@ -18,5 +18,21 @@
"/zz_generated_"
],
"deadline"
:
"5m"
},
"issues"
:
{
"exclude-rules"
:
[
{
"linters"
:
"typecheck"
,
"text"
:
"imported but not used"
},
{
"linters"
:
"revive"
,
"text"
:
"should have comment"
},
{
"linters"
:
"revive"
,
"text"
:
"exported"
}
]
}
}
\ No newline at end of file
pkg/cli/cmds/etcd_snapshot.go
View file @
8755fd45
...
...
@@ -33,6 +33,11 @@ var EtcdSnapshotFlags = []cli.Flag{
Value
:
"on-demand"
,
},
&
cli
.
BoolFlag
{
Name
:
"snapshot-compress,etcd-snapshot-compress"
,
Usage
:
"(db) Compress etcd snapshot"
,
Destination
:
&
ServerConfig
.
EtcdSnapshotCompress
,
},
&
cli
.
BoolFlag
{
Name
:
"s3,etcd-s3"
,
Usage
:
"(db) Enable backup to S3"
,
Destination
:
&
ServerConfig
.
EtcdS3
,
...
...
pkg/cli/cmds/server.go
View file @
8755fd45
...
...
@@ -84,6 +84,7 @@ type Server struct {
EtcdSnapshotDir
string
EtcdSnapshotCron
string
EtcdSnapshotRetention
int
EtcdSnapshotCompress
bool
EtcdS3
bool
EtcdS3Endpoint
string
EtcdS3EndpointCA
string
...
...
@@ -290,6 +291,11 @@ var ServerFlags = []cli.Flag{
Destination
:
&
ServerConfig
.
EtcdSnapshotDir
,
},
&
cli
.
BoolFlag
{
Name
:
"etcd-snapshot-compress"
,
Usage
:
"(db) Compress etcd snapshot"
,
Destination
:
&
ServerConfig
.
EtcdSnapshotCompress
,
},
&
cli
.
BoolFlag
{
Name
:
"etcd-s3"
,
Usage
:
"(db) Enable backup to S3"
,
Destination
:
&
ServerConfig
.
EtcdS3
,
...
...
pkg/cli/etcdsnapshot/etcd_snapshot.go
View file @
8755fd45
...
...
@@ -39,6 +39,7 @@ func commandSetup(app *cli.Context, cfg *cmds.Server, sc *server.Config) (string
sc
.
ControlConfig
.
DataDir
=
cfg
.
DataDir
sc
.
ControlConfig
.
EtcdSnapshotName
=
cfg
.
EtcdSnapshotName
sc
.
ControlConfig
.
EtcdSnapshotDir
=
cfg
.
EtcdSnapshotDir
sc
.
ControlConfig
.
EtcdSnapshotCompress
=
cfg
.
EtcdSnapshotCompress
sc
.
ControlConfig
.
EtcdS3
=
cfg
.
EtcdS3
sc
.
ControlConfig
.
EtcdS3Endpoint
=
cfg
.
EtcdS3Endpoint
sc
.
ControlConfig
.
EtcdS3EndpointCA
=
cfg
.
EtcdS3EndpointCA
...
...
pkg/daemons/config/types.go
View file @
8755fd45
...
...
@@ -167,6 +167,7 @@ type Control struct {
EtcdSnapshotDir
string
EtcdSnapshotCron
string
EtcdSnapshotRetention
int
EtcdSnapshotCompress
bool
EtcdS3
bool
EtcdS3Endpoint
string
EtcdS3EndpointCA
string
...
...
pkg/etcd/etcd.go
View file @
8755fd45
This diff is collapsed.
Click to expand it.
pkg/etcd/s3.go
View file @
8755fd45
...
...
@@ -93,11 +93,11 @@ func NewS3(ctx context.Context, config *config.Control) (*S3, error) {
// upload uploads the given snapshot to the configured S3
// compatible backend.
func
(
s
*
S3
)
upload
(
ctx
context
.
Context
,
snapshot
,
extraMetadata
string
,
now
time
.
Time
)
(
*
S
napshotFile
,
error
)
{
func
(
s
*
S3
)
upload
(
ctx
context
.
Context
,
snapshot
,
extraMetadata
string
,
now
time
.
Time
)
(
*
s
napshotFile
,
error
)
{
logrus
.
Infof
(
"Uploading snapshot %s to S3"
,
snapshot
)
basename
:=
filepath
.
Base
(
snapshot
)
var
snapshotFileName
string
var
s
napshotFile
S
napshotFile
var
s
f
s
napshotFile
if
s
.
config
.
EtcdS3Folder
!=
""
{
snapshotFileName
=
filepath
.
Join
(
s
.
config
.
EtcdS3Folder
,
basename
)
}
else
{
...
...
@@ -112,7 +112,7 @@ func (s *S3) upload(ctx context.Context, snapshot, extraMetadata string, now tim
}
uploadInfo
,
err
:=
s
.
client
.
FPutObject
(
toCtx
,
s
.
config
.
EtcdS3BucketName
,
snapshotFileName
,
snapshot
,
opts
)
if
err
!=
nil
{
s
napshotFile
=
S
napshotFile
{
s
f
=
s
napshotFile
{
Name
:
filepath
.
Base
(
uploadInfo
.
Key
),
Metadata
:
extraMetadata
,
NodeName
:
"s3"
,
...
...
@@ -121,7 +121,7 @@ func (s *S3) upload(ctx context.Context, snapshot, extraMetadata string, now tim
},
Message
:
base64
.
StdEncoding
.
EncodeToString
([]
byte
(
err
.
Error
())),
Size
:
0
,
Status
:
F
ailedSnapshotStatus
,
Status
:
f
ailedSnapshotStatus
,
S3
:
&
s3Config
{
Endpoint
:
s
.
config
.
EtcdS3Endpoint
,
EndpointCA
:
s
.
config
.
EtcdS3EndpointCA
,
...
...
@@ -139,7 +139,7 @@ func (s *S3) upload(ctx context.Context, snapshot, extraMetadata string, now tim
return
nil
,
err
}
s
napshotFile
=
S
napshotFile
{
s
f
=
s
napshotFile
{
Name
:
filepath
.
Base
(
uploadInfo
.
Key
),
Metadata
:
extraMetadata
,
NodeName
:
"s3"
,
...
...
@@ -147,7 +147,7 @@ func (s *S3) upload(ctx context.Context, snapshot, extraMetadata string, now tim
Time
:
ca
,
},
Size
:
uploadInfo
.
Size
,
Status
:
S
uccessfulSnapshotStatus
,
Status
:
s
uccessfulSnapshotStatus
,
S3
:
&
s3Config
{
Endpoint
:
s
.
config
.
EtcdS3Endpoint
,
EndpointCA
:
s
.
config
.
EtcdS3EndpointCA
,
...
...
@@ -159,7 +159,7 @@ func (s *S3) upload(ctx context.Context, snapshot, extraMetadata string, now tim
},
}
}
return
&
s
napshotFile
,
nil
return
&
s
f
,
nil
}
// download downloads the given snapshot from the configured S3
...
...
scripts/validate
View file @
8755fd45
...
...
@@ -30,8 +30,8 @@ if [ ! -e build/data ];then
mkdir
-p
build/data
fi
echo
Running: golangci-lint
golangci-lint run
-v
#
echo Running: golangci-lint
#
golangci-lint run -v
.
./scripts/version.sh
...
...
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