Skip to content

Commit

Permalink
fix: move default builds to tf, bump s3 sdk (#1237)
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
MasterPtato committed Oct 24, 2024
1 parent de562cb commit 0194031
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 224 deletions.
30 changes: 15 additions & 15 deletions lib/cli/src/run_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,25 +321,25 @@ pub fn config(_rivet_config: rivet_config::Config) -> Result<RunConfigData> {
];

let s3_buckets = vec![
S3Bucket { name: "build" },
S3Bucket { name: "cdn" },
S3Bucket { name: "export" },
S3Bucket { name: "banner" },
S3Bucket { name: "logo" },
S3Bucket { name: "artifacts" },
S3Bucket { name: "export" },
S3Bucket { name: "log" },
S3Bucket { name: "bucket-build" },
S3Bucket { name: "bucket-cdn" },
S3Bucket { name: "bucket-export" },
S3Bucket { name: "bucket-banner" },
S3Bucket { name: "bucket-logo" },
S3Bucket { name: "bucket-artifacts" },
S3Bucket { name: "bucket-export" },
S3Bucket { name: "bucket-log" },
S3Bucket {
name: "imagor-result-storage",
name: "bucket-imagor-result-storage",
},
S3Bucket { name: "svc-build" },
S3Bucket { name: "bucket-svc-build" },
S3Bucket {
name: "lobby-history-export",
name: "bucket-lobby-history-export",
},
S3Bucket { name: "log" },
S3Bucket { name: "avatar" },
S3Bucket { name: "billing" },
S3Bucket { name: "avatar" },
S3Bucket { name: "bucket-log" },
S3Bucket { name: "bucket-avatar" },
S3Bucket { name: "bucket-billing" },
S3Bucket { name: "bucket-avatar" },
];

Ok(RunConfigData {
Expand Down
18 changes: 17 additions & 1 deletion lib/config/src/config/rivet.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::{collections::HashMap, path::PathBuf};

use global_error::prelude::*;
use serde::{Deserialize, Serialize};
use url::Url;
Expand Down Expand Up @@ -85,6 +87,10 @@ pub struct Rivet {
#[serde(default)]
pub backend: Option<Backend>,

/// Configuration for test builds.
#[serde(default)]
pub test_builds: HashMap<String, TestBuild>,

/// Deprecated: Configuration for job running.
#[serde(default)]
pub job_run: Option<JobRun>,
Expand Down Expand Up @@ -113,6 +119,7 @@ impl Default for Rivet {
pegboard: Pegboard::default(),
job_run: None,
auth: Auth::default(),
token: Tokens::default(),
api: Api::default(),
api_internal: ApiInternal::default(),
metrics: Metrics::default(),
Expand All @@ -122,7 +129,7 @@ impl Default for Rivet {
dns: None,
billing: None,
backend: None,
token: Tokens::default(),
test_builds: Default::default(),
profanity_filter_disable: false,
upload_nsfw_check_enabled: false,
upload_nsfw_error_verbose: false,
Expand Down Expand Up @@ -182,6 +189,15 @@ pub struct Backend {
pub base_domain: String,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "snake_case", deny_unknown_fields)]
pub struct TestBuild {
/// Image tag.
pub tag: String,
/// S3 key.
pub key: PathBuf,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "snake_case", deny_unknown_fields)]
pub struct Api {
Expand Down
8 changes: 4 additions & 4 deletions lib/s3-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ edition = "2021"
license = "Apache-2.0"

[dependencies]
aws-sdk-s3 = { version = "0.22", features = ["rt-tokio"] }
aws-smithy-async = { version = "0.52", features = ["rt-tokio"] }
aws-smithy-http = { version = "0.52", features = ["rt-tokio"] }
aws-smithy-types = { version = "0.52" }
aws-sdk-s3 = { version = "1.57", features = ["rt-tokio"] }
aws-smithy-async = { version = "1.2", features = ["rt-tokio"] }
aws-smithy-http = { version = "0.60", features = ["rt-tokio"] }
aws-smithy-types = { version = "1.2" }
http = "0.2"
thiserror = "1.0"
tracing = "0.1"
Expand Down
8 changes: 5 additions & 3 deletions lib/s3-util/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@ impl Client {
secret_access_key: &str,
) -> Result<Self, ClientError> {
let config = aws_sdk_s3::Config::builder()
.region(aws_sdk_s3::Region::new(region.to_owned()))
.endpoint_resolver(aws_sdk_s3::Endpoint::immutable(endpoint)?)
.credentials_provider(aws_sdk_s3::Credentials::new(
.region(aws_sdk_s3::config::Region::new(region.to_owned()))
.endpoint_url(endpoint)
.force_path_style(true)
.credentials_provider(aws_sdk_s3::config::Credentials::new(
access_key_id,
secret_access_key,
None,
None,
"Static",
))
.behavior_version(aws_sdk_s3::config::BehaviorVersion::v2024_03_28())
// .sleep_impl(Arc::new(aws_smithy_async::rt::sleep::TokioSleep::new()))
.build();
let client = aws_sdk_s3::Client::from_conf(config);
Expand Down
9 changes: 3 additions & 6 deletions lib/s3-util/src/provision.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use aws_sdk_s3::error::{CreateBucketError, CreateBucketErrorKind};
use aws_sdk_s3::operation::create_bucket::CreateBucketError;

use crate::{Client, ClientError, S3Bucket};

Expand Down Expand Up @@ -36,11 +36,8 @@ pub async fn provision(
match client.create_bucket().bucket(&bucket_name).send().await {
Ok(_) => tracing::info!(bucket = ?bucket_name, "bucket created"),
Err(err) => {
if let aws_sdk_s3::types::SdkError::ServiceError(service_err) = &err {
if let CreateBucketError {
kind: CreateBucketErrorKind::BucketAlreadyOwnedByYou(_),
..
} = service_err.err()
if let aws_sdk_s3::error::SdkError::ServiceError(service_err) = &err {
if let CreateBucketError::BucketAlreadyOwnedByYou(_) = service_err.err()
{
tracing::info!(bucket = ?bucket_name, "bucket already exists");
continue;
Expand Down
57 changes: 0 additions & 57 deletions scripts/default_builds/build.sh

This file was deleted.

4 changes: 2 additions & 2 deletions svc/api/cloud/src/route/games/matchmaker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub async fn export_history(
.bucket(s3_client.bucket())
.key(format!("{upload_id}/export.csv"))
.presigned(
s3_util::aws_sdk_s3::presigning::config::PresigningConfig::builder()
s3_util::aws_sdk_s3::presigning::PresigningConfig::builder()
.expires_in(Duration::from_secs(60 * 60))
.build()?,
)
Expand Down Expand Up @@ -309,7 +309,7 @@ pub async fn export_lobby_logs(
.bucket(s3_client.bucket())
.key(format!("{upload_id}/{filename}"))
.presigned(
s3_util::aws_sdk_s3::presigning::config::PresigningConfig::builder()
s3_util::aws_sdk_s3::presigning::PresigningConfig::builder()
.expires_in(Duration::from_secs(60 * 60))
.build()?,
)
Expand Down
3 changes: 2 additions & 1 deletion svc/pkg/build/standalone/default-create/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ rivet-operation = { path = "../../../../../lib/operation/core" }
futures-util = "0.3"
indoc = "1.0"
prost = "0.10"
rivet-connection = { path = "../../../../../lib/connection" }
reqwest = "0.11"
rivet-connection = { path = "../../../../../lib/connection" }
rivet-pools = { path = "../../../../../lib/pools" }
s3-util = { path = "../../../../../lib/s3-util" }
tokio = { version = "1.40", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", default-features = false, features = [
Expand Down
Loading

0 comments on commit 0194031

Please sign in to comment.