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)

* 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>
  • Loading branch information
pracucci authored Sep 14, 2022
1 parent eb9abf7 commit bfad6ac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* [BUGFIX] Memberlist: retry joining memberlist cluster on startup when no nodes are resolved. #2837
* [BUGFIX] Query-frontend: fix incorrect mapping of http status codes 413 to 500 when request is too large. #2819
* [BUGFIX] Ruler: fix panic when `ruler.external_url` is explicitly set to an empty string (`""`) in YAML. #2915
* [BUGFIX] Fix sanity check done on configured filesystem directories when running Alertmanager in microservices mode. #2947

### Mixin

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 bfad6ac

Please sign in to comment.