Skip to content

Commit

Permalink
update: fixed location constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Dec 9, 2024
1 parent 62bac48 commit 47a4675
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 21 deletions.
7 changes: 3 additions & 4 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

AWS_ACCESS_KEY_ID=AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY=AWS_SECRET_ACCESS_KEY
AWS_REGION=us-east-1
MADARA_ORCHESTRATOR_AWS_BUCKET_LOCATION_CONSTRAINT=us-west-1
AWS_REGION=us-west-1
# For Aws sdk
AWS_ENDPOINT_URL=http://localhost.localstack.cloud:4566
# For Omniqueue
Expand All @@ -20,7 +19,7 @@ MADARA_ORCHESTRATOR_EVENT_BRIDGE_TRIGGER_POLICY_NAME=madara-orchestrator-worker-

#### ALERTS ####

MADARA_ORCHESTRATOR_AWS_SNS_ARN=arn:aws:sns:us-east-1:000000000000:madara-orchestrator-arn
MADARA_ORCHESTRATOR_AWS_SNS_ARN=arn:aws:sns:us-west-1:000000000000:madara-orchestrator-arn


#### DATA AVAILABILITY ####
Expand Down Expand Up @@ -67,7 +66,7 @@ MADARA_ORCHESTRATOR_ATLANTIC_RPC_NODE_URL=http://127.0.0.1:8545
MADARA_ORCHESTRATOR_SQS_PREFIX=madara_orchestrator
MADARA_ORCHESTRATOR_SQS_SUFFIX=queue
MADARA_ORCHESTRATOR_EVENT_BRIDGE_TARGET_QUEUE_NAME=madara_orchestrator_worker_trigger_queue
MADARA_ORCHESTRATOR_SQS_BASE_QUEUE_URL=http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000
MADARA_ORCHESTRATOR_SQS_BASE_QUEUE_URL=http://sqs.us-west-1.localhost.localstack.cloud:4566/000000000000

#### SETTLEMENT ####

Expand Down
4 changes: 0 additions & 4 deletions crates/orchestrator/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,6 @@ pub mod validate_params {
if aws_s3_args.aws_s3 && aws_config_args.aws {
Ok(StorageValidatedArgs::AWSS3(AWSS3ValidatedArgs {
bucket_name: aws_s3_args.bucket_name.clone().expect("Bucket name is required"),
bucket_location_constraint: aws_s3_args
.bucket_location_constraint
.clone()
.expect("Bucket Location Constraint is required"),
}))
} else {
Err("Only AWS S3 is supported as of now".to_string())
Expand Down
11 changes: 6 additions & 5 deletions crates/orchestrator/src/data_storage/aws_s3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ pub const S3_SETTINGS_NAME: &str = "s3";
#[derive(Debug, Clone)]
pub struct AWSS3ValidatedArgs {
pub bucket_name: String,
pub bucket_location_constraint: String,
}

/// AWSS3 represents AWS S3 client object containing the client and the config itself.
pub struct AWSS3 {
client: Client,
bucket: String,
bucket_location_constraint: String,
bucket_location_constraint: BucketLocationConstraint,
}

/// Implementation for AWS S3 client. Contains the function for :
Expand All @@ -36,10 +35,13 @@ impl AWSS3 {
// this is necessary for it to work with localstack in test cases
s3_config_builder.set_force_path_style(Some(true));
let client = Client::from_conf(s3_config_builder.build());

let region_str = aws_config.region().expect("Could not get region as string").to_string();
let location_constraint: BucketLocationConstraint = BucketLocationConstraint::from_str(region_str.as_str()).expect("Could not get location constraint from region string");
Self {
client,
bucket: s3_config.bucket_name.clone(),
bucket_location_constraint: s3_config.bucket_location_constraint.clone(),
bucket_location_constraint: location_constraint,
}
}
}
Expand Down Expand Up @@ -90,8 +92,7 @@ impl DataStorage for AWSS3 {
async fn create_bucket(&self, bucket_name: &str) -> Result<()> {
let create_bucket_config = Some(
CreateBucketConfiguration::builder()
// TODO: assign region based on env
.location_constraint(BucketLocationConstraint::from_str(self.bucket_location_constraint.as_str()).expect("Could not decode location constraint"))
.location_constraint(self.bucket_location_constraint.clone())
.build(),
);

Expand Down
6 changes: 1 addition & 5 deletions crates/orchestrator/src/queue/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,12 @@ pub struct JobQueueMessage {
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Display)]
#[strum(serialize_all = "PascalCase")]
pub enum WorkerTriggerType {
#[strum(serialize = "Snos")]
Snos,
#[strum(serialize = "Proving")]
Proving,
#[strum(serialize = "ProofRegistration")]
ProofRegistration,
#[strum(serialize = "DataSubmission")]
DataSubmission,
#[strum(serialize = "UpdateState")]
UpdateState,
}

Expand Down
1 change: 0 additions & 1 deletion crates/orchestrator/src/tests/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ fn get_env_params() -> EnvParams {

let storage_params = StorageValidatedArgs::AWSS3(AWSS3ValidatedArgs {
bucket_name: get_env_var_or_panic("MADARA_ORCHESTRATOR_AWS_S3_BUCKET_NAME"),
bucket_location_constraint: get_env_var_or_panic("MADARA_ORCHESTRATOR_AWS_BUCKET_LOCATION_CONSTRAINT"),
});

let queue_params = QueueValidatedArgs::AWSSQS(AWSSQSValidatedArgs {
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ async fn test_orchestrator_workflow(#[case] l2_block_number: String) {
let target_queue_name = &get_env_var_or_panic("MADARA_ORCHESTRATOR_EVENT_BRIDGE_TARGET_QUEUE_NAME");

// Setup eventbridge rules
create_eventbridge_rule(trigger_rule_name, target_queue_name).await.expect(
create_event_bridge_rule(trigger_rule_name, target_queue_name).await.expect(
"Unable to create
event bridge rule",
);
Expand Down Expand Up @@ -239,7 +239,7 @@ async fn test_orchestrator_workflow(#[case] l2_block_number: String) {

/// Function that adds rules to tests for localstack
/// This can be removed after https://github.com/localstack/localstack/issues/9861 is closed
async fn create_eventbridge_rule(trigger_rule_name: &String, target_queue_name: &String) -> color_eyre::Result<()> {
async fn create_event_bridge_rule(trigger_rule_name: &String, target_queue_name: &String) -> color_eyre::Result<()> {
let aws_config = &aws_config::from_env().load().await;

let queue_client = aws_sdk_sqs::Client::new(aws_config);
Expand Down

0 comments on commit 47a4675

Please sign in to comment.