Skip to content

Commit

Permalink
chore: make s3 and API gateway cloud linting optional
Browse files Browse the repository at this point in the history
Make s3 and API gateway cloud linting optional.
  • Loading branch information
nand4011 committed Aug 2, 2024
1 parent 0f4746d commit 279c846
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 16 deletions.
14 changes: 12 additions & 2 deletions momento-cli-opts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,24 @@ to help find opportunities for optimizations with Momento.
region: String,
#[arg(
long = "enable-ddb-ttl-check",
help = "Opt in to check whether ddb tables have ttl enabled. If there are lots of tables, could slow down data collection"
help = "Opt in to check whether ddb tables have ttl enabled. If there are lots of tables, this could slow down data collection"
)]
enable_ddb_ttl_check: bool,
#[arg(
long = "enable-gsi",
help = "Opt in to check metrics on dynamodb gsi's. If there are lots of tables with gsi's, could slow down data collection"
help = "Opt in to check metrics on dynamodb gsi's. If there are lots of tables with gsi's, this could slow down data collection"
)]
enable_gsi: bool,
#[arg(
long = "enable-s3",
help = "Opt in to check metrics on s3. If there are lots of s3 buckets, this could slow down data collection"
)]
enable_s3: bool,
#[arg(
long = "enable-apt-gateway",
help = "Opt in to check metrics on API Gateway"
)]
enable_api_gateway: bool,
#[arg(
value_enum,
long = "resource",
Expand Down
39 changes: 25 additions & 14 deletions momento/src/commands/cloud_linter/linter_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub async fn run_cloud_linter(
region: String,
enable_ddb_ttl_check: bool,
enable_gsi: bool,
enable_s3: bool,
enable_api_gateway: bool,
only_collect_for_resource: Option<CloudLinterResources>,
metric_collection_rate: u32,
) -> Result<(), CliError> {
Expand All @@ -49,6 +51,8 @@ pub async fn run_cloud_linter(
tx,
enable_ddb_ttl_check,
enable_gsi,
enable_s3,
enable_api_gateway,
only_collect_for_resource,
metric_collection_rate,
)
Expand Down Expand Up @@ -80,11 +84,14 @@ pub async fn run_cloud_linter(
Ok(())
}

#[allow(clippy::too_many_arguments)]
async fn process_data(
region: String,
sender: Sender<Resource>,
enable_ddb_ttl_check: bool,
enable_gsi: bool,
enable_s3: bool,
enable_api_gateway: bool,
only_collect_for_resource: Option<CloudLinterResources>,
metric_collection_rate: u32,
) -> Result<(), CliError> {
Expand Down Expand Up @@ -170,21 +177,25 @@ async fn process_data(
};
};

process_s3_resources(
&config,
Arc::clone(&control_plane_limiter),
Arc::clone(&metrics_limiter),
sender.clone(),
)
.await?;
if enable_s3 {
process_s3_resources(
&config,
Arc::clone(&control_plane_limiter),
Arc::clone(&metrics_limiter),
sender.clone(),
)
.await?;
}

process_api_gateway_resources(
&config,
Arc::clone(&control_plane_limiter),
Arc::clone(&metrics_limiter),
sender.clone(),
)
.await?;
if enable_api_gateway {
process_api_gateway_resources(
&config,
Arc::clone(&control_plane_limiter),
Arc::clone(&metrics_limiter),
sender.clone(),
)
.await?;
}

process_ddb_resources(
&config,
Expand Down
4 changes: 4 additions & 0 deletions momento/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,15 @@ async fn run_momento_command(args: momento_cli_opts::Momento) -> Result<(), CliE
resource,
metric_collection_rate,
enable_gsi,
enable_s3,
enable_api_gateway,
} => {
commands::cloud_linter::linter_cli::run_cloud_linter(
region,
enable_ddb_ttl_check,
enable_gsi,
enable_s3,
enable_api_gateway,
resource,
metric_collection_rate,
)
Expand Down

0 comments on commit 279c846

Please sign in to comment.