From 6947ee9bc9f971dfb44443fbe15833b4e2d2e577 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Fri, 8 Nov 2013 23:43:05 +0700 Subject: [PATCH] Try to create metrics root directory if missing This change tries to be nice and create the metrics directoy first before erroring out. Change-Id: I72691cdc32469708cd671c6ef1fb7db55fe60430 --- storage/metric/tiered.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/metric/tiered.go b/storage/metric/tiered.go index 17981c0c4..4088427f9 100644 --- a/storage/metric/tiered.go +++ b/storage/metric/tiered.go @@ -15,6 +15,7 @@ package metric import ( "fmt" + "os" "sort" "sync" "time" @@ -114,7 +115,9 @@ const watermarkCacheLimit = 1024 * 1024 func NewTieredStorage(appendToDiskQueueDepth, viewQueueDepth uint, flushMemoryInterval time.Duration, memoryTTL time.Duration, rootDirectory string) (*TieredStorage, error) { if isDir, _ := utility.IsDir(rootDirectory); !isDir { - return nil, fmt.Errorf("Could not find metrics directory %s", rootDirectory) + if err := os.MkdirAll(rootDirectory, 0755); err != nil { + return nil, fmt.Errorf("Could not find or create metrics directory %s: %s", rootDirectory, err) + } } diskStorage, err := NewLevelDBMetricPersistence(rootDirectory)