Merge pull request #4699 from influxdata/dom/silly-config

refactor: warn for silly object store configs
pull/24376/head
kodiakhq[bot] 2022-06-01 15:48:10 +00:00 committed by GitHub
commit 507e153c5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View File

@ -1,7 +1,7 @@
//! This module implements the `remote partition` CLI subcommand
use bytes::Bytes;
use clap_blocks::object_store::make_object_store;
use clap_blocks::object_store::{make_object_store, ObjectStoreType};
use clap_blocks::{catalog_dsn::CatalogDsnConfig, object_store::ObjectStoreConfig};
use data_types::{
ColumnType, KafkaPartition, NamespaceId, NamespaceSchema as CatalogNamespaceSchema,
@ -54,6 +54,12 @@ pub enum Error {
#[error("Partition not found")]
PartitionNotFound,
#[error(
"The object store is configured to store files in memory which is \
unlikely to be useful - try passing --object-store=file"
)]
SillyObjectStoreConfig,
}
/// Manage IOx chunks
@ -133,6 +139,13 @@ pub async fn command(connection: Connection, config: Config) -> Result<(), Error
let partition_mapping =
load_partition(&catalog, &schema, &pull.table, &partition).await?;
match &pull.object_store.object_store {
None | Some(ObjectStoreType::Memory | ObjectStoreType::MemoryThrottled) => {
return Err(Error::SillyObjectStoreConfig);
}
_ => {}
}
let object_store =
make_object_store(&pull.object_store).map_err(Error::ObjectStoreParsing)?;

View File

@ -119,6 +119,8 @@ async fn remote_partition_and_get_from_store_and_pull() {
.and(predicate::str::contains(filename)),
);
// Ensure a warning is emitted when specifying (or
// defaulting to) in-memory file storage.
Command::cargo_bin("influxdb_iox")
.unwrap()
.arg("-h")
@ -134,6 +136,29 @@ async fn remote_partition_and_get_from_store_and_pull() {
.arg("my_awesome_table")
.arg("1970-01-01")
.assert()
.failure()
.stderr(predicate::str::contains("try passing --object-store=file"));
// Ensure files are actually wrote to the filesystem
let dir = tempfile::tempdir().expect("could not get temporary directory");
Command::cargo_bin("influxdb_iox")
.unwrap()
.arg("-h")
.arg(&router_addr)
.arg("remote")
.arg("partition")
.arg("pull")
.arg("--catalog")
.arg("memory")
.arg("--object-store")
.arg("file")
.arg("--data-dir")
.arg(dir.path().to_str().unwrap())
.arg(&namespace)
.arg("my_awesome_table")
.arg("1970-01-01")
.assert()
.success()
.stdout(
predicate::str::contains("wrote file")