mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-06 13:02:55 +00:00
endpoint_storage: allow bypassing s3 write check on startup (#12165)
Related: https://github.com/neondatabase/cloud/issues/27195
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2055,6 +2055,7 @@ dependencies = [
|
|||||||
"axum-extra",
|
"axum-extra",
|
||||||
"camino",
|
"camino",
|
||||||
"camino-tempfile",
|
"camino-tempfile",
|
||||||
|
"clap",
|
||||||
"futures",
|
"futures",
|
||||||
"http-body-util",
|
"http-body-util",
|
||||||
"itertools 0.10.5",
|
"itertools 0.10.5",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ anyhow.workspace = true
|
|||||||
axum-extra.workspace = true
|
axum-extra.workspace = true
|
||||||
axum.workspace = true
|
axum.workspace = true
|
||||||
camino.workspace = true
|
camino.workspace = true
|
||||||
|
clap.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
jsonwebtoken.workspace = true
|
jsonwebtoken.workspace = true
|
||||||
prometheus.workspace = true
|
prometheus.workspace = true
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
//! This service is deployed either as a separate component or as part of compute image
|
//! This service is deployed either as a separate component or as part of compute image
|
||||||
//! for large computes.
|
//! for large computes.
|
||||||
mod app;
|
mod app;
|
||||||
use anyhow::{Context, bail};
|
use anyhow::Context;
|
||||||
|
use clap::Parser;
|
||||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
use utils::logging;
|
use utils::logging;
|
||||||
@@ -17,6 +18,18 @@ const fn listen() -> SocketAddr {
|
|||||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 51243)
|
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 51243)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
struct Args {
|
||||||
|
#[arg(exclusive = true)]
|
||||||
|
config_file: Option<String>,
|
||||||
|
#[arg(long, default_value = "false", requires = "config")]
|
||||||
|
/// to allow testing k8s helm chart where we don't have s3 credentials
|
||||||
|
no_s3_check_on_startup: bool,
|
||||||
|
#[arg(long, value_name = "FILE")]
|
||||||
|
/// inline config mode for k8s helm chart
|
||||||
|
config: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
struct Config {
|
struct Config {
|
||||||
@@ -37,19 +50,16 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
logging::Output::Stdout,
|
logging::Output::Stdout,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Allow either passing filename or inline config (for k8s helm chart)
|
let args = Args::parse();
|
||||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
let config: Config = if let Some(config_path) = args.config_file {
|
||||||
let config: Config = if args.len() == 1 && args[0].ends_with(".json") {
|
info!("Reading config from {config_path}");
|
||||||
info!("Reading config from {}", args[0]);
|
let config = std::fs::read_to_string(config_path)?;
|
||||||
let config = std::fs::read_to_string(args[0].clone())?;
|
|
||||||
serde_json::from_str(&config).context("parsing config")?
|
serde_json::from_str(&config).context("parsing config")?
|
||||||
} else if !args.is_empty() && args[0].starts_with("--config=") {
|
} else if let Some(config) = args.config {
|
||||||
info!("Reading inline config");
|
info!("Reading inline config");
|
||||||
let config = args.join(" ");
|
serde_json::from_str(&config).context("parsing config")?
|
||||||
let config = config.strip_prefix("--config=").unwrap();
|
|
||||||
serde_json::from_str(config).context("parsing config")?
|
|
||||||
} else {
|
} else {
|
||||||
bail!("Usage: endpoint_storage config.json or endpoint_storage --config=JSON");
|
anyhow::bail!("Supply either config file path or --config=inline-config");
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Reading pemfile from {}", config.pemfile.clone());
|
info!("Reading pemfile from {}", config.pemfile.clone());
|
||||||
@@ -62,7 +72,9 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
let storage = remote_storage::GenericRemoteStorage::from_config(&config.storage_config).await?;
|
let storage = remote_storage::GenericRemoteStorage::from_config(&config.storage_config).await?;
|
||||||
let cancel = tokio_util::sync::CancellationToken::new();
|
let cancel = tokio_util::sync::CancellationToken::new();
|
||||||
app::check_storage_permissions(&storage, cancel.clone()).await?;
|
if !args.no_s3_check_on_startup {
|
||||||
|
app::check_storage_permissions(&storage, cancel.clone()).await?;
|
||||||
|
}
|
||||||
|
|
||||||
let proxy = std::sync::Arc::new(endpoint_storage::Storage {
|
let proxy = std::sync::Arc::new(endpoint_storage::Storage {
|
||||||
auth,
|
auth,
|
||||||
|
|||||||
Reference in New Issue
Block a user