mirror of
https://github.com/neondatabase/neon.git
synced 2026-06-01 04:20:39 +00:00
Add set_mergeable
This commit is contained in:
@@ -602,6 +602,16 @@ fn handle_timeline(timeline_match: &ArgMatches, env: &mut local_env::LocalEnv) -
|
||||
let dst_endpoint = cplane.endpoints.get(dst_endpoint_id).unwrap();
|
||||
dst_endpoint.merge_from(src_endpoint)?;
|
||||
}
|
||||
Some(("set_mergeable", branch_match)) => {
|
||||
let endpoint_id = branch_match
|
||||
.get_one::<String>("endpoint")
|
||||
.map(|s| s.as_str())
|
||||
.ok_or(anyhow!("No endpoint provided"))?;
|
||||
|
||||
let cplane = ComputeControlPlane::load(env.clone())?;
|
||||
let endpoint = cplane.endpoints.get(endpoint_id).unwrap();
|
||||
endpoint.set_mergeable()?;
|
||||
}
|
||||
Some((sub_name, _)) => bail!("Unexpected tenant subcommand '{sub_name}'"),
|
||||
None => bail!("no tenant subcommand provided"),
|
||||
}
|
||||
@@ -1325,6 +1335,10 @@ fn cli() -> Command {
|
||||
.arg(Arg::new("src-endpoint").long("src-endpoint").help("Source endpoint for merge").required(true))
|
||||
.arg(Arg::new("dst-endpoint").long("dst-endpoint").help("Destination endpoint for merge").required(true))
|
||||
)
|
||||
.subcommand(Command::new("set_mergeable")
|
||||
.about("Mark branch as mergeable")
|
||||
.arg(Arg::new("endpoint").long("endpoint").help("Enpoint to be marked as mergeable").required(true))
|
||||
)
|
||||
.subcommand(Command::new("create")
|
||||
.about("Create a new blank timeline")
|
||||
.arg(tenant_id_arg.clone())
|
||||
|
||||
@@ -572,9 +572,11 @@ impl Endpoint {
|
||||
}
|
||||
ComputeStatus::Empty
|
||||
| ComputeStatus::ConfigurationPending
|
||||
| ComputeStatus::Configuration
|
||||
| ComputeStatus::MergePending
|
||||
| ComputeStatus::Merging => {
|
||||
| ComputeStatus::Configuration
|
||||
| ComputeStatus::MergePending
|
||||
| ComputeStatus::Merging
|
||||
| ComputeStatus::SetMergeablePending
|
||||
| ComputeStatus::SetMergeable => {
|
||||
bail!("unexpected compute status: {:?}", state.status)
|
||||
}
|
||||
}
|
||||
@@ -699,6 +701,28 @@ impl Endpoint {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_mergeable(&self) -> Result<()> {
|
||||
let client = reqwest::blocking::Client::new();
|
||||
let response = client
|
||||
.post(format!(
|
||||
"http://{}:{}/set_mergeable",
|
||||
self.http_address.ip(),
|
||||
self.http_address.port()
|
||||
))
|
||||
.send()?;
|
||||
let status = response.status();
|
||||
if !(status.is_client_error() || status.is_server_error()) {
|
||||
Ok(())
|
||||
} else {
|
||||
let url = response.url().to_owned();
|
||||
let msg = match response.text() {
|
||||
Ok(err_body) => format!("Error: {}", err_body),
|
||||
Err(_) => format!("Http error ({}) at {}.", status.as_u16(), url),
|
||||
};
|
||||
Err(anyhow::anyhow!(msg))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stop(&self, destroy: bool) -> Result<()> {
|
||||
// If we are going to destroy data directory,
|
||||
// use immediate shutdown mode, otherwise,
|
||||
|
||||
Reference in New Issue
Block a user