Skip to content

Commit

Permalink
Fix sanity check done on configured filesystem directories when runni…
Browse files Browse the repository at this point in the history
…ng 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)
  • Loading branch information
pracucci committed Sep 14, 2022
1 parent 95bf87b commit df038d7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Grafana Mimir

* [BUGFIX] Fix sanity check done on configured filesystem directories when running Alertmanager in microservices mode. #2947

### Mixin

### Jsonnet
Expand Down
3 changes: 2 additions & 1 deletion pkg/mimir/mimir.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ func (c *Config) validateFilesystemPaths(logger log.Logger) error {

var paths []pathConfig

if c.BlocksStorage.Bucket.Backend == bucket.Filesystem {
// Blocks storage (check only for components using it).
if c.isAnyModuleEnabled(All, Write, Read, Backend, Ingester, Querier, StoreGateway, Compactor, Ruler) && c.BlocksStorage.Bucket.Backend == bucket.Filesystem {
// Add the optional prefix to the path, because that's the actual location where blocks will be stored.
paths = append(paths, pathConfig{
name: "blocks storage filesystem directory",
Expand Down
19 changes: 19 additions & 0 deletions pkg/mimir/mimir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,25 @@ func TestConfig_validateFilesystemPaths(t *testing.T) {
cfg.BlocksStorage.Bucket.Filesystem.Directory = "./data-blocks"
},
},
"should succeed if blocks storage filesystem directory overlaps with alertmanager data directory, but we're running alertmanager in microservices mode": {
setup: func(cfg *Config) {
cfg.Target = flagext.StringSliceCSV{AlertManager}
cfg.BlocksStorage.Bucket.Backend = bucket.Filesystem
cfg.BlocksStorage.Bucket.Filesystem.Directory = "blocks"
cfg.AlertmanagerStorage.Backend = bucket.Filesystem
cfg.AlertmanagerStorage.Filesystem.Directory = "/data/alertmanager"
cfg.Alertmanager.DataDir = cwd
},
},
"should fail if blocks storage filesystem directory overlaps with alertmanager data directory, and alertmanager is running along with other components": {
setup: func(cfg *Config) {
cfg.Target = flagext.StringSliceCSV{All, AlertManager}
cfg.Common.Storage.Backend = bucket.Filesystem
cfg.Common.Storage.Filesystem.Directory = "blocks"
cfg.Alertmanager.DataDir = cwd
},
expectedErr: fmt.Sprintf(`the configured blocks storage filesystem directory "blocks" cannot overlap with the configured alertmanager data directory "%s"`, cwd),
},
}

for testName, testData := range tests {
Expand Down

0 comments on commit df038d7

Please sign in to comment.