feat(admin): enhance notification event handlers (#530)

* add log

* add logs

* test

* cargo fmt

* add event admin api

* feat: add ImportIam handle

* refact bucket replication

* Update ecstore/src/disk/endpoint.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: weisd <weishidavip@163.com>
Co-authored-by: lygn128 <lygn128@163.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
houseme
2025-07-01 12:34:24 +08:00
committed by GitHub
parent 024f9512be
commit 18a3902d2c
7 changed files with 311 additions and 14 deletions
+24 -7
View File
@@ -2,6 +2,7 @@ use super::error::{Error, Result};
use path_absolutize::Absolutize;
use rustfs_utils::{is_local_host, is_socket_addr};
use std::{fmt::Display, path::Path};
use tracing::debug;
use url::{ParseError, Url};
/// enum for endpoint type.
@@ -75,6 +76,8 @@ impl TryFrom<&str> for Endpoint {
#[cfg(windows)]
let path = Path::new(&path[1..]).absolutize()?;
debug!("endpoint try_from: path={}", path.display());
if path.parent().is_none() || Path::new("").eq(&path) {
return Err(Error::other("empty or root path is not supported in URL endpoint"));
}
@@ -155,26 +158,40 @@ impl Endpoint {
/// returns the host to be used for grid connections.
pub fn grid_host(&self) -> String {
match (self.url.host(), self.url.port()) {
(Some(host), Some(port)) => format!("{}://{}:{}", self.url.scheme(), host, port),
(Some(host), None) => format!("{}://{}", self.url.scheme(), host),
(Some(host), Some(port)) => {
debug!("grid_host scheme={}: host={}, port={}", self.url.scheme(), host, port);
format!("{}://{}:{}", self.url.scheme(), host, port)
}
(Some(host), None) => {
debug!("grid_host scheme={}: host={}", self.url.scheme(), host);
format!("{}://{}", self.url.scheme(), host)
}
_ => String::new(),
}
}
pub fn host_port(&self) -> String {
match (self.url.host(), self.url.port()) {
(Some(host), Some(port)) => format!("{host}:{port}"),
(Some(host), None) => format!("{host}"),
(Some(host), Some(port)) => {
debug!("host_port host={}, port={}", host, port);
format!("{host}:{port}")
}
(Some(host), None) => {
debug!("host_port host={}, port={}", host, self.url.port().unwrap_or(0));
format!("{host}")
}
_ => String::new(),
}
}
pub fn get_file_path(&self) -> &str {
let path = self.url.path();
#[cfg(windows)]
let path = &path[1..];
if self.url.scheme() == "file" {
let stripped = path.strip_prefix('/').unwrap_or(path);
debug!("get_file_path windows: path={}", stripped);
return stripped;
}
path
}
}
+12 -3
View File
@@ -130,7 +130,16 @@ impl Debug for LocalDisk {
impl LocalDisk {
pub async fn new(ep: &Endpoint, cleanup: bool) -> Result<Self> {
let root = fs::canonicalize(ep.get_file_path()).await?;
debug!("Creating local disk");
let root = match fs::canonicalize(ep.get_file_path()).await {
Ok(path) => path,
Err(e) => {
if e.kind() == ErrorKind::NotFound {
return Err(DiskError::VolumeNotFound.into());
}
return Err(to_file_error(e).into());
}
};
if cleanup {
// TODO: 删除 tmp 数据
@@ -140,7 +149,7 @@ impl LocalDisk {
.join(Path::new(super::FORMAT_CONFIG_FILE))
.absolutize_virtually(&root)?
.into_owned();
debug!("format_path: {:?}", format_path);
let (format_data, format_meta) = read_file_exists(&format_path).await?;
let mut id = None;
@@ -245,7 +254,7 @@ impl LocalDisk {
let root = disk.root.clone();
tokio::spawn(Self::cleanup_deleted_objects_loop(root, exit_rx));
debug!("LocalDisk created: {:?}", disk);
Ok(disk)
}