Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/google/go-containerregistry v0.20.7
github.com/gorilla/websocket v1.5.3
github.com/itchyny/json2yaml v0.1.4
github.com/kernel/hypeman-go v0.17.0
github.com/kernel/hypeman-go v0.19.0
github.com/knadh/koanf/parsers/yaml v1.1.0
github.com/knadh/koanf/providers/env v1.1.0
github.com/knadh/koanf/providers/file v1.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnV
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs=
github.com/itchyny/json2yaml v0.1.4 h1:/pErVOXGG5iTyXHi/QKR4y3uzhLjGTEmmJIy97YT+k8=
github.com/itchyny/json2yaml v0.1.4/go.mod h1:6iudhBZdarpjLFRNj+clWLAkGft+9uCcjAZYXUH9eGI=
github.com/kernel/hypeman-go v0.17.0 h1:OaGS0pFUwXYaFtlXaIQleokgNM7Z+KO0mGhL953yiMQ=
github.com/kernel/hypeman-go v0.17.0/go.mod h1:guRrhyP9QW/ebUS1UcZ0uZLLJeGAAhDNzSi68U4M9hI=
github.com/kernel/hypeman-go v0.19.0 h1:gpkTyR+JMIpEMkbbgeyjgV42TR2qQoPegttq1PsBdDU=
github.com/kernel/hypeman-go v0.19.0/go.mod h1:guRrhyP9QW/ebUS1UcZ0uZLLJeGAAhDNzSi68U4M9hI=
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo=
Expand Down
41 changes: 26 additions & 15 deletions pkg/cmd/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ var standbyCmd = cli.Command{
Name: "compression-enabled",
Usage: "Enable memory compression for this standby operation",
},
&cli.StringFlag{
Name: "compression-delay",
Usage: `Delay before standby snapshot compression begins (e.g., "30s", "5m")`,
},
&cli.StringFlag{
Name: "compression-algorithm",
Usage: `Compression algorithm: "zstd" or "lz4"`,
Expand Down Expand Up @@ -153,24 +157,31 @@ func handleStandby(ctx context.Context, cmd *cli.Command) error {
}

params := hypeman.InstanceStandbyParams{}
if cmd.IsSet("compression-enabled") || cmd.IsSet("compression-algorithm") || cmd.IsSet("compression-level") {
compression := shared.SnapshotCompressionConfigParam{
Enabled: cmd.Bool("compression-enabled"),
}
if !cmd.IsSet("compression-enabled") {
compression.Enabled = true
}
if cmd.IsSet("compression-level") {
compression.Level = hypeman.Opt(int64(cmd.Int("compression-level")))
if cmd.IsSet("compression-enabled") || cmd.IsSet("compression-delay") || cmd.IsSet("compression-algorithm") || cmd.IsSet("compression-level") {
request := hypeman.StandbyInstanceRequestParam{}
if delay := cmd.String("compression-delay"); delay != "" {
request.CompressionDelay = hypeman.Opt(delay)
}
if algorithm := cmd.String("compression-algorithm"); algorithm != "" {
parsedAlgorithm, err := parseSnapshotCompressionAlgorithm(algorithm)
if err != nil {
return err
if cmd.IsSet("compression-enabled") || cmd.IsSet("compression-algorithm") || cmd.IsSet("compression-level") {
compression := shared.SnapshotCompressionConfigParam{
Enabled: cmd.Bool("compression-enabled"),
}
if !cmd.IsSet("compression-enabled") {
compression.Enabled = true
}
if cmd.IsSet("compression-level") {
compression.Level = hypeman.Opt(int64(cmd.Int("compression-level")))
}
if algorithm := cmd.String("compression-algorithm"); algorithm != "" {
parsedAlgorithm, err := parseSnapshotCompressionAlgorithm(algorithm)
if err != nil {
return err
}
compression.Algorithm = parsedAlgorithm
}
compression.Algorithm = parsedAlgorithm
request.Compression = compression
}
params.Compression = compression
params.StandbyInstanceRequest = request
}

fmt.Fprintf(os.Stderr, "Putting %s into standby...\n", args[0])
Expand Down
43 changes: 26 additions & 17 deletions pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ Examples:
Name: "snapshot-compression-enabled",
Usage: "Enable snapshot memory compression for this instance policy",
},
&cli.StringFlag{
Name: "snapshot-compression-delay",
Usage: `Delay before standby snapshot compression begins (e.g., "30s", "5m")`,
},
&cli.StringFlag{
Name: "snapshot-compression-algorithm",
Usage: `Snapshot compression algorithm: "zstd" or "lz4"`,
Expand Down Expand Up @@ -347,26 +351,31 @@ func handleRun(ctx context.Context, cmd *cli.Command) error {
}

// Snapshot policy compression
if cmd.IsSet("snapshot-compression-enabled") || cmd.IsSet("snapshot-compression-algorithm") || cmd.IsSet("snapshot-compression-level") {
compression := shared.SnapshotCompressionConfigParam{
Enabled: cmd.Bool("snapshot-compression-enabled"),
}
if !cmd.IsSet("snapshot-compression-enabled") {
compression.Enabled = true
if cmd.IsSet("snapshot-compression-enabled") || cmd.IsSet("snapshot-compression-delay") || cmd.IsSet("snapshot-compression-algorithm") || cmd.IsSet("snapshot-compression-level") {
policy := hypeman.SnapshotPolicyParam{}
if delay := cmd.String("snapshot-compression-delay"); delay != "" {
policy.StandbyCompressionDelay = hypeman.Opt(delay)
}
if cmd.IsSet("snapshot-compression-level") {
compression.Level = hypeman.Opt(int64(cmd.Int("snapshot-compression-level")))
}
if algorithm := cmd.String("snapshot-compression-algorithm"); algorithm != "" {
parsedAlgorithm, err := parseSnapshotCompressionAlgorithm(algorithm)
if err != nil {
return fmt.Errorf("invalid snapshot compression algorithm: %w", err)
if cmd.IsSet("snapshot-compression-enabled") || cmd.IsSet("snapshot-compression-algorithm") || cmd.IsSet("snapshot-compression-level") {
compression := shared.SnapshotCompressionConfigParam{
Enabled: cmd.Bool("snapshot-compression-enabled"),
}
compression.Algorithm = parsedAlgorithm
}
params.SnapshotPolicy = hypeman.SnapshotPolicyParam{
Compression: compression,
if !cmd.IsSet("snapshot-compression-enabled") {
compression.Enabled = true
}
if cmd.IsSet("snapshot-compression-level") {
compression.Level = hypeman.Opt(int64(cmd.Int("snapshot-compression-level")))
}
if algorithm := cmd.String("snapshot-compression-algorithm"); algorithm != "" {
parsedAlgorithm, err := parseSnapshotCompressionAlgorithm(algorithm)
if err != nil {
return fmt.Errorf("invalid snapshot compression algorithm: %w", err)
}
compression.Algorithm = parsedAlgorithm
}
policy.Compression = compression
}
params.SnapshotPolicy = policy
}

// Volume mounts
Expand Down
Loading