From c155793128cec31a33802d0d17d49363633ce6d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20B=C4=85czek?= Date: Thu, 22 Sep 2022 15:17:42 +0200 Subject: [PATCH] [#251] File probes override (#252) This reverts commit 2e9f6030 Allows overriding file probes paths in case of container with read only file system. --- cmd/flags/file_probe.go | 6 +++++- cmd/root.go | 4 ++-- docs/about/getting-started.md | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/flags/file_probe.go b/cmd/flags/file_probe.go index 98fc18c..9de5ab9 100644 --- a/cmd/flags/file_probe.go +++ b/cmd/flags/file_probe.go @@ -21,7 +21,9 @@ import ( // FileProbe stores flags related to the file probe. type FileProbe struct { - Enabled bool + Enabled bool + LivenessPath string + ReadinessPath string } func (p *FileProbe) String() string { @@ -30,4 +32,6 @@ func (p *FileProbe) String() string { func (p *FileProbe) initFlags() { flag.BoolVar(&p.Enabled, "file-probe-enabled", true, "If set to true writes files to be used as readiness/liveness probes") + flag.StringVar(&p.LivenessPath, "file-probe-liveness-path", "alive", "File to be used for liveness probe") + flag.StringVar(&p.ReadinessPath, "file-probe-readiness-path", "ready", "File to be used for readiness probe") } diff --git a/cmd/root.go b/cmd/root.go index 131e88c..9d9b0b9 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -47,7 +47,7 @@ func RunCmdRoot() { // run runs the main logic and returns the number of warmup requests actually sent. func run() int { if opts.FileProbe.Enabled { - probe.WriteFile("alive") + probe.WriteFile(opts.FileProbe.LivenessPath) } var validationError bool @@ -156,7 +156,7 @@ func postProcess(requestsSentCounter int) { } if opts.FileProbe.Enabled { - probe.WriteFile("ready") + probe.WriteFile(opts.FileProbe.ReadinessPath) } } } diff --git a/docs/about/getting-started.md b/docs/about/getting-started.md index e81e32b..e0d4e7a 100644 --- a/docs/about/getting-started.md +++ b/docs/about/getting-started.md @@ -20,6 +20,8 @@ The application receives a number of command-line flags including the requests t | -http-requests | string | N/A | Http request to be sent. Request is in `:[:body]` format. E.g. `post:/ping:{"key": "value"}`. To send multiple requests, simply repeat this flag for each request. Use the notation `:file/xyz.json` if you want to use an external file for the request body. | | -fail-readiness | bool | false | If set to true readiness will fail if the target did not became ready in time | | -file-probe-enabled | bool | true | If set to true writes files that can be used as readiness/liveness probes. a file with the name `alive` is created when Mittens starts and a file named `ready` is created when the warmup completes | +| -file-probe-liveness-path | string | alive | File to be used for liveness probe | +| -file-probe-readiness-path | string | ready | File to be used for readiness probe | | -request-delay-milliseconds | int | 500 | Delay in milliseconds between requests | | -target-grpc-host | string | localhost | gRPC host to warm up | | -target-grpc-port | int | 50051 | gRPC port for warm up requests |