Merge pull request #4699 from influxdata/dom/silly-config
refactor: warn for silly object store configspull/24376/head
commit
507e153c5a
|
@ -1,7 +1,7 @@
|
||||||
//! This module implements the `remote partition` CLI subcommand
|
//! This module implements the `remote partition` CLI subcommand
|
||||||
|
|
||||||
use bytes::Bytes;
|
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 clap_blocks::{catalog_dsn::CatalogDsnConfig, object_store::ObjectStoreConfig};
|
||||||
use data_types::{
|
use data_types::{
|
||||||
ColumnType, KafkaPartition, NamespaceId, NamespaceSchema as CatalogNamespaceSchema,
|
ColumnType, KafkaPartition, NamespaceId, NamespaceSchema as CatalogNamespaceSchema,
|
||||||
|
@ -54,6 +54,12 @@ pub enum Error {
|
||||||
|
|
||||||
#[error("Partition not found")]
|
#[error("Partition not found")]
|
||||||
PartitionNotFound,
|
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
|
/// Manage IOx chunks
|
||||||
|
@ -133,6 +139,13 @@ pub async fn command(connection: Connection, config: Config) -> Result<(), Error
|
||||||
let partition_mapping =
|
let partition_mapping =
|
||||||
load_partition(&catalog, &schema, &pull.table, &partition).await?;
|
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 =
|
let object_store =
|
||||||
make_object_store(&pull.object_store).map_err(Error::ObjectStoreParsing)?;
|
make_object_store(&pull.object_store).map_err(Error::ObjectStoreParsing)?;
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,8 @@ async fn remote_partition_and_get_from_store_and_pull() {
|
||||||
.and(predicate::str::contains(filename)),
|
.and(predicate::str::contains(filename)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Ensure a warning is emitted when specifying (or
|
||||||
|
// defaulting to) in-memory file storage.
|
||||||
Command::cargo_bin("influxdb_iox")
|
Command::cargo_bin("influxdb_iox")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.arg("-h")
|
.arg("-h")
|
||||||
|
@ -134,6 +136,29 @@ async fn remote_partition_and_get_from_store_and_pull() {
|
||||||
.arg("my_awesome_table")
|
.arg("my_awesome_table")
|
||||||
.arg("1970-01-01")
|
.arg("1970-01-01")
|
||||||
.assert()
|
.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()
|
.success()
|
||||||
.stdout(
|
.stdout(
|
||||||
predicate::str::contains("wrote file")
|
predicate::str::contains("wrote file")
|
||||||
|
|
Loading…
Reference in New Issue