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
3db7f988
Unverified
Commit
3db7f988
authored
Jun 08, 2021
by
Brian Downs
Committed by
GitHub
Jun 08, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3354 from briandowns/backport_etcd_subcommands-1.21
[ Backport 1.21 ] - etcd subcommands 1.21
parents
16ae282c
8fd180e0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
7 deletions
+32
-7
main.go
cmd/etcdsnapshot/main.go
+2
-1
main.go
cmd/k3s/main.go
+1
-0
main.go
cmd/server/main.go
+2
-1
main.go
main.go
+2
-1
etcd_snapshot.go
pkg/cli/cmds/etcd_snapshot.go
+14
-2
server.go
pkg/cli/cmds/server.go
+1
-1
etcd.go
pkg/etcd/etcd.go
+10
-1
No files found.
cmd/etcdsnapshot/main.go
View file @
3db7f988
...
@@ -17,7 +17,8 @@ func main() {
...
@@ -17,7 +17,8 @@ func main() {
cmds
.
NewEtcdSnapshotSubcommands
(
cmds
.
NewEtcdSnapshotSubcommands
(
etcdsnapshot
.
Delete
,
etcdsnapshot
.
Delete
,
etcdsnapshot
.
List
,
etcdsnapshot
.
List
,
etcdsnapshot
.
Prune
),
etcdsnapshot
.
Prune
,
etcdsnapshot
.
Run
),
),
),
}
}
...
...
cmd/k3s/main.go
View file @
3db7f988
...
@@ -48,6 +48,7 @@ func main() {
...
@@ -48,6 +48,7 @@ func main() {
cmds
.
NewEtcdSnapshotSubcommands
(
cmds
.
NewEtcdSnapshotSubcommands
(
etcdsnapshotCommand
,
etcdsnapshotCommand
,
etcdsnapshotCommand
,
etcdsnapshotCommand
,
etcdsnapshotCommand
,
etcdsnapshotCommand
),
etcdsnapshotCommand
),
),
),
}
}
...
...
cmd/server/main.go
View file @
3db7f988
...
@@ -47,7 +47,8 @@ func main() {
...
@@ -47,7 +47,8 @@ func main() {
cmds
.
NewEtcdSnapshotSubcommands
(
cmds
.
NewEtcdSnapshotSubcommands
(
etcdsnapshot
.
Delete
,
etcdsnapshot
.
Delete
,
etcdsnapshot
.
List
,
etcdsnapshot
.
List
,
etcdsnapshot
.
Prune
),
etcdsnapshot
.
Prune
,
etcdsnapshot
.
Run
),
),
),
}
}
...
...
main.go
View file @
3db7f988
...
@@ -31,7 +31,8 @@ func main() {
...
@@ -31,7 +31,8 @@ func main() {
cmds
.
NewEtcdSnapshotSubcommands
(
cmds
.
NewEtcdSnapshotSubcommands
(
etcdsnapshot
.
Delete
,
etcdsnapshot
.
Delete
,
etcdsnapshot
.
List
,
etcdsnapshot
.
List
,
etcdsnapshot
.
Prune
),
etcdsnapshot
.
Prune
,
etcdsnapshot
.
Run
),
),
),
}
}
...
...
pkg/cli/cmds/etcd_snapshot.go
View file @
3db7f988
...
@@ -95,7 +95,7 @@ func NewEtcdSnapshotCommand(action func(*cli.Context) error, subcommands []cli.C
...
@@ -95,7 +95,7 @@ func NewEtcdSnapshotCommand(action func(*cli.Context) error, subcommands []cli.C
}
}
}
}
func
NewEtcdSnapshotSubcommands
(
delete
,
list
,
prune
func
(
ctx
*
cli
.
Context
)
error
)
[]
cli
.
Command
{
func
NewEtcdSnapshotSubcommands
(
delete
,
list
,
prune
,
save
func
(
ctx
*
cli
.
Context
)
error
)
[]
cli
.
Command
{
return
[]
cli
.
Command
{
return
[]
cli
.
Command
{
{
{
Name
:
"delete"
,
Name
:
"delete"
,
...
@@ -122,10 +122,22 @@ func NewEtcdSnapshotSubcommands(delete, list, prune func(ctx *cli.Context) error
...
@@ -122,10 +122,22 @@ func NewEtcdSnapshotSubcommands(delete, list, prune func(ctx *cli.Context) error
Action
:
prune
,
Action
:
prune
,
Flags
:
append
(
EtcdSnapshotFlags
,
&
cli
.
IntFlag
{
Flags
:
append
(
EtcdSnapshotFlags
,
&
cli
.
IntFlag
{
Name
:
"snapshot-retention"
,
Name
:
"snapshot-retention"
,
Usage
:
"(db) Number of snapshots to retain"
,
Usage
:
"(db) Number of snapshots to retain
. Default: 5
"
,
Destination
:
&
ServerConfig
.
EtcdSnapshotRetention
,
Destination
:
&
ServerConfig
.
EtcdSnapshotRetention
,
Value
:
defaultSnapshotRentention
,
Value
:
defaultSnapshotRentention
,
}),
}),
},
},
{
Name
:
"save"
,
Usage
:
"Trigger an immediate etcd snapshot"
,
SkipFlagParsing
:
false
,
SkipArgReorder
:
true
,
Action
:
save
,
Flags
:
append
(
EtcdSnapshotFlags
,
&
cli
.
StringFlag
{
Name
:
"dir"
,
Usage
:
"(db) Directory to save etcd on-demand snapshot. (default: ${data-dir}/db/snapshots)"
,
Destination
:
&
ServerConfig
.
EtcdSnapshotDir
,
}),
},
}
}
}
}
pkg/cli/cmds/server.go
View file @
3db7f988
...
@@ -252,7 +252,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
...
@@ -252,7 +252,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
},
},
&
cli
.
IntFlag
{
&
cli
.
IntFlag
{
Name
:
"etcd-snapshot-retention"
,
Name
:
"etcd-snapshot-retention"
,
Usage
:
"(db) Number of snapshots to retain"
,
Usage
:
"(db) Number of snapshots to retain
Default: 5
"
,
Destination
:
&
ServerConfig
.
EtcdSnapshotRetention
,
Destination
:
&
ServerConfig
.
EtcdSnapshotRetention
,
Value
:
defaultSnapshotRentention
,
Value
:
defaultSnapshotRentention
,
},
},
...
...
pkg/etcd/etcd.go
View file @
3db7f988
...
@@ -978,6 +978,14 @@ func (e *ETCD) PruneSnapshots(ctx context.Context) error {
...
@@ -978,6 +978,14 @@ func (e *ETCD) PruneSnapshots(ctx context.Context) error {
return
errors
.
Wrap
(
err
,
"failed to get the snapshot dir"
)
return
errors
.
Wrap
(
err
,
"failed to get the snapshot dir"
)
}
}
if
e
.
config
.
EtcdS3
{
if
e
.
initS3IfNil
(
ctx
);
err
!=
nil
{
return
err
}
return
e
.
s3
.
snapshotRetention
(
ctx
)
}
return
snapshotRetention
(
e
.
config
.
EtcdSnapshotRetention
,
snapshotDir
)
return
snapshotRetention
(
e
.
config
.
EtcdSnapshotRetention
,
snapshotDir
)
}
}
...
@@ -1009,12 +1017,13 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error {
...
@@ -1009,12 +1017,13 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error {
}
}
objectsCh
:=
make
(
chan
minio
.
ObjectInfo
)
objectsCh
:=
make
(
chan
minio
.
ObjectInfo
)
defer
close
(
objectsCh
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
defaultS3OpTimeout
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
defaultS3OpTimeout
)
defer
cancel
()
defer
cancel
()
go
func
()
{
go
func
()
{
defer
close
(
objectsCh
)
opts
:=
minio
.
ListObjectsOptions
{
opts
:=
minio
.
ListObjectsOptions
{
Recursive
:
true
,
Recursive
:
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