Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Cache Size Limits for kopia server start #3060

Merged
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 4 additions & 0 deletions pkg/kopia/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (

type ServerStartCommandArgs struct {
*CommandArgs
CacheArgs
CacheDirectory string
ServerAddress string
TLSCertFile string
TLSKeyFile string
Expand Down Expand Up @@ -60,6 +62,8 @@ func ServerStart(cmdArgs ServerStartCommandArgs) []string {
args = args.AppendLoggable(readOnlyFlag)
}

args = cmdArgs.kopiaCacheArgs(args, cmdArgs.CacheDirectory)

r4rajat marked this conversation as resolved.
Show resolved Hide resolved
if cmdArgs.EnablePprof {
args = args.AppendLoggable(enablePprof)
}
Expand Down
24 changes: 19 additions & 5 deletions pkg/kopia/command/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func (kServer *KopiaServerTestSuite) TestServerCommands(c *C) {
ConfigFilePath: "path/kopia.config",
LogDirectory: "cache/log",
}
cacheArgs := CacheArgs{
ContentCacheLimitMB: 500,
MetadataCacheLimitMB: 500,
}

for _, tc := range []struct {
f func() []string
Expand All @@ -41,6 +45,8 @@ func (kServer *KopiaServerTestSuite) TestServerCommands(c *C) {
f: func() []string {
args := ServerStartCommandArgs{
CommandArgs: commandArgs,
CacheArgs: cacheArgs,
CacheDirectory: "cache/dir",
viveksinghggits marked this conversation as resolved.
Show resolved Hide resolved
ServerAddress: "a-server-address",
TLSCertFile: "/path/to/cert/tls.crt",
TLSKeyFile: "/path/to/key/tls.key",
Expand All @@ -53,12 +59,14 @@ func (kServer *KopiaServerTestSuite) TestServerCommands(c *C) {
}
return ServerStart(args)
},
expectedLog: "bash -o errexit -c kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log server start --tls-generate-cert --address=a-server-address --tls-cert-file=/path/to/cert/tls.crt --tls-key-file=/path/to/key/tls.key --server-username=a-username@a-hostname --server-password=a-user-password --server-control-username=a-username@a-hostname --server-control-password=a-user-password --enable-pprof --metrics-listen-addr=a-server-address:51516 > /dev/null 2>&1 &",
expectedLog: "bash -o errexit -c kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log server start --tls-generate-cert --address=a-server-address --tls-cert-file=/path/to/cert/tls.crt --tls-key-file=/path/to/key/tls.key --server-username=a-username@a-hostname --server-password=a-user-password --server-control-username=a-username@a-hostname --server-control-password=a-user-password --cache-directory=cache/dir --content-cache-size-limit-mb=500 --metadata-cache-size-limit-mb=500 --enable-pprof --metrics-listen-addr=a-server-address:51516 > /dev/null 2>&1 &",
},
{
f: func() []string {
args := ServerStartCommandArgs{
CommandArgs: commandArgs,
CacheArgs: cacheArgs,
CacheDirectory: "cache/dir",
ServerAddress: "a-server-address",
TLSCertFile: "/path/to/cert/tls.crt",
TLSKeyFile: "/path/to/key/tls.key",
Expand All @@ -69,12 +77,14 @@ func (kServer *KopiaServerTestSuite) TestServerCommands(c *C) {
}
return ServerStart(args)
},
expectedLog: "bash -o errexit -c kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log server start --tls-generate-cert --address=a-server-address --tls-cert-file=/path/to/cert/tls.crt --tls-key-file=/path/to/key/tls.key --server-username=a-username@a-hostname --server-password=a-user-password --server-control-username=a-username@a-hostname --server-control-password=a-user-password > /dev/null 2>&1 &",
expectedLog: "bash -o errexit -c kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log server start --tls-generate-cert --address=a-server-address --tls-cert-file=/path/to/cert/tls.crt --tls-key-file=/path/to/key/tls.key --server-username=a-username@a-hostname --server-password=a-user-password --server-control-username=a-username@a-hostname --server-control-password=a-user-password --cache-directory=cache/dir --content-cache-size-limit-mb=500 --metadata-cache-size-limit-mb=500 > /dev/null 2>&1 &",
},
{
f: func() []string {
args := ServerStartCommandArgs{
CommandArgs: commandArgs,
CacheArgs: cacheArgs,
CacheDirectory: "cache/dir",
ServerAddress: "a-server-address",
TLSCertFile: "/path/to/cert/tls.crt",
TLSKeyFile: "/path/to/key/tls.key",
Expand All @@ -85,12 +95,14 @@ func (kServer *KopiaServerTestSuite) TestServerCommands(c *C) {
}
return ServerStart(args)
},
expectedLog: "bash -o errexit -c kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log server start --tls-generate-cert --address=a-server-address --tls-cert-file=/path/to/cert/tls.crt --tls-key-file=/path/to/key/tls.key --server-username=a-username@a-hostname --server-password=a-user-password --server-control-username=a-username@a-hostname --server-control-password=a-user-password",
expectedLog: "bash -o errexit -c kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log server start --tls-generate-cert --address=a-server-address --tls-cert-file=/path/to/cert/tls.crt --tls-key-file=/path/to/key/tls.key --server-username=a-username@a-hostname --server-password=a-user-password --server-control-username=a-username@a-hostname --server-control-password=a-user-password --cache-directory=cache/dir --content-cache-size-limit-mb=500 --metadata-cache-size-limit-mb=500",
},
{
f: func() []string {
args := ServerStartCommandArgs{
CommandArgs: commandArgs,
CacheArgs: cacheArgs,
CacheDirectory: "cache/dir",
ServerAddress: "a-server-address",
TLSCertFile: "/path/to/cert/tls.crt",
TLSKeyFile: "/path/to/key/tls.key",
Expand All @@ -101,12 +113,14 @@ func (kServer *KopiaServerTestSuite) TestServerCommands(c *C) {
}
return ServerStart(args)
},
expectedLog: "bash -o errexit -c kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log server start --address=a-server-address --tls-cert-file=/path/to/cert/tls.crt --tls-key-file=/path/to/key/tls.key --server-username=a-username@a-hostname --server-password=a-user-password --server-control-username=a-username@a-hostname --server-control-password=a-user-password > /dev/null 2>&1 &",
expectedLog: "bash -o errexit -c kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log server start --address=a-server-address --tls-cert-file=/path/to/cert/tls.crt --tls-key-file=/path/to/key/tls.key --server-username=a-username@a-hostname --server-password=a-user-password --server-control-username=a-username@a-hostname --server-control-password=a-user-password --cache-directory=cache/dir --content-cache-size-limit-mb=500 --metadata-cache-size-limit-mb=500 > /dev/null 2>&1 &",
},
{
f: func() []string {
args := ServerStartCommandArgs{
CommandArgs: commandArgs,
CacheArgs: cacheArgs,
CacheDirectory: "cache/dir",
ServerAddress: "a-server-address",
TLSCertFile: "/path/to/cert/tls.crt",
TLSKeyFile: "/path/to/key/tls.key",
Expand All @@ -119,7 +133,7 @@ func (kServer *KopiaServerTestSuite) TestServerCommands(c *C) {
}
return ServerStart(args)
},
expectedLog: "bash -o errexit -c kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log server start --address=a-server-address --tls-cert-file=/path/to/cert/tls.crt --tls-key-file=/path/to/key/tls.key --htpasswd-file=/path/htpasswd --server-username=a-username@a-hostname --server-password=a-user-password --server-control-username=a-username@a-hostname --server-control-password=a-user-password --readonly > /dev/null 2>&1 &",
expectedLog: "bash -o errexit -c kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log server start --address=a-server-address --tls-cert-file=/path/to/cert/tls.crt --tls-key-file=/path/to/key/tls.key --htpasswd-file=/path/htpasswd --server-username=a-username@a-hostname --server-password=a-user-password --server-control-username=a-username@a-hostname --server-control-password=a-user-password --readonly --cache-directory=cache/dir --content-cache-size-limit-mb=500 --metadata-cache-size-limit-mb=500 > /dev/null 2>&1 &",
},
{
f: func() []string {
Expand Down