Skip to content

Commit

Permalink
Revert restore hack
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Stanton <ian@tembo.io>
  • Loading branch information
ianstanton committed Sep 25, 2024
1 parent 5de7269 commit 4227c09
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 49 deletions.
42 changes: 1 addition & 41 deletions conductor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,43 +35,19 @@ pub async fn generate_spec(
namespace: &str,
backups_bucket: &str,
spec: &CoreDBSpec,
is_cloud_formation: bool,
is_azure: bool,
azure_storage_account: &str,
write_path: &str,
) -> Value {
let mut spec = spec.clone();
// Add the bucket name into the backups_path if it's not already there

if let Some(restore) = &mut spec.restore {
if let Some(backups_path) = &mut restore.backups_path {
if !backups_path.starts_with(&format!("s3://{}", backups_bucket)) && is_cloud_formation
if !backups_path.starts_with(&format!("s3://{}", backups_bucket))
{
let path_suffix = backups_path.trim_start_matches("s3://");
*backups_path = format!("s3://{}/{}", backups_bucket, path_suffix);
}
}
if is_azure {
let r = Restore {
azure_credentials: spec.backup.azure_credentials.clone(),
s3_credentials: None,
google_credentials: None,
backups_path: Some(format!(
"https://{}.blob.core.windows.net/{}/{}/{}",
azure_storage_account,
backups_bucket,
restore.server_name.clone(),
restore.server_name.clone()
)),
server_name: restore.server_name.clone(),
volume_snapshot: Some(false),
endpoint_url: None,
recovery_target_time: restore.recovery_target_time.clone(),
};
spec.restore = Some(r);
}
}

serde_json::json!({
"apiVersion": "coredb.io/v1alpha1",
"kind": "CoreDB",
Expand Down Expand Up @@ -670,10 +646,6 @@ mod tests {
"namespace",
"my-bucket",
&spec,
true,
false,
"",
"",
)
.await;
let expected_backups_path = "s3://my-bucket/coredb/coredb/org-coredb-inst-pgtrunkio-dev";
Expand Down Expand Up @@ -702,10 +674,6 @@ mod tests {
"namespace",
"my-bucket",
&spec,
true,
false,
"",
"",
)
.await;
let expected_backups_path = "s3://my-bucket/coredb/coredb/org-coredb-inst-pgtrunkio-dev";
Expand All @@ -732,10 +700,6 @@ mod tests {
"namespace",
"my-bucket",
&spec,
true,
false,
"",
"",
)
.await;
assert!(result["spec"]["restore"]["backupsPath"].is_null());
Expand All @@ -755,10 +719,6 @@ mod tests {
"namespace",
"my-bucket",
&spec,
true,
false,
"",
"",
)
.await;
assert!(result["spec"]["restore"].is_null());
Expand Down
8 changes: 0 additions & 8 deletions conductor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,6 @@ async fn run(metrics: CustomMetrics) -> Result<(), ConductorError> {
&namespace,
&backup_archive_bucket,
&coredb_spec,
is_cloud_formation,
is_azure,
&azure_storage_account,
&read_msg
.message
.backups_write_path
.clone()
.unwrap_or(format!("v2/{}", read_msg.message.namespace)),
)
.await;

Expand Down

0 comments on commit 4227c09

Please sign in to comment.