mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-05 12:57:42 +00:00
feat: isolate list objects quorum config
This commit is contained in:
@@ -181,6 +181,8 @@ pub struct ListPathOptions {
|
|||||||
const MARKER_TAG_VERSION: &str = "v1";
|
const MARKER_TAG_VERSION: &str = "v1";
|
||||||
const ENV_API_LIST_QUORUM: &str = "RUSTFS_API_LIST_QUORUM";
|
const ENV_API_LIST_QUORUM: &str = "RUSTFS_API_LIST_QUORUM";
|
||||||
const DEFAULT_API_LIST_QUORUM: &str = "strict";
|
const DEFAULT_API_LIST_QUORUM: &str = "strict";
|
||||||
|
const ENV_API_LIST_OBJECTS_QUORUM: &str = "RUSTFS_LIST_OBJECTS_QUORUM";
|
||||||
|
const DEFAULT_API_LIST_OBJECTS_QUORUM: &str = "optimal";
|
||||||
|
|
||||||
fn normalize_list_quorum(value: &str) -> &'static str {
|
fn normalize_list_quorum(value: &str) -> &'static str {
|
||||||
let value = value.trim();
|
let value = value.trim();
|
||||||
@@ -202,6 +204,11 @@ fn list_quorum_from_env() -> String {
|
|||||||
normalize_list_quorum(&value).to_owned()
|
normalize_list_quorum(&value).to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn list_objects_quorum_from_env() -> String {
|
||||||
|
let value = rustfs_utils::get_env_str(ENV_API_LIST_OBJECTS_QUORUM, DEFAULT_API_LIST_OBJECTS_QUORUM);
|
||||||
|
normalize_list_quorum(&value).to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
fn list_metadata_resolution_params(bucket: String, listing_quorum: usize, versioned: bool) -> MetadataResolutionParams {
|
fn list_metadata_resolution_params(bucket: String, listing_quorum: usize, versioned: bool) -> MetadataResolutionParams {
|
||||||
let mut resolver = MetadataResolutionParams {
|
let mut resolver = MetadataResolutionParams {
|
||||||
dir_quorum: listing_quorum,
|
dir_quorum: listing_quorum,
|
||||||
@@ -392,7 +399,7 @@ impl ECStore {
|
|||||||
limit: effective_max_keys,
|
limit: effective_max_keys,
|
||||||
marker,
|
marker,
|
||||||
incl_deleted,
|
incl_deleted,
|
||||||
ask_disks: list_quorum_from_env(),
|
ask_disks: list_objects_quorum_from_env(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -551,7 +558,7 @@ impl ECStore {
|
|||||||
limit: effective_max_keys,
|
limit: effective_max_keys,
|
||||||
marker,
|
marker,
|
||||||
incl_deleted: true,
|
incl_deleted: true,
|
||||||
ask_disks: list_quorum_from_env(),
|
ask_disks: list_objects_quorum_from_env(),
|
||||||
versioned: true,
|
versioned: true,
|
||||||
include_marker: has_version_marker,
|
include_marker: has_version_marker,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -1542,7 +1549,7 @@ impl Sets {
|
|||||||
limit: effective_max_keys,
|
limit: effective_max_keys,
|
||||||
marker,
|
marker,
|
||||||
incl_deleted,
|
incl_deleted,
|
||||||
ask_disks: list_quorum_from_env(),
|
ask_disks: list_objects_quorum_from_env(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1684,7 +1691,7 @@ impl Sets {
|
|||||||
limit: effective_max_keys,
|
limit: effective_max_keys,
|
||||||
marker,
|
marker,
|
||||||
incl_deleted: true,
|
incl_deleted: true,
|
||||||
ask_disks: list_quorum_from_env(),
|
ask_disks: list_objects_quorum_from_env(),
|
||||||
versioned: true,
|
versioned: true,
|
||||||
include_marker: has_version_marker,
|
include_marker: has_version_marker,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -2293,7 +2300,7 @@ impl SetDisks {
|
|||||||
limit: effective_max_keys,
|
limit: effective_max_keys,
|
||||||
marker,
|
marker,
|
||||||
incl_deleted,
|
incl_deleted,
|
||||||
ask_disks: list_quorum_from_env(),
|
ask_disks: list_objects_quorum_from_env(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2435,7 +2442,7 @@ impl SetDisks {
|
|||||||
limit: effective_max_keys,
|
limit: effective_max_keys,
|
||||||
marker,
|
marker,
|
||||||
incl_deleted: true,
|
incl_deleted: true,
|
||||||
ask_disks: list_quorum_from_env(),
|
ask_disks: list_objects_quorum_from_env(),
|
||||||
versioned: true,
|
versioned: true,
|
||||||
include_marker: has_version_marker,
|
include_marker: has_version_marker,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -2959,9 +2966,9 @@ fn calc_common_counter(infos: &[DiskInfo], read_quorum: usize) -> u64 {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::{
|
use super::{
|
||||||
ENV_API_LIST_QUORUM, GatherResultsState, ListPathOptions, MAX_OBJECT_LIST, VersionMarker, gather_results,
|
ENV_API_LIST_OBJECTS_QUORUM, ENV_API_LIST_QUORUM, GatherResultsState, ListPathOptions, MAX_OBJECT_LIST, VersionMarker,
|
||||||
list_metadata_resolution_params, list_quorum_from_env, max_keys_plus_one, merge_entry_channels, normalize_list_quorum,
|
gather_results, list_metadata_resolution_params, list_objects_quorum_from_env, list_quorum_from_env, max_keys_plus_one,
|
||||||
parse_version_marker, version_marker_for_entries, walk_result_from_set_errors,
|
merge_entry_channels, normalize_list_quorum, parse_version_marker, version_marker_for_entries, walk_result_from_set_errors,
|
||||||
};
|
};
|
||||||
use crate::error::StorageError;
|
use crate::error::StorageError;
|
||||||
use rustfs_filemeta::{MetaCacheEntries, MetaCacheEntriesSorted, MetaCacheEntry};
|
use rustfs_filemeta::{MetaCacheEntries, MetaCacheEntriesSorted, MetaCacheEntry};
|
||||||
@@ -3193,6 +3200,22 @@ mod test {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial_test::serial]
|
||||||
|
fn list_objects_quorum_from_env_defaults_to_optimal() {
|
||||||
|
temp_env::with_var_unset(ENV_API_LIST_OBJECTS_QUORUM, || {
|
||||||
|
assert_eq!(list_objects_quorum_from_env(), "optimal");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial_test::serial]
|
||||||
|
fn list_objects_quorum_from_env_honors_supported_value() {
|
||||||
|
temp_env::with_var(ENV_API_LIST_OBJECTS_QUORUM, Some("strict"), || {
|
||||||
|
assert_eq!(list_objects_quorum_from_env(), "strict");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn list_metadata_resolution_params_limits_plain_listing_to_latest_version() {
|
fn list_metadata_resolution_params_limits_plain_listing_to_latest_version() {
|
||||||
let resolver = list_metadata_resolution_params("bucket".to_string(), 2, false);
|
let resolver = list_metadata_resolution_params("bucket".to_string(), 2, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user