Skip to content

Commit 5869cba

Browse files
committed
Merge remote-tracking branch 'upstream/main' into feat/pr-1820-refresh
2 parents 068e471 + e33c153 commit 5869cba

9 files changed

Lines changed: 910 additions & 171 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dragonfly-client-config/src/dfdaemon.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ pub fn default_dfdaemon_config_path() -> PathBuf {
5151
crate::default_config_dir().join("dfdaemon.yaml")
5252
}
5353

54+
/// Returns the default dynconfig path for dfdaemon, which is used when the
55+
/// manager is not configured.
56+
#[inline]
57+
pub fn default_dfdaemon_dynconfig_path() -> PathBuf {
58+
crate::default_config_dir().join("dynconfig.yaml")
59+
}
60+
5461
/// Returns the default log directory for dfdaemon.
5562
#[inline]
5663
pub fn default_dfdaemon_log_dir() -> PathBuf {
@@ -240,6 +247,18 @@ fn default_dynconfig_refresh_interval() -> Duration {
240247
Duration::from_secs(300)
241248
}
242249

250+
/// Returns the default interval to refresh the local dynamic configuration.
251+
#[inline]
252+
pub fn default_local_dynconfig_refresh_interval() -> Duration {
253+
Duration::from_secs(60)
254+
}
255+
256+
/// Returns the default scheduler address for the local dynamic configuration.
257+
#[inline]
258+
pub fn default_local_dynconfig_scheduler_addr() -> String {
259+
"dragonfly-scheduler:8002".to_string()
260+
}
261+
243262
/// Returns the default port of the storage tcp server.
244263
#[inline]
245264
fn default_storage_server_tcp_port() -> u16 {
@@ -1621,9 +1640,11 @@ pub struct Config {
16211640
#[validate]
16221641
pub upload: Upload,
16231642

1624-
/// The manager configuration for dfdaemon.
1643+
/// The manager configuration for dfdaemon. If not configured, the dynamic
1644+
/// configuration is loaded from the local dynconfig file instead of being
1645+
/// fetched from the manager.
16251646
#[validate]
1626-
pub manager: Manager,
1647+
pub manager: Option<Manager>,
16271648

16281649
/// The scheduler configuration for dfdaemon.
16291650
#[validate]

dragonfly-client-config/src/dfinit.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,13 @@ pub struct ContainerdRegistry {
123123

124124
/// The flag to skip verifying the server's certificate, refer to
125125
/// https://github.com/containerd/containerd/blob/main/docs/hosts.md#bypass-tls-verification-example.
126+
#[serde(skip_serializing_if = "Option::is_none")]
126127
pub skip_verify: Option<bool>,
127128

128129
/// The Certificate Authority Certification, which can be set to a path or an array of paths each pointing
129130
/// to a ca file for use in authenticating with the registry namespace, refer to
130131
/// https://github.com/containerd/containerd/blob/main/docs/hosts.md#ca-field.
132+
#[serde(skip_serializing_if = "Option::is_none")]
131133
pub ca: Option<Vec<String>>,
132134
}
133135

dragonfly-client/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ anyhow.workspace = true
6666
bytes.workspace = true
6767
bytesize.workspace = true
6868
humantime.workspace = true
69+
humantime-serde.workspace = true
6970
uuid.workspace = true
7071
percent-encoding.workspace = true
7172
tokio-rustls.workspace = true
7273
serde_json.workspace = true
74+
serde_yaml.workspace = true
7375
fs2.workspace = true
7476
lazy_static.workspace = true
7577
futures.workspace = true

dragonfly-client/src/bin/dfdaemon/main.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use dragonfly_client::dynconfig::Dynconfig;
2222
use dragonfly_client::gc::GC;
2323
use dragonfly_client::grpc::{
2424
dfdaemon_download::DfdaemonDownloadServer, dfdaemon_upload::DfdaemonUploadServer,
25-
manager::ManagerClient, scheduler::SchedulerClient,
25+
scheduler::SchedulerClient,
2626
};
2727
use dragonfly_client::health::Health;
2828
use dragonfly_client::proxy::Proxy;
@@ -84,6 +84,14 @@ struct Args {
8484
]
8585
config: PathBuf,
8686

87+
#[arg(
88+
long = "dynconfig",
89+
default_value_os_t = dfdaemon::default_dfdaemon_dynconfig_path(),
90+
env = "DFDAEMON_DYNCONFIG",
91+
help = "Specify the dynconfig file to use when the manager address is not configured"
92+
)]
93+
dynconfig: PathBuf,
94+
8795
#[arg(
8896
short = 'l',
8997
long,
@@ -202,22 +210,14 @@ async fn main() -> Result<(), anyhow::Error> {
202210
);
203211
let id_generator = Arc::new(id_generator);
204212

205-
// Initialize manager client.
206-
let manager_client = ManagerClient::new(config.clone(), config.manager.addr.clone())
207-
.await
208-
.inspect_err(|err| {
209-
error!("initialize manager client failed: {}", err);
210-
})?;
211-
let manager_client = Arc::new(manager_client);
212-
213213
// Initialize channel for graceful shutdown.
214214
let shutdown = shutdown::Shutdown::default();
215215
let (shutdown_complete_tx, mut shutdown_complete_rx) = mpsc::unbounded_channel();
216216

217217
// Initialize dynconfig server.
218218
let dynconfig = Dynconfig::new(
219219
config.clone(),
220-
manager_client.clone(),
220+
args.dynconfig,
221221
shutdown.clone(),
222222
shutdown_complete_tx.clone(),
223223
)

0 commit comments

Comments
 (0)