Skip to content

Commit df038d7

Browse files
authored
Fix sanity check done on configured filesystem directories when running Alertmanager in microservices mode (#2947) (#2948)
* Fix sanity check done on configured filesystem directories when running Alertmanager in microservices mode Signed-off-by: Marco Pracucci <marco@pracucci.com> * Added CHANGELOG entry Signed-off-by: Marco Pracucci <marco@pracucci.com> Signed-off-by: Marco Pracucci <marco@pracucci.com> (cherry picked from commit bfad6ac)
1 parent 95bf87b commit df038d7

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Grafana Mimir
66

7+
* [BUGFIX] Fix sanity check done on configured filesystem directories when running Alertmanager in microservices mode. #2947
8+
79
### Mixin
810

911
### Jsonnet

pkg/mimir/mimir.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ func (c *Config) validateFilesystemPaths(logger log.Logger) error {
325325

326326
var paths []pathConfig
327327

328-
if c.BlocksStorage.Bucket.Backend == bucket.Filesystem {
328+
// Blocks storage (check only for components using it).
329+
if c.isAnyModuleEnabled(All, Write, Read, Backend, Ingester, Querier, StoreGateway, Compactor, Ruler) && c.BlocksStorage.Bucket.Backend == bucket.Filesystem {
329330
// Add the optional prefix to the path, because that's the actual location where blocks will be stored.
330331
paths = append(paths, pathConfig{
331332
name: "blocks storage filesystem directory",

pkg/mimir/mimir_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,25 @@ func TestConfig_validateFilesystemPaths(t *testing.T) {
542542
cfg.BlocksStorage.Bucket.Filesystem.Directory = "./data-blocks"
543543
},
544544
},
545+
"should succeed if blocks storage filesystem directory overlaps with alertmanager data directory, but we're running alertmanager in microservices mode": {
546+
setup: func(cfg *Config) {
547+
cfg.Target = flagext.StringSliceCSV{AlertManager}
548+
cfg.BlocksStorage.Bucket.Backend = bucket.Filesystem
549+
cfg.BlocksStorage.Bucket.Filesystem.Directory = "blocks"
550+
cfg.AlertmanagerStorage.Backend = bucket.Filesystem
551+
cfg.AlertmanagerStorage.Filesystem.Directory = "/data/alertmanager"
552+
cfg.Alertmanager.DataDir = cwd
553+
},
554+
},
555+
"should fail if blocks storage filesystem directory overlaps with alertmanager data directory, and alertmanager is running along with other components": {
556+
setup: func(cfg *Config) {
557+
cfg.Target = flagext.StringSliceCSV{All, AlertManager}
558+
cfg.Common.Storage.Backend = bucket.Filesystem
559+
cfg.Common.Storage.Filesystem.Directory = "blocks"
560+
cfg.Alertmanager.DataDir = cwd
561+
},
562+
expectedErr: fmt.Sprintf(`the configured blocks storage filesystem directory "blocks" cannot overlap with the configured alertmanager data directory "%s"`, cwd),
563+
},
545564
}
546565

547566
for testName, testData := range tests {

0 commit comments

Comments
 (0)