Skip to content

Commit

Permalink
Add preliminary support for other cloud providers to orchestratord
Browse files Browse the repository at this point in the history
Changes orchestratord to use the CloudProvider used by the catalog, to
reduce duplication and eliminate the possibility of incompatibilities
between them.
Adds preliminary support for other cloud providers.

Does not add any special handling of them, but accepts GCP, Azure, and
Generic cloud providers.

In the future, we may want to expand our support for these to include
their equivalent of IAM roles, to support advanced features such as
non-password-based access to persist buckets or assuming roles, but that
is all out of scope for now.
  • Loading branch information
alex-hunt-materialize committed Nov 19, 2024
1 parent 4500822 commit d0c0e38
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 33 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/orchestratord/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ rust_library(
"//src/orchestrator-tracing:mz_orchestrator_tracing",
"//src/ore:mz_ore",
"//src/prof-http:mz_prof_http",
"//src/sql:mz_sql",
"//src/tls-util:mz_tls_util",
] + all_crate_deps(normal = True),
)
Expand Down Expand Up @@ -79,6 +80,7 @@ rust_test(
"//src/orchestrator-tracing:mz_orchestrator_tracing",
"//src/ore:mz_ore",
"//src/prof-http:mz_prof_http",
"//src/sql:mz_sql",
"//src/tls-util:mz_tls_util",
] + all_crate_deps(
normal = True,
Expand All @@ -99,6 +101,7 @@ rust_doc_test(
"//src/orchestrator-tracing:mz_orchestrator_tracing",
"//src/ore:mz_ore",
"//src/prof-http:mz_prof_http",
"//src/sql:mz_sql",
"//src/tls-util:mz_tls_util",
] + all_crate_deps(
normal = True,
Expand Down Expand Up @@ -133,6 +136,7 @@ rust_binary(
"//src/orchestrator-tracing:mz_orchestrator_tracing",
"//src/ore:mz_ore",
"//src/prof-http:mz_prof_http",
"//src/sql:mz_sql",
"//src/tls-util:mz_tls_util",
] + all_crate_deps(normal = True),
)
1 change: 1 addition & 0 deletions src/orchestratord/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mz-ore = { path = "../ore" }
mz-orchestrator-kubernetes = { path = "../orchestrator-kubernetes" }
mz-orchestrator-tracing = { path = "../orchestrator-tracing" }
mz-prof-http = { path = "../prof-http" }
mz-sql = { path = "../sql" }
mz-tls-util = { path = "../tls-util" }
prometheus = { version = "0.13.3", default-features = false }
rand = "0.8.5"
Expand Down
32 changes: 1 addition & 31 deletions src/orchestratord/src/controller/materialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use mz_cloud_resources::crd::materialize::v1alpha1::{Materialize, MaterializeSta
use mz_orchestrator_kubernetes::KubernetesImagePullPolicy;
use mz_orchestrator_tracing::TracingCliArgs;
use mz_ore::{cast::CastFrom, cli::KeyValueArg, instrument};
use mz_sql::catalog::CloudProvider;

mod console;
mod resources;
Expand Down Expand Up @@ -127,37 +128,6 @@ pub struct Args {
console_http_port: i32,
}

#[derive(Debug, Eq, PartialEq, Clone, Copy)]
pub enum CloudProvider {
Aws,
Local,
}

impl std::str::FromStr for CloudProvider {
type Err = String;

fn from_str(value: &str) -> Result<Self, Self::Err> {
match value.to_lowercase().as_ref() {
"aws" => Ok(Self::Aws),
"local" => Ok(Self::Local),
_ => Err("invalid cloud provider".to_string()),
}
}
}

impl std::fmt::Display for CloudProvider {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Self::Aws => "aws",
Self::Local => "local",
}
)
}
}

#[derive(clap::Parser)]
pub struct AwsInfo {
#[clap(long)]
Expand Down
3 changes: 2 additions & 1 deletion src/orchestratord/src/controller/materialize/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use tracing::trace;

use super::{matching_image_from_environmentd_image_ref, CloudProvider};
use super::matching_image_from_environmentd_image_ref;
use crate::k8s::{apply_resource, delete_resource, get_resource};
use mz_cloud_resources::crd::materialize::v1alpha1::Materialize;
use mz_environmentd::DeploymentStatus;
use mz_orchestrator_tracing::TracingCliArgs;
use mz_ore::instrument;
use mz_sql::catalog::CloudProvider;

#[derive(Debug, Serialize)]
pub struct Resources {
Expand Down
41 changes: 40 additions & 1 deletion src/sql/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,12 @@ pub enum CloudProvider {
Cloudtest,
/// Amazon Web Services.
Aws,
/// Google Cloud Platform
Gcp,
/// Microsoft Azure
Azure,
/// Other generic cloud provider
Generic,
}

impl fmt::Display for CloudProvider {
Expand All @@ -1210,6 +1216,9 @@ impl fmt::Display for CloudProvider {
CloudProvider::MzCompose => f.write_str("mzcompose"),
CloudProvider::Cloudtest => f.write_str("cloudtest"),
CloudProvider::Aws => f.write_str("aws"),
CloudProvider::Gcp => f.write_str("gcp"),
CloudProvider::Azure => f.write_str("azure"),
CloudProvider::Generic => f.write_str("generic"),
}
}
}
Expand All @@ -1218,12 +1227,15 @@ impl FromStr for CloudProvider {
type Err = InvalidCloudProviderError;

fn from_str(s: &str) -> Result<CloudProvider, InvalidCloudProviderError> {
match s {
match s.to_lowercase().as_ref() {
"local" => Ok(CloudProvider::Local),
"docker" => Ok(CloudProvider::Docker),
"mzcompose" => Ok(CloudProvider::MzCompose),
"cloudtest" => Ok(CloudProvider::Cloudtest),
"aws" => Ok(CloudProvider::Aws),
"gcp" => Ok(CloudProvider::Gcp),
"azure" => Ok(CloudProvider::Azure),
"generic" => Ok(CloudProvider::Generic),
_ => Err(InvalidCloudProviderError),
}
}
Expand Down Expand Up @@ -1784,6 +1796,33 @@ mod tests {
ordinal: 0,
}),
),
(
"gcp-us-central1-1497a3b7-a455-4fc4-8752-b44a94b5f90a-0",
Ok(EnvironmentId {
cloud_provider: CloudProvider::Gcp,
cloud_provider_region: "us-central1".into(),
organization_id: "1497a3b7-a455-4fc4-8752-b44a94b5f90a".parse().unwrap(),
ordinal: 0,
}),
),
(
"azure-australiaeast-1497a3b7-a455-4fc4-8752-b44a94b5f90a-0",
Ok(EnvironmentId {
cloud_provider: CloudProvider::Azure,
cloud_provider_region: "australiaeast".into(),
organization_id: "1497a3b7-a455-4fc4-8752-b44a94b5f90a".parse().unwrap(),
ordinal: 0,
}),
),
(
"generic-moon-station-11-darkside-1497a3b7-a455-4fc4-8752-b44a94b5f90a-0",
Ok(EnvironmentId {
cloud_provider: CloudProvider::Generic,
cloud_provider_region: "moon-station-11-darkside".into(),
organization_id: "1497a3b7-a455-4fc4-8752-b44a94b5f90a".parse().unwrap(),
ordinal: 0,
}),
),
("", Err(InvalidEnvironmentIdError)),
(
"local-az1-1497a3b7-a455-4fc4-8752-b44a94b5f90a-123456789",
Expand Down

0 comments on commit d0c0e38

Please sign in to comment.