mirror of
https://git.vectorsigma.ru/public/k3s.git
synced 2026-08-04 04:49:28 +00:00
Merge pull request #3354 from briandowns/backport_etcd_subcommands-1.21
[ Backport 1.21 ] - etcd subcommands 1.21
This commit is contained in:
@@ -17,7 +17,8 @@ func main() {
|
||||
cmds.NewEtcdSnapshotSubcommands(
|
||||
etcdsnapshot.Delete,
|
||||
etcdsnapshot.List,
|
||||
etcdsnapshot.Prune),
|
||||
etcdsnapshot.Prune,
|
||||
etcdsnapshot.Run),
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ func main() {
|
||||
cmds.NewCheckConfigCommand(externalCLIAction("check-config", dataDir)),
|
||||
cmds.NewEtcdSnapshotCommand(etcdsnapshotCommand,
|
||||
cmds.NewEtcdSnapshotSubcommands(
|
||||
etcdsnapshotCommand,
|
||||
etcdsnapshotCommand,
|
||||
etcdsnapshotCommand,
|
||||
etcdsnapshotCommand),
|
||||
|
||||
@@ -47,7 +47,8 @@ func main() {
|
||||
cmds.NewEtcdSnapshotSubcommands(
|
||||
etcdsnapshot.Delete,
|
||||
etcdsnapshot.List,
|
||||
etcdsnapshot.Prune),
|
||||
etcdsnapshot.Prune,
|
||||
etcdsnapshot.Run),
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
3
main.go
3
main.go
@@ -31,7 +31,8 @@ func main() {
|
||||
cmds.NewEtcdSnapshotSubcommands(
|
||||
etcdsnapshot.Delete,
|
||||
etcdsnapshot.List,
|
||||
etcdsnapshot.Prune),
|
||||
etcdsnapshot.Prune,
|
||||
etcdsnapshot.Run),
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -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{
|
||||
{
|
||||
Name: "delete",
|
||||
@@ -122,10 +122,22 @@ func NewEtcdSnapshotSubcommands(delete, list, prune func(ctx *cli.Context) error
|
||||
Action: prune,
|
||||
Flags: append(EtcdSnapshotFlags, &cli.IntFlag{
|
||||
Name: "snapshot-retention",
|
||||
Usage: "(db) Number of snapshots to retain",
|
||||
Usage: "(db) Number of snapshots to retain. Default: 5",
|
||||
Destination: &ServerConfig.EtcdSnapshotRetention,
|
||||
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,
|
||||
}),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "etcd-snapshot-retention",
|
||||
Usage: "(db) Number of snapshots to retain",
|
||||
Usage: "(db) Number of snapshots to retain Default: 5",
|
||||
Destination: &ServerConfig.EtcdSnapshotRetention,
|
||||
Value: defaultSnapshotRentention,
|
||||
},
|
||||
|
||||
@@ -978,6 +978,14 @@ func (e *ETCD) PruneSnapshots(ctx context.Context) error {
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -1009,12 +1017,13 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error {
|
||||
}
|
||||
|
||||
objectsCh := make(chan minio.ObjectInfo)
|
||||
defer close(objectsCh)
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultS3OpTimeout)
|
||||
defer cancel()
|
||||
|
||||
go func() {
|
||||
defer close(objectsCh)
|
||||
|
||||
opts := minio.ListObjectsOptions{
|
||||
Recursive: true,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user