fix: warn if `--data-dir is specified but `--object_store` type is not file (#5147)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
pull/24376/head
Andrew Lamb 2022-07-18 21:00:54 -04:00 committed by GitHub
parent f7a0fd43d2
commit 17231b4001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -5,7 +5,7 @@ use object_store::memory::InMemory;
use object_store::path::Path; use object_store::path::Path;
use object_store::throttle::ThrottledStore; use object_store::throttle::ThrottledStore;
use object_store::{throttle::ThrottleConfig, DynObjectStore}; use object_store::{throttle::ThrottleConfig, DynObjectStore};
use observability_deps::tracing::info; use observability_deps::tracing::{info, warn};
use snafu::{ResultExt, Snafu}; use snafu::{ResultExt, Snafu};
use std::sync::Arc; use std::sync::Arc;
use std::{fs, num::NonZeroUsize, path::PathBuf, time::Duration}; use std::{fs, num::NonZeroUsize, path::PathBuf, time::Duration};
@ -365,6 +365,13 @@ fn new_azure(_: &ObjectStoreConfig) -> Result<Arc<DynObjectStore>, ParseError> {
} }
pub fn make_object_store(config: &ObjectStoreConfig) -> Result<Arc<DynObjectStore>, ParseError> { pub fn make_object_store(config: &ObjectStoreConfig) -> Result<Arc<DynObjectStore>, ParseError> {
if let Some(data_dir) = &config.database_directory {
if !matches!(&config.object_store, Some(ObjectStoreType::File)) {
warn!(?data_dir, object_store_type=?config.object_store,
"--data-dir / `INFLUXDB_IOX_DB_DIR` ignored. It only affects 'file' object stores");
}
}
match &config.object_store { match &config.object_store {
Some(ObjectStoreType::Memory) | None => Ok(Arc::new(InMemory::new())), Some(ObjectStoreType::Memory) | None => Ok(Arc::new(InMemory::new())),
Some(ObjectStoreType::MemoryThrottled) => { Some(ObjectStoreType::MemoryThrottled) => {