Line data Source code
1 : //! This module is responsible for locating and loading paths in a local setup.
2 : //!
3 : //! Now it also provides init method which acts like a stub for proper installation
4 : //! script which will use local paths.
5 :
6 : use std::collections::HashMap;
7 : use std::net::SocketAddr;
8 : use std::path::{Path, PathBuf};
9 : use std::process::{Command, Stdio};
10 : use std::time::Duration;
11 : use std::{env, fs};
12 :
13 : use anyhow::{Context, bail};
14 : use clap::ValueEnum;
15 : use pageserver_api::config::PostHogConfig;
16 : use pem::Pem;
17 : use postgres_backend::AuthType;
18 : use reqwest::{Certificate, Url};
19 : use safekeeper_api::PgMajorVersion;
20 : use serde::{Deserialize, Serialize};
21 : use utils::auth::encode_from_key_file;
22 : use utils::id::{NodeId, TenantId, TenantTimelineId, TimelineId};
23 :
24 : use crate::broker::StorageBroker;
25 : use crate::endpoint_storage::{
26 : ENDPOINT_STORAGE_DEFAULT_ADDR, ENDPOINT_STORAGE_REMOTE_STORAGE_DIR, EndpointStorage,
27 : };
28 : use crate::pageserver::{PAGESERVER_REMOTE_STORAGE_DIR, PageServerNode};
29 : use crate::safekeeper::SafekeeperNode;
30 :
31 : pub const DEFAULT_PG_VERSION: u32 = 17;
32 :
33 : //
34 : // This data structures represents neon_local CLI config
35 : //
36 : // It is deserialized from the .neon/config file, or the config file passed
37 : // to 'neon_local init --config=<path>' option. See control_plane/simple.conf for
38 : // an example.
39 : //
40 : #[derive(PartialEq, Eq, Clone, Debug)]
41 : pub struct LocalEnv {
42 : // Base directory for all the nodes (the pageserver, safekeepers and
43 : // compute endpoints).
44 : //
45 : // This is not stored in the config file. Rather, this is the path where the
46 : // config file itself is. It is read from the NEON_REPO_DIR env variable which
47 : // must be an absolute path. If the env var is not set, $PWD/.neon is used.
48 : pub base_data_dir: PathBuf,
49 :
50 : // Path to postgres distribution. It's expected that "bin", "include",
51 : // "lib", "share" from postgres distribution are there. If at some point
52 : // in time we will be able to run against vanilla postgres we may split that
53 : // to four separate paths and match OS-specific installation layout.
54 : pub pg_distrib_dir: PathBuf,
55 :
56 : // Path to pageserver binary.
57 : pub neon_distrib_dir: PathBuf,
58 :
59 : // Default tenant ID to use with the 'neon_local' command line utility, when
60 : // --tenant_id is not explicitly specified.
61 : pub default_tenant_id: Option<TenantId>,
62 :
63 : // used to issue tokens during e.g pg start
64 : pub private_key_path: PathBuf,
65 : /// Path to environment's public key
66 : pub public_key_path: PathBuf,
67 :
68 : pub broker: NeonBroker,
69 :
70 : // Configuration for the storage controller (1 per neon_local environment)
71 : pub storage_controller: NeonStorageControllerConf,
72 :
73 : /// This Vec must always contain at least one pageserver
74 : /// Populdated by [`Self::load_config`] from the individual `pageserver.toml`s.
75 : /// NB: not used anymore except for informing users that they need to change their `.neon/config`.
76 : pub pageservers: Vec<PageServerConf>,
77 :
78 : pub safekeepers: Vec<SafekeeperConf>,
79 :
80 : pub endpoint_storage: EndpointStorageConf,
81 :
82 : // Control plane upcall API for pageserver: if None, we will not run storage_controller If set, this will
83 : // be propagated into each pageserver's configuration.
84 : pub control_plane_api: Url,
85 :
86 : // Control plane upcall APIs for storage controller. If set, this will be propagated into the
87 : // storage controller's configuration.
88 : pub control_plane_hooks_api: Option<Url>,
89 :
90 : /// Keep human-readable aliases in memory (and persist them to config), to hide ZId hex strings from the user.
91 : // A `HashMap<String, HashMap<TenantId, TimelineId>>` would be more appropriate here,
92 : // but deserialization into a generic toml object as `toml::Value::try_from` fails with an error.
93 : // https://toml.io/en/v1.0.0 does not contain a concept of "a table inside another table".
94 : pub branch_name_mappings: HashMap<String, Vec<(TenantId, TimelineId)>>,
95 :
96 : /// Flag to generate SSL certificates for components that need it.
97 : /// Also generates root CA certificate that is used to sign all other certificates.
98 : pub generate_local_ssl_certs: bool,
99 : }
100 :
101 : /// On-disk state stored in `.neon/config`.
102 : #[derive(PartialEq, Eq, Clone, Debug, Default, Serialize, Deserialize)]
103 : #[serde(default, deny_unknown_fields)]
104 : pub struct OnDiskConfig {
105 : pub pg_distrib_dir: PathBuf,
106 : pub neon_distrib_dir: PathBuf,
107 : pub default_tenant_id: Option<TenantId>,
108 : pub private_key_path: PathBuf,
109 : pub public_key_path: PathBuf,
110 : pub broker: NeonBroker,
111 : pub storage_controller: NeonStorageControllerConf,
112 : #[serde(
113 : skip_serializing,
114 : deserialize_with = "fail_if_pageservers_field_specified"
115 : )]
116 : pub pageservers: Vec<PageServerConf>,
117 : pub safekeepers: Vec<SafekeeperConf>,
118 : pub endpoint_storage: EndpointStorageConf,
119 : pub control_plane_api: Option<Url>,
120 : pub control_plane_hooks_api: Option<Url>,
121 : pub control_plane_compute_hook_api: Option<Url>,
122 : branch_name_mappings: HashMap<String, Vec<(TenantId, TimelineId)>>,
123 : // Note: skip serializing because in compat tests old storage controller fails
124 : // to load new config file. May be removed after this field is in release branch.
125 : #[serde(skip_serializing_if = "std::ops::Not::not")]
126 : pub generate_local_ssl_certs: bool,
127 : }
128 :
129 0 : fn fail_if_pageservers_field_specified<'de, D>(_: D) -> Result<Vec<PageServerConf>, D::Error>
130 0 : where
131 0 : D: serde::Deserializer<'de>,
132 : {
133 0 : Err(serde::de::Error::custom(
134 0 : "The 'pageservers' field is no longer used; pageserver.toml is now authoritative; \
135 0 : Please remove the `pageservers` from your .neon/config.",
136 0 : ))
137 0 : }
138 :
139 : /// The description of the neon_local env to be initialized by `neon_local init --config`.
140 0 : #[derive(Clone, Debug, Deserialize)]
141 : #[serde(deny_unknown_fields)]
142 : pub struct NeonLocalInitConf {
143 : // TODO: do we need this? Seems unused
144 : pub pg_distrib_dir: Option<PathBuf>,
145 : // TODO: do we need this? Seems unused
146 : pub neon_distrib_dir: Option<PathBuf>,
147 : pub default_tenant_id: TenantId,
148 : pub broker: NeonBroker,
149 : pub storage_controller: Option<NeonStorageControllerConf>,
150 : pub pageservers: Vec<NeonLocalInitPageserverConf>,
151 : pub safekeepers: Vec<SafekeeperConf>,
152 : pub endpoint_storage: EndpointStorageConf,
153 : pub control_plane_api: Option<Url>,
154 : pub control_plane_hooks_api: Option<Url>,
155 : pub generate_local_ssl_certs: bool,
156 : }
157 :
158 0 : #[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug)]
159 : #[serde(default)]
160 : pub struct EndpointStorageConf {
161 : pub listen_addr: SocketAddr,
162 : }
163 :
164 : /// Broker config for cluster internal communication.
165 0 : #[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, Default)]
166 : #[serde(default)]
167 : pub struct NeonBroker {
168 : /// Broker listen HTTP address for storage nodes coordination, e.g. '127.0.0.1:50051'.
169 : /// At least one of listen_addr or listen_https_addr must be set.
170 : pub listen_addr: Option<SocketAddr>,
171 : /// Broker listen HTTPS address for storage nodes coordination, e.g. '127.0.0.1:50051'.
172 : /// At least one of listen_addr or listen_https_addr must be set.
173 : /// listen_https_addr is preferred over listen_addr in neon_local.
174 : pub listen_https_addr: Option<SocketAddr>,
175 : }
176 :
177 : /// A part of storage controller's config the neon_local knows about.
178 : #[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug)]
179 : #[serde(default)]
180 : pub struct NeonStorageControllerConf {
181 : /// Heartbeat timeout before marking a node offline
182 : #[serde(with = "humantime_serde")]
183 : pub max_offline: Duration,
184 :
185 : #[serde(with = "humantime_serde")]
186 : pub max_warming_up: Duration,
187 :
188 : pub start_as_candidate: bool,
189 :
190 : /// Database url used when running multiple storage controller instances
191 : pub database_url: Option<SocketAddr>,
192 :
193 : /// Thresholds for auto-splitting a tenant into shards.
194 : pub split_threshold: Option<u64>,
195 : pub max_split_shards: Option<u8>,
196 : pub initial_split_threshold: Option<u64>,
197 : pub initial_split_shards: Option<u8>,
198 :
199 : pub max_secondary_lag_bytes: Option<u64>,
200 :
201 : #[serde(with = "humantime_serde")]
202 : pub heartbeat_interval: Duration,
203 :
204 : #[serde(with = "humantime_serde")]
205 : pub long_reconcile_threshold: Option<Duration>,
206 :
207 : pub use_https_pageserver_api: bool,
208 :
209 : pub timelines_onto_safekeepers: bool,
210 :
211 : pub use_https_safekeeper_api: bool,
212 :
213 : pub use_local_compute_notifications: bool,
214 :
215 : pub timeline_safekeeper_count: Option<usize>,
216 :
217 : pub posthog_config: Option<PostHogConfig>,
218 :
219 : pub kick_secondary_downloads: Option<bool>,
220 :
221 : #[serde(with = "humantime_serde")]
222 : pub shard_split_request_timeout: Option<Duration>,
223 : }
224 :
225 : impl NeonStorageControllerConf {
226 : // Use a shorter pageserver unavailability interval than the default to speed up tests.
227 : const DEFAULT_MAX_OFFLINE_INTERVAL: std::time::Duration = std::time::Duration::from_secs(10);
228 :
229 : const DEFAULT_MAX_WARMING_UP_INTERVAL: std::time::Duration = std::time::Duration::from_secs(30);
230 :
231 : // Very tight heartbeat interval to speed up tests
232 : const DEFAULT_HEARTBEAT_INTERVAL: std::time::Duration = std::time::Duration::from_millis(1000);
233 : }
234 :
235 : impl Default for NeonStorageControllerConf {
236 0 : fn default() -> Self {
237 0 : Self {
238 0 : max_offline: Self::DEFAULT_MAX_OFFLINE_INTERVAL,
239 0 : max_warming_up: Self::DEFAULT_MAX_WARMING_UP_INTERVAL,
240 0 : start_as_candidate: false,
241 0 : database_url: None,
242 0 : split_threshold: None,
243 0 : max_split_shards: None,
244 0 : initial_split_threshold: None,
245 0 : initial_split_shards: None,
246 0 : max_secondary_lag_bytes: None,
247 0 : heartbeat_interval: Self::DEFAULT_HEARTBEAT_INTERVAL,
248 0 : long_reconcile_threshold: None,
249 0 : use_https_pageserver_api: false,
250 0 : timelines_onto_safekeepers: true,
251 0 : use_https_safekeeper_api: false,
252 0 : use_local_compute_notifications: true,
253 0 : timeline_safekeeper_count: None,
254 0 : posthog_config: None,
255 0 : kick_secondary_downloads: None,
256 0 : shard_split_request_timeout: None,
257 0 : }
258 0 : }
259 : }
260 :
261 : impl Default for EndpointStorageConf {
262 0 : fn default() -> Self {
263 0 : Self {
264 0 : listen_addr: ENDPOINT_STORAGE_DEFAULT_ADDR,
265 0 : }
266 0 : }
267 : }
268 :
269 : impl NeonBroker {
270 0 : pub fn client_url(&self) -> Url {
271 0 : let url = if let Some(addr) = self.listen_https_addr {
272 0 : format!("https://{addr}")
273 : } else {
274 0 : format!(
275 0 : "http://{}",
276 0 : self.listen_addr
277 0 : .expect("at least one address should be set")
278 : )
279 : };
280 :
281 0 : Url::parse(&url).expect("failed to construct url")
282 0 : }
283 : }
284 :
285 : // neon_local needs to know this subset of pageserver configuration.
286 : // For legacy reasons, this information is duplicated from `pageserver.toml` into `.neon/config`.
287 : // It can get stale if `pageserver.toml` is changed.
288 : // TODO(christian): don't store this at all in `.neon/config`, always load it from `pageserver.toml`
289 0 : #[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug)]
290 : #[serde(default, deny_unknown_fields)]
291 : pub struct PageServerConf {
292 : pub id: NodeId,
293 : pub listen_pg_addr: String,
294 : pub listen_http_addr: String,
295 : pub listen_https_addr: Option<String>,
296 : pub listen_grpc_addr: Option<String>,
297 : pub pg_auth_type: AuthType,
298 : pub http_auth_type: AuthType,
299 : pub grpc_auth_type: AuthType,
300 : pub no_sync: bool,
301 : }
302 :
303 : impl Default for PageServerConf {
304 0 : fn default() -> Self {
305 0 : Self {
306 0 : id: NodeId(0),
307 0 : listen_pg_addr: String::new(),
308 0 : listen_http_addr: String::new(),
309 0 : listen_https_addr: None,
310 0 : listen_grpc_addr: None,
311 0 : pg_auth_type: AuthType::Trust,
312 0 : http_auth_type: AuthType::Trust,
313 0 : grpc_auth_type: AuthType::Trust,
314 0 : no_sync: false,
315 0 : }
316 0 : }
317 : }
318 :
319 : /// The toml that can be passed to `neon_local init --config`.
320 : /// This is a subset of the `pageserver.toml` configuration.
321 : // TODO(christian): use pageserver_api::config::ConfigToml (PR #7656)
322 0 : #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
323 : pub struct NeonLocalInitPageserverConf {
324 : pub id: NodeId,
325 : pub listen_pg_addr: String,
326 : pub listen_http_addr: String,
327 : pub listen_https_addr: Option<String>,
328 : pub listen_grpc_addr: Option<String>,
329 : pub pg_auth_type: AuthType,
330 : pub http_auth_type: AuthType,
331 : pub grpc_auth_type: AuthType,
332 : #[serde(default, skip_serializing_if = "std::ops::Not::not")]
333 : pub no_sync: bool,
334 : #[serde(flatten)]
335 : pub other: HashMap<String, toml::Value>,
336 : }
337 :
338 : impl From<&NeonLocalInitPageserverConf> for PageServerConf {
339 0 : fn from(conf: &NeonLocalInitPageserverConf) -> Self {
340 : let NeonLocalInitPageserverConf {
341 0 : id,
342 0 : listen_pg_addr,
343 0 : listen_http_addr,
344 0 : listen_https_addr,
345 0 : listen_grpc_addr,
346 0 : pg_auth_type,
347 0 : http_auth_type,
348 0 : grpc_auth_type,
349 0 : no_sync,
350 : other: _,
351 0 : } = conf;
352 0 : Self {
353 0 : id: *id,
354 0 : listen_pg_addr: listen_pg_addr.clone(),
355 0 : listen_http_addr: listen_http_addr.clone(),
356 0 : listen_https_addr: listen_https_addr.clone(),
357 0 : listen_grpc_addr: listen_grpc_addr.clone(),
358 0 : pg_auth_type: *pg_auth_type,
359 0 : grpc_auth_type: *grpc_auth_type,
360 0 : http_auth_type: *http_auth_type,
361 0 : no_sync: *no_sync,
362 0 : }
363 0 : }
364 : }
365 :
366 0 : #[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug)]
367 : #[serde(default)]
368 : pub struct SafekeeperConf {
369 : pub id: NodeId,
370 : pub pg_port: u16,
371 : pub pg_tenant_only_port: Option<u16>,
372 : pub http_port: u16,
373 : pub https_port: Option<u16>,
374 : pub sync: bool,
375 : pub remote_storage: Option<String>,
376 : pub backup_threads: Option<u32>,
377 : pub auth_enabled: bool,
378 : pub listen_addr: Option<String>,
379 : }
380 :
381 : impl Default for SafekeeperConf {
382 0 : fn default() -> Self {
383 0 : Self {
384 0 : id: NodeId(0),
385 0 : pg_port: 0,
386 0 : pg_tenant_only_port: None,
387 0 : http_port: 0,
388 0 : https_port: None,
389 0 : sync: true,
390 0 : remote_storage: None,
391 0 : backup_threads: None,
392 0 : auth_enabled: false,
393 0 : listen_addr: None,
394 0 : }
395 0 : }
396 : }
397 :
398 : #[derive(Clone, Copy)]
399 : pub enum InitForceMode {
400 : MustNotExist,
401 : EmptyDirOk,
402 : RemoveAllContents,
403 : }
404 :
405 : impl ValueEnum for InitForceMode {
406 0 : fn value_variants<'a>() -> &'a [Self] {
407 0 : &[
408 0 : Self::MustNotExist,
409 0 : Self::EmptyDirOk,
410 0 : Self::RemoveAllContents,
411 0 : ]
412 0 : }
413 :
414 0 : fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
415 0 : Some(clap::builder::PossibleValue::new(match self {
416 0 : InitForceMode::MustNotExist => "must-not-exist",
417 0 : InitForceMode::EmptyDirOk => "empty-dir-ok",
418 0 : InitForceMode::RemoveAllContents => "remove-all-contents",
419 : }))
420 0 : }
421 : }
422 :
423 : impl SafekeeperConf {
424 : /// Compute is served by port on which only tenant scoped tokens allowed, if
425 : /// it is configured.
426 0 : pub fn get_compute_port(&self) -> u16 {
427 0 : self.pg_tenant_only_port.unwrap_or(self.pg_port)
428 0 : }
429 : }
430 :
431 : impl LocalEnv {
432 0 : pub fn pg_distrib_dir_raw(&self) -> PathBuf {
433 0 : self.pg_distrib_dir.clone()
434 0 : }
435 :
436 0 : pub fn pg_distrib_dir(&self, pg_version: PgMajorVersion) -> anyhow::Result<PathBuf> {
437 0 : let path = self.pg_distrib_dir.clone();
438 :
439 0 : Ok(path.join(pg_version.v_str()))
440 0 : }
441 :
442 0 : pub fn pg_dir(&self, pg_version: PgMajorVersion, dir_name: &str) -> anyhow::Result<PathBuf> {
443 0 : Ok(self.pg_distrib_dir(pg_version)?.join(dir_name))
444 0 : }
445 :
446 0 : pub fn pg_bin_dir(&self, pg_version: PgMajorVersion) -> anyhow::Result<PathBuf> {
447 0 : self.pg_dir(pg_version, "bin")
448 0 : }
449 :
450 0 : pub fn pg_lib_dir(&self, pg_version: PgMajorVersion) -> anyhow::Result<PathBuf> {
451 0 : self.pg_dir(pg_version, "lib")
452 0 : }
453 :
454 0 : pub fn endpoint_storage_bin(&self) -> PathBuf {
455 0 : self.neon_distrib_dir.join("endpoint_storage")
456 0 : }
457 :
458 0 : pub fn pageserver_bin(&self) -> PathBuf {
459 0 : self.neon_distrib_dir.join("pageserver")
460 0 : }
461 :
462 0 : pub fn storage_controller_bin(&self) -> PathBuf {
463 : // Irrespective of configuration, storage controller binary is always
464 : // run from the same location as neon_local. This means that for compatibility
465 : // tests that run old pageserver/safekeeper, they still run latest storage controller.
466 0 : let neon_local_bin_dir = env::current_exe().unwrap().parent().unwrap().to_owned();
467 0 : neon_local_bin_dir.join("storage_controller")
468 0 : }
469 :
470 0 : pub fn safekeeper_bin(&self) -> PathBuf {
471 0 : self.neon_distrib_dir.join("safekeeper")
472 0 : }
473 :
474 0 : pub fn storage_broker_bin(&self) -> PathBuf {
475 0 : self.neon_distrib_dir.join("storage_broker")
476 0 : }
477 :
478 0 : pub fn endpoints_path(&self) -> PathBuf {
479 0 : self.base_data_dir.join("endpoints")
480 0 : }
481 :
482 0 : pub fn storage_broker_data_dir(&self) -> PathBuf {
483 0 : self.base_data_dir.join("storage_broker")
484 0 : }
485 :
486 0 : pub fn pageserver_data_dir(&self, pageserver_id: NodeId) -> PathBuf {
487 0 : self.base_data_dir
488 0 : .join(format!("pageserver_{pageserver_id}"))
489 0 : }
490 :
491 0 : pub fn safekeeper_data_dir(&self, data_dir_name: &str) -> PathBuf {
492 0 : self.base_data_dir.join("safekeepers").join(data_dir_name)
493 0 : }
494 :
495 0 : pub fn endpoint_storage_data_dir(&self) -> PathBuf {
496 0 : self.base_data_dir.join("endpoint_storage")
497 0 : }
498 :
499 0 : pub fn get_pageserver_conf(&self, id: NodeId) -> anyhow::Result<&PageServerConf> {
500 0 : if let Some(conf) = self.pageservers.iter().find(|node| node.id == id) {
501 0 : Ok(conf)
502 : } else {
503 0 : let have_ids = self
504 0 : .pageservers
505 0 : .iter()
506 0 : .map(|node| format!("{}:{}", node.id, node.listen_http_addr))
507 0 : .collect::<Vec<_>>();
508 0 : let joined = have_ids.join(",");
509 0 : bail!("could not find pageserver {id}, have ids {joined}")
510 : }
511 0 : }
512 :
513 0 : pub fn ssl_ca_cert_path(&self) -> Option<PathBuf> {
514 0 : if self.generate_local_ssl_certs {
515 0 : Some(self.base_data_dir.join("rootCA.crt"))
516 : } else {
517 0 : None
518 : }
519 0 : }
520 :
521 0 : pub fn ssl_ca_key_path(&self) -> Option<PathBuf> {
522 0 : if self.generate_local_ssl_certs {
523 0 : Some(self.base_data_dir.join("rootCA.key"))
524 : } else {
525 0 : None
526 : }
527 0 : }
528 :
529 0 : pub fn generate_ssl_ca_cert(&self) -> anyhow::Result<()> {
530 0 : let cert_path = self.ssl_ca_cert_path().unwrap();
531 0 : let key_path = self.ssl_ca_key_path().unwrap();
532 0 : if !fs::exists(cert_path.as_path())? {
533 0 : generate_ssl_ca_cert(cert_path.as_path(), key_path.as_path())?;
534 0 : }
535 0 : Ok(())
536 0 : }
537 :
538 0 : pub fn generate_ssl_cert(&self, cert_path: &Path, key_path: &Path) -> anyhow::Result<()> {
539 0 : self.generate_ssl_ca_cert()?;
540 0 : generate_ssl_cert(
541 0 : cert_path,
542 0 : key_path,
543 0 : self.ssl_ca_cert_path().unwrap().as_path(),
544 0 : self.ssl_ca_key_path().unwrap().as_path(),
545 : )
546 0 : }
547 :
548 : /// Creates HTTP client with local SSL CA certificates.
549 0 : pub fn create_http_client(&self) -> reqwest::Client {
550 0 : let ssl_ca_certs = self.ssl_ca_cert_path().map(|ssl_ca_file| {
551 0 : let buf = std::fs::read(ssl_ca_file).expect("SSL CA file should exist");
552 0 : Certificate::from_pem_bundle(&buf).expect("SSL CA file should be valid")
553 0 : });
554 :
555 0 : let mut http_client = reqwest::Client::builder();
556 0 : for ssl_ca_cert in ssl_ca_certs.unwrap_or_default() {
557 0 : http_client = http_client.add_root_certificate(ssl_ca_cert);
558 0 : }
559 :
560 0 : http_client
561 0 : .build()
562 0 : .expect("HTTP client should construct with no error")
563 0 : }
564 :
565 : /// Inspect the base data directory and extract the instance id and instance directory path
566 : /// for all storage controller instances
567 0 : pub async fn storage_controller_instances(&self) -> std::io::Result<Vec<(u8, PathBuf)>> {
568 0 : let mut instances = Vec::default();
569 :
570 0 : let dir = std::fs::read_dir(self.base_data_dir.clone())?;
571 0 : for dentry in dir {
572 0 : let dentry = dentry?;
573 0 : let is_dir = dentry.metadata()?.is_dir();
574 0 : let filename = dentry.file_name().into_string().unwrap();
575 0 : let parsed_instance_id = match filename.strip_prefix("storage_controller_") {
576 0 : Some(suffix) => suffix.parse::<u8>().ok(),
577 0 : None => None,
578 : };
579 :
580 0 : let is_instance_dir = is_dir && parsed_instance_id.is_some();
581 :
582 0 : if !is_instance_dir {
583 0 : continue;
584 0 : }
585 :
586 0 : instances.push((
587 0 : parsed_instance_id.expect("Checked previously"),
588 0 : dentry.path(),
589 0 : ));
590 : }
591 :
592 0 : Ok(instances)
593 0 : }
594 :
595 0 : pub fn register_branch_mapping(
596 0 : &mut self,
597 0 : branch_name: String,
598 0 : tenant_id: TenantId,
599 0 : timeline_id: TimelineId,
600 0 : ) -> anyhow::Result<()> {
601 0 : let existing_values = self
602 0 : .branch_name_mappings
603 0 : .entry(branch_name.clone())
604 0 : .or_default();
605 :
606 0 : let existing_ids = existing_values
607 0 : .iter()
608 0 : .find(|(existing_tenant_id, _)| existing_tenant_id == &tenant_id);
609 :
610 0 : if let Some((_, old_timeline_id)) = existing_ids {
611 0 : if old_timeline_id == &timeline_id {
612 0 : Ok(())
613 : } else {
614 0 : bail!(
615 0 : "branch '{branch_name}' is already mapped to timeline {old_timeline_id}, cannot map to another timeline {timeline_id}"
616 : );
617 : }
618 : } else {
619 0 : existing_values.push((tenant_id, timeline_id));
620 0 : Ok(())
621 : }
622 0 : }
623 :
624 0 : pub fn get_branch_timeline_id(
625 0 : &self,
626 0 : branch_name: &str,
627 0 : tenant_id: TenantId,
628 0 : ) -> Option<TimelineId> {
629 0 : self.branch_name_mappings
630 0 : .get(branch_name)?
631 0 : .iter()
632 0 : .find(|(mapped_tenant_id, _)| mapped_tenant_id == &tenant_id)
633 0 : .map(|&(_, timeline_id)| timeline_id)
634 0 : }
635 :
636 0 : pub fn timeline_name_mappings(&self) -> HashMap<TenantTimelineId, String> {
637 0 : self.branch_name_mappings
638 0 : .iter()
639 0 : .flat_map(|(name, tenant_timelines)| {
640 0 : tenant_timelines.iter().map(|&(tenant_id, timeline_id)| {
641 0 : (TenantTimelineId::new(tenant_id, timeline_id), name.clone())
642 0 : })
643 0 : })
644 0 : .collect()
645 0 : }
646 :
647 : /// Construct `Self` from on-disk state.
648 0 : pub fn load_config(repopath: &Path) -> anyhow::Result<Self> {
649 0 : if !repopath.exists() {
650 0 : bail!(
651 0 : "Neon config is not found in {}. You need to run 'neon_local init' first",
652 0 : repopath.to_str().unwrap()
653 : );
654 0 : }
655 :
656 : // TODO: check that it looks like a neon repository
657 :
658 : // load and parse file
659 0 : let config_file_contents = fs::read_to_string(repopath.join("config"))?;
660 0 : let on_disk_config: OnDiskConfig = toml::from_str(config_file_contents.as_str())?;
661 0 : let mut env = {
662 : let OnDiskConfig {
663 0 : pg_distrib_dir,
664 0 : neon_distrib_dir,
665 0 : default_tenant_id,
666 0 : private_key_path,
667 0 : public_key_path,
668 0 : broker,
669 0 : storage_controller,
670 0 : pageservers,
671 0 : safekeepers,
672 0 : control_plane_api,
673 0 : control_plane_hooks_api,
674 : control_plane_compute_hook_api: _,
675 0 : branch_name_mappings,
676 0 : generate_local_ssl_certs,
677 0 : endpoint_storage,
678 0 : } = on_disk_config;
679 0 : LocalEnv {
680 0 : base_data_dir: repopath.to_owned(),
681 0 : pg_distrib_dir,
682 0 : neon_distrib_dir,
683 0 : default_tenant_id,
684 0 : private_key_path,
685 0 : public_key_path,
686 0 : broker,
687 0 : storage_controller,
688 0 : pageservers,
689 0 : safekeepers,
690 0 : control_plane_api: control_plane_api.unwrap(),
691 0 : control_plane_hooks_api,
692 0 : branch_name_mappings,
693 0 : generate_local_ssl_certs,
694 0 : endpoint_storage,
695 0 : }
696 : };
697 :
698 : // The source of truth for pageserver configuration is the pageserver.toml.
699 0 : assert!(
700 0 : env.pageservers.is_empty(),
701 0 : "we ensure this during deserialization"
702 : );
703 0 : env.pageservers = {
704 0 : let iter = std::fs::read_dir(repopath).context("open dir")?;
705 0 : let mut pageservers = Vec::new();
706 0 : for res in iter {
707 0 : let dentry = res?;
708 : const PREFIX: &str = "pageserver_";
709 0 : let dentry_name = dentry
710 0 : .file_name()
711 0 : .into_string()
712 0 : .ok()
713 0 : .with_context(|| format!("non-utf8 dentry: {:?}", dentry.path()))
714 0 : .unwrap();
715 0 : if !dentry_name.starts_with(PREFIX) {
716 0 : continue;
717 0 : }
718 0 : if !dentry.file_type().context("determine file type")?.is_dir() {
719 0 : anyhow::bail!("expected a directory, got {:?}", dentry.path());
720 0 : }
721 0 : let id = dentry_name[PREFIX.len()..]
722 0 : .parse::<NodeId>()
723 0 : .with_context(|| format!("parse id from {:?}", dentry.path()))?;
724 : // TODO(christian): use pageserver_api::config::ConfigToml (PR #7656)
725 0 : #[derive(serde::Serialize, serde::Deserialize)]
726 : // (allow unknown fields, unlike PageServerConf)
727 : struct PageserverConfigTomlSubset {
728 : listen_pg_addr: String,
729 : listen_http_addr: String,
730 : listen_https_addr: Option<String>,
731 : listen_grpc_addr: Option<String>,
732 : pg_auth_type: AuthType,
733 : http_auth_type: AuthType,
734 : grpc_auth_type: AuthType,
735 : #[serde(default)]
736 : no_sync: bool,
737 : }
738 0 : let config_toml_path = dentry.path().join("pageserver.toml");
739 0 : let config_toml: PageserverConfigTomlSubset = toml_edit::de::from_str(
740 0 : &std::fs::read_to_string(&config_toml_path)
741 0 : .with_context(|| format!("read {config_toml_path:?}"))?,
742 : )
743 0 : .context("parse pageserver.toml")?;
744 0 : let identity_toml_path = dentry.path().join("identity.toml");
745 0 : #[derive(serde::Serialize, serde::Deserialize)]
746 : struct IdentityTomlSubset {
747 : id: NodeId,
748 : }
749 0 : let identity_toml: IdentityTomlSubset = toml_edit::de::from_str(
750 0 : &std::fs::read_to_string(&identity_toml_path)
751 0 : .with_context(|| format!("read {identity_toml_path:?}"))?,
752 : )
753 0 : .context("parse identity.toml")?;
754 : let PageserverConfigTomlSubset {
755 0 : listen_pg_addr,
756 0 : listen_http_addr,
757 0 : listen_https_addr,
758 0 : listen_grpc_addr,
759 0 : pg_auth_type,
760 0 : http_auth_type,
761 0 : grpc_auth_type,
762 0 : no_sync,
763 0 : } = config_toml;
764 : let IdentityTomlSubset {
765 0 : id: identity_toml_id,
766 0 : } = identity_toml;
767 0 : let conf = PageServerConf {
768 : id: {
769 0 : anyhow::ensure!(
770 0 : identity_toml_id == id,
771 0 : "id mismatch: identity.toml:id={identity_toml_id} pageserver_(.*) id={id}",
772 : );
773 0 : id
774 : },
775 0 : listen_pg_addr,
776 0 : listen_http_addr,
777 0 : listen_https_addr,
778 0 : listen_grpc_addr,
779 0 : pg_auth_type,
780 0 : http_auth_type,
781 0 : grpc_auth_type,
782 0 : no_sync,
783 : };
784 0 : pageservers.push(conf);
785 : }
786 0 : pageservers
787 : };
788 :
789 0 : Ok(env)
790 0 : }
791 :
792 0 : pub fn persist_config(&self) -> anyhow::Result<()> {
793 0 : Self::persist_config_impl(
794 0 : &self.base_data_dir,
795 0 : &OnDiskConfig {
796 0 : pg_distrib_dir: self.pg_distrib_dir.clone(),
797 0 : neon_distrib_dir: self.neon_distrib_dir.clone(),
798 0 : default_tenant_id: self.default_tenant_id,
799 0 : private_key_path: self.private_key_path.clone(),
800 0 : public_key_path: self.public_key_path.clone(),
801 0 : broker: self.broker.clone(),
802 0 : storage_controller: self.storage_controller.clone(),
803 0 : pageservers: vec![], // it's skip_serializing anyway
804 0 : safekeepers: self.safekeepers.clone(),
805 0 : control_plane_api: Some(self.control_plane_api.clone()),
806 0 : control_plane_hooks_api: self.control_plane_hooks_api.clone(),
807 0 : control_plane_compute_hook_api: None,
808 0 : branch_name_mappings: self.branch_name_mappings.clone(),
809 0 : generate_local_ssl_certs: self.generate_local_ssl_certs,
810 0 : endpoint_storage: self.endpoint_storage.clone(),
811 0 : },
812 : )
813 0 : }
814 :
815 0 : pub fn persist_config_impl(base_path: &Path, config: &OnDiskConfig) -> anyhow::Result<()> {
816 0 : let conf_content = &toml::to_string_pretty(config)?;
817 0 : let target_config_path = base_path.join("config");
818 0 : fs::write(&target_config_path, conf_content).with_context(|| {
819 0 : format!(
820 0 : "Failed to write config file into path '{}'",
821 0 : target_config_path.display()
822 : )
823 0 : })
824 0 : }
825 :
826 : // this function is used only for testing purposes in CLI e g generate tokens during init
827 0 : pub fn generate_auth_token<S: Serialize>(&self, claims: &S) -> anyhow::Result<String> {
828 0 : let key = self.read_private_key()?;
829 0 : encode_from_key_file(claims, &key)
830 0 : }
831 :
832 : /// Get the path to the private key.
833 0 : pub fn get_private_key_path(&self) -> PathBuf {
834 0 : if self.private_key_path.is_absolute() {
835 0 : self.private_key_path.to_path_buf()
836 : } else {
837 0 : self.base_data_dir.join(&self.private_key_path)
838 : }
839 0 : }
840 :
841 : /// Get the path to the public key.
842 0 : pub fn get_public_key_path(&self) -> PathBuf {
843 0 : if self.public_key_path.is_absolute() {
844 0 : self.public_key_path.to_path_buf()
845 : } else {
846 0 : self.base_data_dir.join(&self.public_key_path)
847 : }
848 0 : }
849 :
850 : /// Read the contents of the private key file.
851 0 : pub fn read_private_key(&self) -> anyhow::Result<Pem> {
852 0 : let private_key_path = self.get_private_key_path();
853 0 : let pem = pem::parse(fs::read(private_key_path)?)?;
854 0 : Ok(pem)
855 0 : }
856 :
857 : /// Read the contents of the public key file.
858 0 : pub fn read_public_key(&self) -> anyhow::Result<Pem> {
859 0 : let public_key_path = self.get_public_key_path();
860 0 : let pem = pem::parse(fs::read(public_key_path)?)?;
861 0 : Ok(pem)
862 0 : }
863 :
864 : /// Materialize the [`NeonLocalInitConf`] to disk. Called during [`neon_local init`].
865 0 : pub fn init(conf: NeonLocalInitConf, force: &InitForceMode) -> anyhow::Result<()> {
866 0 : let base_path = base_path();
867 0 : assert_ne!(base_path, Path::new(""));
868 0 : let base_path = &base_path;
869 :
870 : // create base_path dir
871 0 : if base_path.exists() {
872 0 : match force {
873 : InitForceMode::MustNotExist => {
874 0 : bail!(
875 0 : "directory '{}' already exists. Perhaps already initialized?",
876 0 : base_path.display()
877 : );
878 : }
879 : InitForceMode::EmptyDirOk => {
880 0 : if let Some(res) = std::fs::read_dir(base_path)?.next() {
881 0 : res.context("check if directory is empty")?;
882 0 : anyhow::bail!("directory not empty: {base_path:?}");
883 0 : }
884 : }
885 : InitForceMode::RemoveAllContents => {
886 0 : println!("removing all contents of '{}'", base_path.display());
887 : // instead of directly calling `remove_dir_all`, we keep the original dir but removing
888 : // all contents inside. This helps if the developer symbol links another directory (i.e.,
889 : // S3 local SSD) to the `.neon` base directory.
890 0 : for entry in std::fs::read_dir(base_path)? {
891 0 : let entry = entry?;
892 0 : let path = entry.path();
893 0 : if path.is_dir() {
894 0 : fs::remove_dir_all(&path)?;
895 : } else {
896 0 : fs::remove_file(&path)?;
897 : }
898 : }
899 : }
900 : }
901 0 : }
902 0 : if !base_path.exists() {
903 0 : fs::create_dir(base_path)?;
904 0 : }
905 :
906 : let NeonLocalInitConf {
907 0 : pg_distrib_dir,
908 0 : neon_distrib_dir,
909 0 : default_tenant_id,
910 0 : broker,
911 0 : storage_controller,
912 0 : pageservers,
913 0 : safekeepers,
914 0 : control_plane_api,
915 0 : generate_local_ssl_certs,
916 0 : control_plane_hooks_api,
917 0 : endpoint_storage,
918 0 : } = conf;
919 :
920 : // Find postgres binaries.
921 : // Follow POSTGRES_DISTRIB_DIR if set, otherwise look in "pg_install".
922 : // Note that later in the code we assume, that distrib dirs follow the same pattern
923 : // for all postgres versions.
924 0 : let pg_distrib_dir = pg_distrib_dir.unwrap_or_else(|| {
925 0 : if let Some(postgres_bin) = env::var_os("POSTGRES_DISTRIB_DIR") {
926 0 : postgres_bin.into()
927 : } else {
928 0 : let cwd = env::current_dir().unwrap();
929 0 : cwd.join("pg_install")
930 : }
931 0 : });
932 :
933 : // Find neon binaries.
934 0 : let neon_distrib_dir = neon_distrib_dir
935 0 : .unwrap_or_else(|| env::current_exe().unwrap().parent().unwrap().to_owned());
936 :
937 : // Generate keypair for JWT.
938 : //
939 : // The keypair is only needed if authentication is enabled in any of the
940 : // components. For convenience, we generate the keypair even if authentication
941 : // is not enabled, so that you can easily enable it after the initialization
942 : // step.
943 0 : generate_auth_keys(
944 0 : base_path.join("auth_private_key.pem").as_path(),
945 0 : base_path.join("auth_public_key.pem").as_path(),
946 : )
947 0 : .context("generate auth keys")?;
948 0 : let private_key_path = PathBuf::from("auth_private_key.pem");
949 0 : let public_key_path = PathBuf::from("auth_public_key.pem");
950 :
951 : // create the runtime type because the remaining initialization code below needs
952 : // a LocalEnv instance op operation
953 : // TODO: refactor to avoid this, LocalEnv should only be constructed from on-disk state
954 0 : let env = LocalEnv {
955 0 : base_data_dir: base_path.clone(),
956 0 : pg_distrib_dir,
957 0 : neon_distrib_dir,
958 0 : default_tenant_id: Some(default_tenant_id),
959 0 : private_key_path,
960 0 : public_key_path,
961 0 : broker,
962 0 : storage_controller: storage_controller.unwrap_or_default(),
963 0 : pageservers: pageservers.iter().map(Into::into).collect(),
964 0 : safekeepers,
965 0 : control_plane_api: control_plane_api.unwrap(),
966 0 : control_plane_hooks_api,
967 0 : branch_name_mappings: Default::default(),
968 0 : generate_local_ssl_certs,
969 0 : endpoint_storage,
970 0 : };
971 :
972 0 : if generate_local_ssl_certs {
973 0 : env.generate_ssl_ca_cert()?;
974 0 : }
975 :
976 : // create endpoints dir
977 0 : fs::create_dir_all(env.endpoints_path())?;
978 :
979 : // create storage broker dir
980 0 : fs::create_dir_all(env.storage_broker_data_dir())?;
981 0 : StorageBroker::from_env(&env)
982 0 : .initialize()
983 0 : .context("storage broker init failed")?;
984 :
985 : // create safekeeper dirs
986 0 : for safekeeper in &env.safekeepers {
987 0 : fs::create_dir_all(SafekeeperNode::datadir_path_by_id(&env, safekeeper.id))?;
988 0 : SafekeeperNode::from_env(&env, safekeeper)
989 0 : .initialize()
990 0 : .context("safekeeper init failed")?;
991 : }
992 :
993 : // initialize pageserver state
994 0 : for (i, ps) in pageservers.into_iter().enumerate() {
995 0 : let runtime_ps = &env.pageservers[i];
996 0 : assert_eq!(&PageServerConf::from(&ps), runtime_ps);
997 0 : fs::create_dir(env.pageserver_data_dir(ps.id))?;
998 0 : PageServerNode::from_env(&env, runtime_ps)
999 0 : .initialize(ps)
1000 0 : .context("pageserver init failed")?;
1001 : }
1002 :
1003 0 : EndpointStorage::from_env(&env)
1004 0 : .init()
1005 0 : .context("object storage init failed")?;
1006 :
1007 : // setup remote remote location for default LocalFs remote storage
1008 0 : std::fs::create_dir_all(env.base_data_dir.join(PAGESERVER_REMOTE_STORAGE_DIR))?;
1009 0 : std::fs::create_dir_all(env.base_data_dir.join(ENDPOINT_STORAGE_REMOTE_STORAGE_DIR))?;
1010 :
1011 0 : env.persist_config()
1012 0 : }
1013 : }
1014 :
1015 0 : pub fn base_path() -> PathBuf {
1016 0 : let path = match std::env::var_os("NEON_REPO_DIR") {
1017 0 : Some(val) => {
1018 0 : let path = PathBuf::from(val);
1019 0 : if !path.is_absolute() {
1020 : // repeat the env var in the error because our default is always absolute
1021 0 : panic!("NEON_REPO_DIR must be an absolute path, got {path:?}");
1022 0 : }
1023 0 : path
1024 : }
1025 : None => {
1026 0 : let pwd = std::env::current_dir()
1027 : // technically this can fail but it's quite unlikeley
1028 0 : .expect("determine current directory");
1029 0 : let pwd_abs = pwd.canonicalize().expect("canonicalize current directory");
1030 0 : pwd_abs.join(".neon")
1031 : }
1032 : };
1033 0 : assert!(path.is_absolute());
1034 0 : path
1035 0 : }
1036 :
1037 : /// Generate a public/private key pair for JWT authentication
1038 0 : fn generate_auth_keys(private_key_path: &Path, public_key_path: &Path) -> anyhow::Result<()> {
1039 : // Generate the key pair
1040 : //
1041 : // openssl genpkey -algorithm ed25519 -out auth_private_key.pem
1042 0 : let keygen_output = Command::new("openssl")
1043 0 : .arg("genpkey")
1044 0 : .args(["-algorithm", "ed25519"])
1045 0 : .args(["-out", private_key_path.to_str().unwrap()])
1046 0 : .stdout(Stdio::null())
1047 0 : .output()
1048 0 : .context("failed to generate auth private key")?;
1049 0 : if !keygen_output.status.success() {
1050 0 : bail!(
1051 0 : "openssl failed: '{}'",
1052 0 : String::from_utf8_lossy(&keygen_output.stderr)
1053 : );
1054 0 : }
1055 :
1056 : // Extract the public key from the private key file
1057 : //
1058 : // openssl pkey -in auth_private_key.pem -pubout -out auth_public_key.pem
1059 0 : let keygen_output = Command::new("openssl")
1060 0 : .arg("pkey")
1061 0 : .args(["-in", private_key_path.to_str().unwrap()])
1062 0 : .arg("-pubout")
1063 0 : .args(["-out", public_key_path.to_str().unwrap()])
1064 0 : .output()
1065 0 : .context("failed to extract public key from private key")?;
1066 0 : if !keygen_output.status.success() {
1067 0 : bail!(
1068 0 : "openssl failed: '{}'",
1069 0 : String::from_utf8_lossy(&keygen_output.stderr)
1070 : );
1071 0 : }
1072 :
1073 0 : Ok(())
1074 0 : }
1075 :
1076 0 : fn generate_ssl_ca_cert(cert_path: &Path, key_path: &Path) -> anyhow::Result<()> {
1077 : // openssl req -x509 -newkey rsa:2048 -nodes -subj "/CN=Neon Local CA" -days 36500 \
1078 : // -out rootCA.crt -keyout rootCA.key
1079 0 : let keygen_output = Command::new("openssl")
1080 0 : .args([
1081 0 : "req", "-x509", "-newkey", "ed25519", "-nodes", "-days", "36500",
1082 0 : ])
1083 0 : .args(["-subj", "/CN=Neon Local CA"])
1084 0 : .args(["-out", cert_path.to_str().unwrap()])
1085 0 : .args(["-keyout", key_path.to_str().unwrap()])
1086 0 : .output()
1087 0 : .context("failed to generate CA certificate")?;
1088 0 : if !keygen_output.status.success() {
1089 0 : bail!(
1090 0 : "openssl failed: '{}'",
1091 0 : String::from_utf8_lossy(&keygen_output.stderr)
1092 : );
1093 0 : }
1094 0 : Ok(())
1095 0 : }
1096 :
1097 0 : fn generate_ssl_cert(
1098 0 : cert_path: &Path,
1099 0 : key_path: &Path,
1100 0 : ca_cert_path: &Path,
1101 0 : ca_key_path: &Path,
1102 0 : ) -> anyhow::Result<()> {
1103 : // Generate Certificate Signing Request (CSR).
1104 0 : let mut csr_path = cert_path.to_path_buf();
1105 0 : csr_path.set_extension(".csr");
1106 :
1107 : // openssl req -new -nodes -newkey rsa:2048 -keyout server.key -out server.csr \
1108 : // -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
1109 0 : let keygen_output = Command::new("openssl")
1110 0 : .args(["req", "-new", "-nodes"])
1111 0 : .args(["-newkey", "ed25519"])
1112 0 : .args(["-subj", "/CN=localhost"])
1113 0 : .args(["-addext", "subjectAltName=DNS:localhost,IP:127.0.0.1"])
1114 0 : .args(["-keyout", key_path.to_str().unwrap()])
1115 0 : .args(["-out", csr_path.to_str().unwrap()])
1116 0 : .output()
1117 0 : .context("failed to generate CSR")?;
1118 0 : if !keygen_output.status.success() {
1119 0 : bail!(
1120 0 : "openssl failed: '{}'",
1121 0 : String::from_utf8_lossy(&keygen_output.stderr)
1122 : );
1123 0 : }
1124 :
1125 : // Sign CSR with CA key.
1126 : //
1127 : // openssl x509 -req -in server.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial \
1128 : // -out server.crt -days 36500 -copy_extensions copyall
1129 0 : let keygen_output = Command::new("openssl")
1130 0 : .args(["x509", "-req"])
1131 0 : .args(["-in", csr_path.to_str().unwrap()])
1132 0 : .args(["-CA", ca_cert_path.to_str().unwrap()])
1133 0 : .args(["-CAkey", ca_key_path.to_str().unwrap()])
1134 0 : .arg("-CAcreateserial")
1135 0 : .args(["-out", cert_path.to_str().unwrap()])
1136 0 : .args(["-days", "36500"])
1137 0 : .args(["-copy_extensions", "copyall"])
1138 0 : .output()
1139 0 : .context("failed to sign CSR")?;
1140 0 : if !keygen_output.status.success() {
1141 0 : bail!(
1142 0 : "openssl failed: '{}'",
1143 0 : String::from_utf8_lossy(&keygen_output.stderr)
1144 : );
1145 0 : }
1146 :
1147 : // Remove CSR file as it's not needed anymore.
1148 0 : fs::remove_file(csr_path)?;
1149 :
1150 0 : Ok(())
1151 0 : }
|