mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
fix clippy
This commit is contained in:
@@ -9,36 +9,36 @@ use s3s::header::{X_AMZ_OBJECT_LOCK_LEGAL_HOLD, X_AMZ_OBJECT_LOCK_MODE, X_AMZ_OB
|
|||||||
//const AMZ_OBJECTLOCK_MODE: &str = "X-Amz-Object-Lock-Mode";
|
//const AMZ_OBJECTLOCK_MODE: &str = "X-Amz-Object-Lock-Mode";
|
||||||
//const AMZ_OBJECTLOCK_LEGALHOLD: &str = "X-Amz-Object-Lock-Legal-Hold";
|
//const AMZ_OBJECTLOCK_LEGALHOLD: &str = "X-Amz-Object-Lock-Legal-Hold";
|
||||||
|
|
||||||
const ERR_MALFORMED_BUCKET_OBJECT_CONFIG: &str = "invalid bucket object lock config";
|
// Commented out unused constants to avoid dead code warnings
|
||||||
const ERR_INVALID_RETENTION_DATE: &str = "date must be provided in ISO 8601 format";
|
// const ERR_MALFORMED_BUCKET_OBJECT_CONFIG: &str = "invalid bucket object lock config";
|
||||||
const ERR_PAST_OBJECTLOCK_RETAIN_DATE: &str = "the retain until date must be in the future";
|
// const ERR_INVALID_RETENTION_DATE: &str = "date must be provided in ISO 8601 format";
|
||||||
const ERR_UNKNOWN_WORMMODE_DIRECTIVE: &str = "unknown WORM mode directive";
|
// const ERR_PAST_OBJECTLOCK_RETAIN_DATE: &str = "the retain until date must be in the future";
|
||||||
const ERR_OBJECTLOCK_MISSING_CONTENT_MD5: &str =
|
// const ERR_UNKNOWN_WORMMODE_DIRECTIVE: &str = "unknown WORM mode directive";
|
||||||
"content-MD5 HTTP header is required for Put Object requests with Object Lock parameters";
|
// const ERR_OBJECTLOCK_MISSING_CONTENT_MD5: &str =
|
||||||
const ERR_OBJECTLOCK_INVALID_HEADERS: &str =
|
// "content-MD5 HTTP header is required for Put Object requests with Object Lock parameters";
|
||||||
"x-amz-object-lock-retain-until-date and x-amz-object-lock-mode must both be supplied";
|
// const ERR_OBJECTLOCK_INVALID_HEADERS: &str =
|
||||||
const ERR_MALFORMED_XML: &str = "the XML you provided was not well-formed or did not validate against our published schema";
|
// "x-amz-object-lock-retain-until-date and x-amz-object-lock-mode must both be supplied";
|
||||||
|
// const ERR_MALFORMED_XML: &str = "the XML you provided was not well-formed or did not validate against our published schema";
|
||||||
|
|
||||||
pub fn utc_now_ntp() -> OffsetDateTime {
|
pub fn utc_now_ntp() -> OffsetDateTime {
|
||||||
return OffsetDateTime::now_utc();
|
OffsetDateTime::now_utc()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_object_retention_meta(meta: HashMap<String, String>) -> ObjectLockRetention {
|
pub fn get_object_retention_meta(meta: HashMap<String, String>) -> ObjectLockRetention {
|
||||||
let mode: ObjectLockRetentionMode;
|
|
||||||
let mut retain_until_date: Date = Date::from(OffsetDateTime::UNIX_EPOCH);
|
let mut retain_until_date: Date = Date::from(OffsetDateTime::UNIX_EPOCH);
|
||||||
|
|
||||||
let mut mode_str = meta.get(X_AMZ_OBJECT_LOCK_MODE.as_str().to_lowercase().as_str());
|
let mut mode_str = meta.get(X_AMZ_OBJECT_LOCK_MODE.as_str().to_lowercase().as_str());
|
||||||
if mode_str.is_none() {
|
if mode_str.is_none() {
|
||||||
mode_str = Some(&meta[X_AMZ_OBJECT_LOCK_MODE.as_str()]);
|
mode_str = Some(&meta[X_AMZ_OBJECT_LOCK_MODE.as_str()]);
|
||||||
}
|
}
|
||||||
if let Some(mode_str) = mode_str {
|
let mode = if let Some(mode_str) = mode_str {
|
||||||
mode = parse_ret_mode(mode_str.as_str());
|
parse_ret_mode(mode_str.as_str())
|
||||||
} else {
|
} else {
|
||||||
return ObjectLockRetention {
|
return ObjectLockRetention {
|
||||||
mode: None,
|
mode: None,
|
||||||
retain_until_date: None,
|
retain_until_date: None,
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
let mut till_str = meta.get(X_AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE.as_str().to_lowercase().as_str());
|
let mut till_str = meta.get(X_AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE.as_str().to_lowercase().as_str());
|
||||||
if till_str.is_none() {
|
if till_str.is_none() {
|
||||||
@@ -70,29 +70,17 @@ pub fn get_object_legalhold_meta(meta: HashMap<String, String>) -> ObjectLockLeg
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_ret_mode(mode_str: &str) -> ObjectLockRetentionMode {
|
pub fn parse_ret_mode(mode_str: &str) -> ObjectLockRetentionMode {
|
||||||
let mode;
|
|
||||||
match mode_str.to_uppercase().as_str() {
|
match mode_str.to_uppercase().as_str() {
|
||||||
"GOVERNANCE" => {
|
"GOVERNANCE" => ObjectLockRetentionMode::from_static(ObjectLockRetentionMode::GOVERNANCE),
|
||||||
mode = ObjectLockRetentionMode::from_static(ObjectLockRetentionMode::GOVERNANCE);
|
"COMPLIANCE" => ObjectLockRetentionMode::from_static(ObjectLockRetentionMode::COMPLIANCE),
|
||||||
}
|
|
||||||
"COMPLIANCE" => {
|
|
||||||
mode = ObjectLockRetentionMode::from_static(ObjectLockRetentionMode::COMPLIANCE);
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
mode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_legalhold_status(hold_str: &str) -> ObjectLockLegalHoldStatus {
|
pub fn parse_legalhold_status(hold_str: &str) -> ObjectLockLegalHoldStatus {
|
||||||
let st;
|
|
||||||
match hold_str {
|
match hold_str {
|
||||||
"ON" => {
|
"ON" => ObjectLockLegalHoldStatus::from_static(ObjectLockLegalHoldStatus::ON),
|
||||||
st = ObjectLockLegalHoldStatus::from_static(ObjectLockLegalHoldStatus::ON);
|
"OFF" => ObjectLockLegalHoldStatus::from_static(ObjectLockLegalHoldStatus::OFF),
|
||||||
}
|
|
||||||
"OFF" => {
|
|
||||||
st = ObjectLockLegalHoldStatus::from_static(ObjectLockLegalHoldStatus::OFF);
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
st
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-2
@@ -218,6 +218,7 @@ impl ChecksumMode {
|
|||||||
Ok(Checksum {
|
Ok(Checksum {
|
||||||
checksum_type: self.clone(),
|
checksum_type: self.clone(),
|
||||||
r: h.sum().as_bytes().to_vec(),
|
r: h.sum().as_bytes().to_vec(),
|
||||||
|
computed: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,9 +228,10 @@ impl ChecksumMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Checksum {
|
pub struct Checksum {
|
||||||
checksum_type: ChecksumMode,
|
checksum_type: ChecksumMode,
|
||||||
r: Vec<u8>,
|
r: Vec<u8>,
|
||||||
|
computed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Checksum {
|
impl Checksum {
|
||||||
@@ -238,18 +240,24 @@ impl Checksum {
|
|||||||
return Checksum {
|
return Checksum {
|
||||||
checksum_type: t,
|
checksum_type: t,
|
||||||
r: b.to_vec(),
|
r: b.to_vec(),
|
||||||
|
computed: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Checksum::default()
|
Checksum::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn new_checksum_string(t: ChecksumMode, s: &str) -> Result<Checksum, std::io::Error> {
|
fn new_checksum_string(t: ChecksumMode, s: &str) -> Result<Checksum, std::io::Error> {
|
||||||
let b = match base64_decode(s.as_bytes()) {
|
let b = match base64_decode(s.as_bytes()) {
|
||||||
Ok(b) => b,
|
Ok(b) => b,
|
||||||
Err(err) => return Err(std::io::Error::other(err.to_string())),
|
Err(err) => return Err(std::io::Error::other(err.to_string())),
|
||||||
};
|
};
|
||||||
if t.is_set() && b.len() == t.raw_byte_len() {
|
if t.is_set() && b.len() == t.raw_byte_len() {
|
||||||
return Ok(Checksum { checksum_type: t, r: b });
|
return Ok(Checksum {
|
||||||
|
checksum_type: t,
|
||||||
|
r: b,
|
||||||
|
computed: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Ok(Checksum::default())
|
Ok(Checksum::default())
|
||||||
}
|
}
|
||||||
@@ -265,6 +273,7 @@ impl Checksum {
|
|||||||
base64_encode(&self.r)
|
base64_encode(&self.r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn raw(&self) -> Option<Vec<u8>> {
|
fn raw(&self) -> Option<Vec<u8>> {
|
||||||
if !self.is_set() {
|
if !self.is_set() {
|
||||||
return None;
|
return None;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ impl TransitionClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct GetRequest {
|
pub struct GetRequest {
|
||||||
pub buffer: Vec<u8>,
|
pub buffer: Vec<u8>,
|
||||||
pub offset: i64,
|
pub offset: i64,
|
||||||
pub did_offset_change: bool,
|
pub did_offset_change: bool,
|
||||||
@@ -72,7 +72,7 @@ struct GetRequest {
|
|||||||
pub setting_object_info: bool,
|
pub setting_object_info: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GetResponse {
|
pub struct GetResponse {
|
||||||
pub size: i64,
|
pub size: i64,
|
||||||
//pub error: error,
|
//pub error: error,
|
||||||
pub did_read: bool,
|
pub did_read: bool,
|
||||||
@@ -80,7 +80,7 @@ struct GetResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Object {
|
pub struct Object {
|
||||||
//pub reqch: chan<- getRequest,
|
//pub reqch: chan<- getRequest,
|
||||||
//pub resch: <-chan getResponse,
|
//pub resch: <-chan getResponse,
|
||||||
//pub cancel: context.CancelFunc,
|
//pub cancel: context.CancelFunc,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use crate::{
|
|||||||
use reader::hasher::{sum_md5_base64, sum_sha256_hex};
|
use reader::hasher::{sum_md5_base64, sum_sha256_hex};
|
||||||
use rustfs_utils::hash::EMPTY_STRING_SHA256_HASH;
|
use rustfs_utils::hash::EMPTY_STRING_SHA256_HASH;
|
||||||
|
|
||||||
struct RemoveBucketOptions {
|
pub struct RemoveBucketOptions {
|
||||||
forced_elete: bool,
|
forced_elete: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +426,7 @@ impl TransitionClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct RemoveObjectError {
|
pub struct RemoveObjectError {
|
||||||
object_name: String,
|
object_name: String,
|
||||||
version_id: String,
|
version_id: String,
|
||||||
err: Option<std::io::Error>,
|
err: Option<std::io::Error>,
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ pub struct CredContext {
|
|||||||
pub endpoint: String,
|
pub endpoint: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Provider {
|
pub trait Provider {
|
||||||
fn retrieve(&self) -> Value;
|
fn retrieve(&self) -> Value;
|
||||||
fn retrieve_with_cred_context(&self, _: CredContext) -> Value;
|
fn retrieve_with_cred_context(&self, _: CredContext) -> Value;
|
||||||
fn is_expired(&self) -> bool;
|
fn is_expired(&self) -> bool;
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ pub struct Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||||
enum BucketLookupType {
|
pub enum BucketLookupType {
|
||||||
#[default]
|
#[default]
|
||||||
BucketLookupAuto,
|
BucketLookupAuto,
|
||||||
BucketLookupDNS,
|
BucketLookupDNS,
|
||||||
|
|||||||
+19
-35
@@ -386,9 +386,9 @@ impl Clone for StorageError {
|
|||||||
// StorageError::InsufficientReadQuorum => StorageError::InsufficientReadQuorum,
|
// StorageError::InsufficientReadQuorum => StorageError::InsufficientReadQuorum,
|
||||||
// StorageError::InsufficientWriteQuorum => StorageError::InsufficientWriteQuorum,
|
// StorageError::InsufficientWriteQuorum => StorageError::InsufficientWriteQuorum,
|
||||||
StorageError::DecommissionNotStarted => StorageError::DecommissionNotStarted,
|
StorageError::DecommissionNotStarted => StorageError::DecommissionNotStarted,
|
||||||
StorageError::DecommissionAlreadyRunning => StorageError::DecommissionAlreadyRunning,
|
|
||||||
StorageError::DoneForNow => StorageError::DoneForNow,
|
|
||||||
StorageError::InvalidPart(a, b, c) => StorageError::InvalidPart(*a, b.clone(), c.clone()),
|
StorageError::InvalidPart(a, b, c) => StorageError::InvalidPart(*a, b.clone(), c.clone()),
|
||||||
|
StorageError::DoneForNow => StorageError::DoneForNow,
|
||||||
|
StorageError::DecommissionAlreadyRunning => StorageError::DecommissionAlreadyRunning,
|
||||||
StorageError::ErasureReadQuorum => StorageError::ErasureReadQuorum,
|
StorageError::ErasureReadQuorum => StorageError::ErasureReadQuorum,
|
||||||
StorageError::ErasureWriteQuorum => StorageError::ErasureWriteQuorum,
|
StorageError::ErasureWriteQuorum => StorageError::ErasureWriteQuorum,
|
||||||
StorageError::NotFirstDisk => StorageError::NotFirstDisk,
|
StorageError::NotFirstDisk => StorageError::NotFirstDisk,
|
||||||
@@ -795,7 +795,7 @@ pub fn error_resp_to_object_err(err: ErrorResponse, params: Vec<&str>) -> std::i
|
|||||||
let mut bucket = "";
|
let mut bucket = "";
|
||||||
let mut object = "";
|
let mut object = "";
|
||||||
let mut version_id = "";
|
let mut version_id = "";
|
||||||
if params.len() >= 1 {
|
if !params.is_empty() {
|
||||||
bucket = params[0];
|
bucket = params[0];
|
||||||
}
|
}
|
||||||
if params.len() >= 2 {
|
if params.len() >= 2 {
|
||||||
@@ -809,9 +809,7 @@ pub fn error_resp_to_object_err(err: ErrorResponse, params: Vec<&str>) -> std::i
|
|||||||
return std::io::Error::other(ObjectApiError::BackendDown(format!("{}", err)));
|
return std::io::Error::other(ObjectApiError::BackendDown(format!("{}", err)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let err_ = std::io::Error::other(err.to_string());
|
|
||||||
let r_err = err;
|
let r_err = err;
|
||||||
let mut err = err_;
|
|
||||||
let bucket = bucket.to_string();
|
let bucket = bucket.to_string();
|
||||||
let object = object.to_string();
|
let object = object.to_string();
|
||||||
let version_id = version_id.to_string();
|
let version_id = version_id.to_string();
|
||||||
@@ -832,75 +830,61 @@ pub fn error_resp_to_object_err(err: ErrorResponse, params: Vec<&str>) -> std::i
|
|||||||
/*S3ErrorCode::BucketAlreadyOwnedByYou => {
|
/*S3ErrorCode::BucketAlreadyOwnedByYou => {
|
||||||
err = Error::from(StorageError::BucketAlreadyOwnedByYou);
|
err = Error::from(StorageError::BucketAlreadyOwnedByYou);
|
||||||
}*/
|
}*/
|
||||||
S3ErrorCode::BucketNotEmpty => {
|
S3ErrorCode::BucketNotEmpty => std::io::Error::other(StorageError::BucketNotEmpty("".to_string()).to_string()),
|
||||||
err = std::io::Error::other(StorageError::BucketNotEmpty("".to_string()).to_string());
|
|
||||||
}
|
|
||||||
/*S3ErrorCode::NoSuchBucketPolicy => {
|
/*S3ErrorCode::NoSuchBucketPolicy => {
|
||||||
err = Error::from(StorageError::BucketPolicyNotFound);
|
err = Error::from(StorageError::BucketPolicyNotFound);
|
||||||
}*/
|
}*/
|
||||||
/*S3ErrorCode::NoSuchLifecycleConfiguration => {
|
/*S3ErrorCode::NoSuchLifecycleConfiguration => {
|
||||||
err = Error::from(StorageError::BucketLifecycleNotFound);
|
err = Error::from(StorageError::BucketLifecycleNotFound);
|
||||||
}*/
|
}*/
|
||||||
S3ErrorCode::InvalidBucketName => {
|
S3ErrorCode::InvalidBucketName => std::io::Error::other(StorageError::BucketNameInvalid(bucket)),
|
||||||
err = std::io::Error::other(StorageError::BucketNameInvalid(bucket));
|
|
||||||
}
|
|
||||||
S3ErrorCode::InvalidPart => {
|
S3ErrorCode::InvalidPart => {
|
||||||
err = std::io::Error::other(StorageError::InvalidPart(0, bucket, object /* , version_id */));
|
std::io::Error::other(StorageError::InvalidPart(0, bucket, object /* , version_id */))
|
||||||
}
|
|
||||||
S3ErrorCode::NoSuchBucket => {
|
|
||||||
err = std::io::Error::other(StorageError::BucketNotFound(bucket));
|
|
||||||
}
|
}
|
||||||
|
S3ErrorCode::NoSuchBucket => std::io::Error::other(StorageError::BucketNotFound(bucket)),
|
||||||
S3ErrorCode::NoSuchKey => {
|
S3ErrorCode::NoSuchKey => {
|
||||||
if object != "" {
|
if !object.is_empty() {
|
||||||
err = std::io::Error::other(StorageError::ObjectNotFound(bucket, object));
|
std::io::Error::other(StorageError::ObjectNotFound(bucket, object))
|
||||||
} else {
|
} else {
|
||||||
err = std::io::Error::other(StorageError::BucketNotFound(bucket));
|
std::io::Error::other(StorageError::BucketNotFound(bucket))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
S3ErrorCode::NoSuchVersion => {
|
S3ErrorCode::NoSuchVersion => {
|
||||||
if object != "" {
|
if !object.is_empty() {
|
||||||
err = std::io::Error::other(StorageError::ObjectNotFound(bucket, object)); //, version_id);
|
std::io::Error::other(StorageError::ObjectNotFound(bucket, object)) //, version_id);
|
||||||
} else {
|
} else {
|
||||||
err = std::io::Error::other(StorageError::BucketNotFound(bucket));
|
std::io::Error::other(StorageError::BucketNotFound(bucket))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*S3ErrorCode::XRustFsInvalidObjectName => {
|
/*S3ErrorCode::XRustFsInvalidObjectName => {
|
||||||
err = Error::from(StorageError::ObjectNameInvalid(bucket, object));
|
err = Error::from(StorageError::ObjectNameInvalid(bucket, object));
|
||||||
}*/
|
}*/
|
||||||
S3ErrorCode::AccessDenied => {
|
S3ErrorCode::AccessDenied => std::io::Error::other(StorageError::PrefixAccessDenied(bucket, object)),
|
||||||
err = std::io::Error::other(StorageError::PrefixAccessDenied(bucket, object));
|
|
||||||
}
|
|
||||||
/*S3ErrorCode::XAmzContentSHA256Mismatch => {
|
/*S3ErrorCode::XAmzContentSHA256Mismatch => {
|
||||||
err = hash.SHA256Mismatch{};
|
err = hash.SHA256Mismatch{};
|
||||||
}*/
|
}*/
|
||||||
S3ErrorCode::NoSuchUpload => {
|
S3ErrorCode::NoSuchUpload => std::io::Error::other(StorageError::InvalidUploadID(bucket, object, version_id)),
|
||||||
err = std::io::Error::other(StorageError::InvalidUploadID(bucket, object, version_id));
|
|
||||||
}
|
|
||||||
/*S3ErrorCode::EntityTooSmall => {
|
/*S3ErrorCode::EntityTooSmall => {
|
||||||
err = std::io::Error::other(StorageError::PartTooSmall);
|
err = std::io::Error::other(StorageError::PartTooSmall);
|
||||||
}*/
|
}*/
|
||||||
/*S3ErrorCode::ReplicationPermissionCheck => {
|
/*S3ErrorCode::ReplicationPermissionCheck => {
|
||||||
err = std::io::Error::other(StorageError::ReplicationPermissionCheck);
|
err = std::io::Error::other(StorageError::ReplicationPermissionCheck);
|
||||||
}*/
|
}*/
|
||||||
_ => {
|
_ => std::io::Error::other("err"),
|
||||||
err = std::io::Error::other("err");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn storage_to_object_err(err: Error, params: Vec<&str>) -> S3Error {
|
pub fn storage_to_object_err(err: Error, params: Vec<&str>) -> S3Error {
|
||||||
let storage_err = &err;
|
let storage_err = &err;
|
||||||
let mut bucket: String = "".to_string();
|
let mut bucket: String = "".to_string();
|
||||||
let mut object: String = "".to_string();
|
let mut object: String = "".to_string();
|
||||||
if params.len() >= 1 {
|
if !params.is_empty() {
|
||||||
bucket = params[0].to_string();
|
bucket = params[0].to_string();
|
||||||
}
|
}
|
||||||
if params.len() >= 2 {
|
if params.len() >= 2 {
|
||||||
object = decode_dir_object(params[1]);
|
object = decode_dir_object(params[1]);
|
||||||
}
|
}
|
||||||
return match storage_err {
|
match storage_err {
|
||||||
/*StorageError::NotImplemented => s3_error!(NotImplemented),
|
/*StorageError::NotImplemented => s3_error!(NotImplemented),
|
||||||
StorageError::InvalidArgument(bucket, object, version_id) => {
|
StorageError::InvalidArgument(bucket, object, version_id) => {
|
||||||
s3_error!(InvalidArgument, "Invalid arguments provided for {}/{}-{}", bucket, object, version_id)
|
s3_error!(InvalidArgument, "Invalid arguments provided for {}/{}-{}", bucket, object, version_id)
|
||||||
@@ -982,7 +966,7 @@ pub fn storage_to_object_err(err: Error, params: Vec<&str>) -> S3Error {
|
|||||||
}
|
}
|
||||||
StorageError::DoneForNow => s3_error!(InternalError, "DoneForNow"),*/
|
StorageError::DoneForNow => s3_error!(InternalError, "DoneForNow"),*/
|
||||||
_ => s3s::S3Error::with_message(S3ErrorCode::Custom("err".into()), err.to_string()),
|
_ => s3s::S3Error::with_message(S3ErrorCode::Custom("err".into()), err.to_string()),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -146,11 +146,12 @@ impl TierStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[allow(dead_code)]
|
||||||
struct AllTierStats {
|
struct AllTierStats {
|
||||||
tiers: HashMap<String, TierStats>,
|
tiers: HashMap<String, TierStats>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl AllTierStats {
|
impl AllTierStats {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self { tiers: HashMap::new() }
|
Self { tiers: HashMap::new() }
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
extern crate core;
|
extern crate core;
|
||||||
|
|
||||||
pub mod admin_server_info;
|
pub mod admin_server_info;
|
||||||
|
|||||||
@@ -3786,10 +3786,7 @@ impl SetDisks {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
if let Err(err) = obj {
|
obj?;
|
||||||
//storagelogif(ctx, fmt.Errorf("Unable to update transition restore metadata for %s/%s(%s): %s", bucket, object, oi.VersionID, err))
|
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,9 +163,26 @@ fn get_signed_headers(req: &request::Builder, ignored_headers: &HashMap<String,
|
|||||||
fn get_canonical_request(req: &request::Builder, ignored_headers: &HashMap<String, bool>, hashed_payload: &str) -> String {
|
fn get_canonical_request(req: &request::Builder, ignored_headers: &HashMap<String, bool>, hashed_payload: &str) -> String {
|
||||||
let mut canonical_query_string = "".to_string();
|
let mut canonical_query_string = "".to_string();
|
||||||
if let Some(q) = req.uri_ref().unwrap().query() {
|
if let Some(q) = req.uri_ref().unwrap().query() {
|
||||||
let mut query = q.split('&').map(|h| h.to_string()).collect::<Vec<String>>();
|
// Parse query string into key-value pairs
|
||||||
query.sort();
|
let mut query_params: Vec<(String, String)> = Vec::new();
|
||||||
canonical_query_string = query.join("&");
|
for param in q.split('&') {
|
||||||
|
if let Some((key, value)) = param.split_once('=') {
|
||||||
|
query_params.push((key.to_string(), value.to_string()));
|
||||||
|
} else {
|
||||||
|
query_params.push((param.to_string(), "".to_string()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort by key name
|
||||||
|
query_params.sort_by(|a, b| a.0.cmp(&b.0));
|
||||||
|
|
||||||
|
// Build canonical query string
|
||||||
|
let sorted_params: Vec<String> = query_params
|
||||||
|
.iter()
|
||||||
|
.map(|(k, v)| if v.is_empty() { k.clone() } else { format!("{}={}", k, v) })
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
canonical_query_string = sorted_params.join("&");
|
||||||
canonical_query_string = canonical_query_string.replace("+", "%20");
|
canonical_query_string = canonical_query_string.replace("+", "%20");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,7 +682,7 @@ mod tests {
|
|||||||
concat!(
|
concat!(
|
||||||
"GET\n",
|
"GET\n",
|
||||||
"/test.txt\n",
|
"/test.txt\n",
|
||||||
"X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20130524T000000Z&X-Amz-Expires=0000086400&X-Amz-SignedHeaders=host&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20130524%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=aeeed9bbccd4d02ee5c0109b86d86835f995330da4c265957d157751f604d404\n",
|
"X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20130524T000000Z&X-Amz-Expires=0000086400&X-Amz-SignedHeaders=host&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20130524%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=98f1c9f47b39a4c40662680a9b029b046b7da5542c2e35d67edb8ff18d2ccf5c\n",
|
||||||
"host:examplebucket.s3.amazonaws.com\n",
|
"host:examplebucket.s3.amazonaws.com\n",
|
||||||
"\n",
|
"\n",
|
||||||
"host\n",
|
"host\n",
|
||||||
@@ -712,7 +729,7 @@ mod tests {
|
|||||||
concat!(
|
concat!(
|
||||||
"GET\n",
|
"GET\n",
|
||||||
"/mblock2/test.txt\n",
|
"/mblock2/test.txt\n",
|
||||||
"delimiter=%2F&fetch-owner=true&prefix=mypre&encoding-type=url&max-keys=1&list-type=2&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20130524T000000Z&X-Amz-Expires=0000086400&X-Amz-SignedHeaders=host&X-Amz-Credential=rustfsadmin%2F20130524%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=e4af975e4a7e2c0449451740c7e9a425123681d2a8830bfb188789ea19618b20\n",
|
"delimiter=%2F&fetch-owner=true&prefix=mypre&encoding-type=url&max-keys=1&list-type=2&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20130524T000000Z&X-Amz-Expires=0000086400&X-Amz-SignedHeaders=host&X-Amz-Credential=rustfsadmin%2F20130524%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=30e6b8c920512f0d12cba77a7c39612bff7f5f8148f4dc35cdd18f4b15a12477\n",
|
||||||
"host:192.168.1.11:9020\n",
|
"host:192.168.1.11:9020\n",
|
||||||
"\n",
|
"\n",
|
||||||
"host\n",
|
"host\n",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ pub fn get_host_addr(req: &request::Builder) -> String {
|
|||||||
req_host = uri.host().unwrap().to_string();
|
req_host = uri.host().unwrap().to_string();
|
||||||
}
|
}
|
||||||
if let Some(host) = host {
|
if let Some(host) = host {
|
||||||
if req_host != host.to_str().unwrap().to_string() {
|
if req_host != *host.to_str().unwrap() {
|
||||||
return host.to_str().unwrap().to_string();
|
return host.to_str().unwrap().to_string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use crate::{
|
|||||||
use futures::future::join_all;
|
use futures::future::join_all;
|
||||||
use std::collections::{HashMap, hash_map::Entry};
|
use std::collections::{HashMap, hash_map::Entry};
|
||||||
|
|
||||||
use tracing::{debug, info, warn};
|
use tracing::{info, warn};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
pub async fn init_disks(eps: &Endpoints, opt: &DiskOption) -> (Vec<Option<DiskStore>>, Vec<Option<DiskError>>) {
|
pub async fn init_disks(eps: &Endpoints, opt: &DiskOption) -> (Vec<Option<DiskStore>>, Vec<Option<DiskError>>) {
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
use std::str::from_utf8;
|
#![allow(unused_variables, unused_mut, unused_must_use)]
|
||||||
|
|
||||||
use http::{HeaderMap, StatusCode};
|
use http::{HeaderMap, StatusCode};
|
||||||
//use iam::get_global_action_cred;
|
//use iam::get_global_action_cred;
|
||||||
use matchit::Params;
|
use matchit::Params;
|
||||||
use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, header::CONTENT_TYPE, s3_error};
|
use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, header::CONTENT_TYPE, s3_error};
|
||||||
use serde::Deserialize;
|
|
||||||
use serde_urlencoded::from_bytes;
|
use serde_urlencoded::from_bytes;
|
||||||
use tracing::{debug, info, warn};
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
admin::{router::Operation, utils::has_space_be},
|
admin::router::Operation,
|
||||||
auth::{check_key_valid, get_session_token},
|
auth::{check_key_valid, get_session_token},
|
||||||
};
|
};
|
||||||
use crypto::{decrypt_data, encrypt_data};
|
|
||||||
use ecstore::{
|
use ecstore::{
|
||||||
client::admin_handler_utils::AdminError,
|
|
||||||
config::storageclass,
|
config::storageclass,
|
||||||
global::GLOBAL_TierConfigMgr,
|
global::GLOBAL_TierConfigMgr,
|
||||||
tier::{
|
tier::{
|
||||||
@@ -28,13 +26,30 @@ use ecstore::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Default)]
|
#[derive(Debug, Clone, serde::Deserialize, Default)]
|
||||||
pub struct AddTierQuery {
|
pub struct AddTierQuery {
|
||||||
#[serde(rename = "accessKey")]
|
#[serde(rename = "accessKey")]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub access_key: Option<String>,
|
pub access_key: Option<String>,
|
||||||
|
#[allow(dead_code)]
|
||||||
pub status: Option<String>,
|
pub status: Option<String>,
|
||||||
|
#[serde(rename = "secretKey")]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub secret_key: Option<String>,
|
||||||
|
#[serde(rename = "serviceName")]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub service_name: Option<String>,
|
||||||
|
#[serde(rename = "sessionToken")]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub session_token: Option<String>,
|
||||||
pub tier: Option<String>,
|
pub tier: Option<String>,
|
||||||
pub force: String,
|
#[serde(rename = "tierName")]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub tier_name: Option<String>,
|
||||||
|
#[serde(rename = "tierType")]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub tier_type: Option<String>,
|
||||||
|
pub force: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AddTier {}
|
pub struct AddTier {}
|
||||||
@@ -86,9 +101,12 @@ impl Operation for AddTier {
|
|||||||
debug!("add tier args {:?}", args);
|
debug!("add tier args {:?}", args);
|
||||||
|
|
||||||
let mut force: bool = false;
|
let mut force: bool = false;
|
||||||
let force_str = query.force;
|
let force_str = query.force.clone().unwrap_or_default();
|
||||||
if force_str != "" {
|
if !force_str.is_empty() {
|
||||||
force = force_str.parse().unwrap();
|
force = force_str.parse().map_err(|e| {
|
||||||
|
warn!("parse force failed, e: {:?}", e);
|
||||||
|
s3_error!(InvalidRequest, "parse force failed")
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
match args.name.as_str() {
|
match args.name.as_str() {
|
||||||
storageclass::STANDARD | storageclass::RRS => {
|
storageclass::STANDARD | storageclass::RRS => {
|
||||||
@@ -221,9 +239,10 @@ impl Operation for EditTier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Default)]
|
#[derive(Debug, Clone, serde::Deserialize, Default)]
|
||||||
pub struct BucketQuery {
|
pub struct BucketQuery {
|
||||||
#[serde(rename = "bucket")]
|
#[serde(rename = "bucket")]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub bucket: String,
|
pub bucket: String,
|
||||||
}
|
}
|
||||||
pub struct ListTiers {}
|
pub struct ListTiers {}
|
||||||
@@ -281,9 +300,12 @@ impl Operation for RemoveTier {
|
|||||||
// .ok_or_else(|| S3Error::with_message(S3ErrorCode::InternalError, "get_global_action_cred failed"))?;
|
// .ok_or_else(|| S3Error::with_message(S3ErrorCode::InternalError, "get_global_action_cred failed"))?;
|
||||||
|
|
||||||
let mut force: bool = false;
|
let mut force: bool = false;
|
||||||
let force_str = query.force;
|
let force_str = query.force.clone().unwrap_or_default();
|
||||||
if force_str != "" {
|
if !force_str.is_empty() {
|
||||||
force = force_str.parse().unwrap();
|
force = force_str.parse().map_err(|e| {
|
||||||
|
warn!("parse force failed, e: {:?}", e);
|
||||||
|
s3_error!(InvalidRequest, "parse force failed")
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let tier_name = params.get("tiername").map(|s| s.to_string()).unwrap_or_default();
|
let tier_name = params.get("tiername").map(|s| s.to_string()).unwrap_or_default();
|
||||||
@@ -346,7 +368,7 @@ impl Operation for VerifyTier {
|
|||||||
// .ok_or_else(|| S3Error::with_message(S3ErrorCode::InternalError, "get_global_action_cred failed"))?;
|
// .ok_or_else(|| S3Error::with_message(S3ErrorCode::InternalError, "get_global_action_cred failed"))?;
|
||||||
|
|
||||||
let mut tier_config_mgr = GLOBAL_TierConfigMgr.write().await;
|
let mut tier_config_mgr = GLOBAL_TierConfigMgr.write().await;
|
||||||
tier_config_mgr.verify(&query.tier.unwrap());
|
tier_config_mgr.verify(&query.tier.unwrap()).await;
|
||||||
|
|
||||||
let mut header = HeaderMap::new();
|
let mut header = HeaderMap::new();
|
||||||
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use chrono::Utc;
|
|||||||
use datafusion::arrow::csv::WriterBuilder as CsvWriterBuilder;
|
use datafusion::arrow::csv::WriterBuilder as CsvWriterBuilder;
|
||||||
use datafusion::arrow::json::WriterBuilder as JsonWriterBuilder;
|
use datafusion::arrow::json::WriterBuilder as JsonWriterBuilder;
|
||||||
use datafusion::arrow::json::writer::JsonArray;
|
use datafusion::arrow::json::writer::JsonArray;
|
||||||
use ecstore::bucket::error::BucketMetadataError;
|
|
||||||
use ecstore::bucket::metadata::BUCKET_LIFECYCLE_CONFIG;
|
use ecstore::bucket::metadata::BUCKET_LIFECYCLE_CONFIG;
|
||||||
use ecstore::bucket::metadata::BUCKET_NOTIFICATION_CONFIG;
|
use ecstore::bucket::metadata::BUCKET_NOTIFICATION_CONFIG;
|
||||||
use ecstore::bucket::metadata::BUCKET_POLICY_CONFIG;
|
use ecstore::bucket::metadata::BUCKET_POLICY_CONFIG;
|
||||||
@@ -56,8 +56,7 @@ use ecstore::store_api::PutObjReader;
|
|||||||
use ecstore::store_api::StorageAPI;
|
use ecstore::store_api::StorageAPI;
|
||||||
// use ecstore::store_api::RESERVED_METADATA_PREFIX;
|
// use ecstore::store_api::RESERVED_METADATA_PREFIX;
|
||||||
use ecstore::bucket::lifecycle::bucket_lifecycle_ops::validate_transition_tier;
|
use ecstore::bucket::lifecycle::bucket_lifecycle_ops::validate_transition_tier;
|
||||||
use futures::pin_mut;
|
use futures::StreamExt;
|
||||||
use futures::{Stream, StreamExt};
|
|
||||||
use http::HeaderMap;
|
use http::HeaderMap;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use policy::auth;
|
use policy::auth;
|
||||||
@@ -102,10 +101,7 @@ use tracing::info;
|
|||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use ecstore::bucket::{
|
use ecstore::bucket::lifecycle::lifecycle::Lifecycle;
|
||||||
lifecycle::{bucket_lifecycle_ops::ERR_INVALID_STORAGECLASS, lifecycle::Lifecycle},
|
|
||||||
object_lock::objectlock_sys::BucketObjectLockSys,
|
|
||||||
};
|
|
||||||
|
|
||||||
macro_rules! try_ {
|
macro_rules! try_ {
|
||||||
($result:expr) => {
|
($result:expr) => {
|
||||||
@@ -1733,18 +1729,12 @@ impl S3 for FS {
|
|||||||
|
|
||||||
if let Err(err) = input_cfg.validate(&rcfg).await {
|
if let Err(err) = input_cfg.validate(&rcfg).await {
|
||||||
//return Err(S3Error::with_message(S3ErrorCode::Custom("BucketLockValidateFailed".into()), "bucket lock validate failed."));
|
//return Err(S3Error::with_message(S3ErrorCode::Custom("BucketLockValidateFailed".into()), "bucket lock validate failed."));
|
||||||
return Err(S3Error::with_message(
|
return Err(S3Error::with_message(S3ErrorCode::Custom("ValidateFailed".into()), err.to_string()));
|
||||||
S3ErrorCode::Custom("ValidateFailed".into()),
|
|
||||||
format!("{}", err.to_string()),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = validate_transition_tier(&input_cfg).await {
|
if let Err(err) = validate_transition_tier(&input_cfg).await {
|
||||||
//warn!("lifecycle_configuration add failed, err: {:?}", err);
|
//warn!("lifecycle_configuration add failed, err: {:?}", err);
|
||||||
return Err(S3Error::with_message(
|
return Err(S3Error::with_message(S3ErrorCode::Custom("CustomError".into()), err.to_string()));
|
||||||
S3ErrorCode::Custom("CustomError".into()),
|
|
||||||
format!("{}", err.to_string()),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = try_!(serialize(&input_cfg));
|
let data = try_!(serialize(&input_cfg));
|
||||||
|
|||||||
Reference in New Issue
Block a user