Skip to content

Commit 02aa996

Browse files
authored
chore: remove unused legacy infra (#1339)
lets wait at least to end of week to land this. The buckets will be orphaned, so we will keep them around a while longer just as a precaution. 4h downloads is removed in favour of a broader analytics engine query that runs less frequently. keeps similar behaviour than before while removing one the largest tables we have.
1 parent ca63a3c commit 02aa996

37 files changed

+253
-2318
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ This is the source code for https://jsr.io, the new JavaScript registry.
2424

2525
**Implementation details**
2626

27-
- Modules and package metadata are stored on Google Cloud Storage (GCS)
28-
- npm compatibility tarballs are stored on Google Cloud Storage (GCS)
27+
- Modules and package metadata are stored on Cloudflare R2
28+
- npm compatibility tarballs are stored on Cloudflare R2
2929
- Management API is implemented in Rust and runs on Google Cloud Run
3030
- Frontend uses Fresh and is running on Google Cloud Run in 6 regions
3131
- https://jsr.io, https://api.jsr.io, and https://npm.jsr.io are served by a
3232
Cloudflare Workers worker
33-
- Module, package metadata, and npm tarballs is served directly from GCS
33+
- Module, package metadata, and npm tarballs is served directly from R2
3434
- /api requests are proxied to the management API
3535
- All other requests are proxied to the frontend
3636
- Data is stored in PostgreSQL (using Google Cloud SQL)

api/.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ GITHUB_CLIENT_ID=xxx
33
GITHUB_CLIENT_SECRET=xxx
44
GITLAB_CLIENT_ID=xxx
55
GITLAB_CLIENT_SECRET=xxx
6-
GCS_ENDPOINT=http://localhost:4080
76
OTLP_ENDPOINT=http://localhost:4317
87
MODULES_BUCKET=modules
98
PUBLISHING_BUCKET=publishing

api/.sqlx/query-68d3663094b9cf79de357c436b8fa561176160d508e54868515c0f55bf4bd832.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/src/analysis.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use url::Url;
4646
use crate::db::DependencyKind;
4747
use crate::db::ExportsMap;
4848
use crate::db::PackageVersionMeta;
49-
use crate::gcs_paths;
5049
use crate::ids::PackageName;
5150
use crate::ids::PackagePath;
5251
use crate::ids::ScopeName;
@@ -56,6 +55,7 @@ use crate::npm::NpmTarballFiles;
5655
use crate::npm::NpmTarballOptions;
5756
use crate::npm::create_npm_tarball;
5857
use crate::s3::BucketWithQueue;
58+
use crate::s3_paths;
5959
use crate::tarball::PublishError;
6060

6161
pub struct PackageAnalysisData {
@@ -574,7 +574,7 @@ async fn rebuild_npm_tarball_inner(
574574
.build(
575575
roots.clone(),
576576
vec![],
577-
&GcsLoader {
577+
&S3Loader {
578578
files: &files,
579579
bucket: &modules_bucket,
580580
scope: &scope,
@@ -633,15 +633,15 @@ async fn rebuild_npm_tarball_inner(
633633
Ok(npm_tarball)
634634
}
635635

636-
struct GcsLoader<'a> {
636+
struct S3Loader<'a> {
637637
files: &'a HashSet<PackagePath>,
638638
bucket: &'a BucketWithQueue,
639639
scope: &'a ScopeName,
640640
name: &'a PackageName,
641641
version: &'a Version,
642642
}
643643

644-
impl GcsLoader<'_> {
644+
impl S3Loader<'_> {
645645
fn load_inner(
646646
&self,
647647
specifier: &ModuleSpecifier,
@@ -655,12 +655,12 @@ impl GcsLoader<'_> {
655655
if !self.files.contains(&path) {
656656
return async move { Ok(None) }.boxed();
657657
};
658-
let gcs_path =
659-
gcs_paths::file_path(self.scope, self.name, self.version, &path);
658+
let s3_path =
659+
s3_paths::file_path(self.scope, self.name, self.version, &path);
660660
let bucket = self.bucket.clone();
661661
async move {
662662
let Some(bytes) = bucket
663-
.download(gcs_path.into())
663+
.download(s3_path.into())
664664
.await
665665
.map_err(|e| LoadError::Other(Arc::new(JsErrorBox::from_err(e))))?
666666
else {
@@ -691,7 +691,7 @@ impl GcsLoader<'_> {
691691
}
692692
}
693693

694-
impl deno_graph::source::Loader for GcsLoader<'_> {
694+
impl deno_graph::source::Loader for S3Loader<'_> {
695695
fn load(
696696
&self,
697697
specifier: &ModuleSpecifier,

api/src/api/admin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2024 the JSR authors. All rights reserved. MIT license.
22
use crate::NpmUrl;
33
use crate::RegistryUrl;
4-
use crate::buckets::Buckets;
54
use crate::external::orama::OramaClient;
5+
use crate::s3::Buckets;
66
use hyper::Body;
77
use hyper::Request;
88
use routerify::Router;

api/src/api/errors.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::borrow::Cow;
55

66
use super::ApiPublishingTask;
77
use crate::errors;
8-
use crate::gcp::GcsError;
98
use crate::s3::S3Error;
109

1110
errors!(
@@ -400,12 +399,6 @@ impl
400399
}
401400
}
402401

403-
impl From<GcsError> for ApiError {
404-
fn from(error: GcsError) -> ApiError {
405-
anyhow::Error::from(error).into()
406-
}
407-
}
408-
409402
impl From<crate::docs::DocNodeCacheError> for ApiError {
410403
fn from(error: crate::docs::DocNodeCacheError) -> ApiError {
411404
anyhow::Error::from(error).into()

api/src/api/package.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ use crate::RegistryUrl;
5353
use crate::analysis::JsrResolver;
5454
use crate::analysis::ModuleParser;
5555
use crate::auth;
56-
use crate::buckets::Buckets;
5756
use crate::db::CreatePackageResult;
5857
use crate::db::CreatePublishingTaskResult;
5958
use crate::db::Database;
@@ -66,8 +65,6 @@ use crate::docs::DocsRequest;
6665
use crate::docs::GeneratedDocsOutput;
6766
use crate::external::orama::OramaClient;
6867
use crate::gcp;
69-
use crate::gcp::CACHE_CONTROL_DO_NOT_CACHE;
70-
use crate::gcp::GcsUploadOptions;
7168
use crate::iam::ReqIamExt;
7269
use crate::ids::PackageName;
7370
use crate::ids::PackagePath;
@@ -78,6 +75,9 @@ use crate::metadata::VersionMetadata;
7875
use crate::npm::generate_npm_version_manifest;
7976
use crate::provenance;
8077
use crate::publish::publish_task;
78+
use crate::s3::Buckets;
79+
use crate::s3::CACHE_CONTROL_DO_NOT_CACHE;
80+
use crate::s3::S3UploadOptions;
8181
use crate::s3::UploadTaskBody;
8282
use crate::tarball::bucket_tarball_path;
8383
use crate::util;
@@ -615,7 +615,7 @@ async fn update_description(
615615
}
616616

617617
let npm_version_manifest_path =
618-
crate::gcs_paths::npm_version_manifest_path(scope, &package.name);
618+
crate::s3_paths::npm_version_manifest_path(scope, &package.name);
619619
let npm_version_manifest =
620620
generate_npm_version_manifest(db, npm_url, scope, &package.name).await?;
621621
let content = serde_json::to_vec_pretty(&npm_version_manifest)?;
@@ -624,7 +624,7 @@ async fn update_description(
624624
.upload(
625625
npm_version_manifest_path.into(),
626626
crate::s3::UploadTaskBody::Bytes(content.into()),
627-
GcsUploadOptions {
627+
S3UploadOptions {
628628
content_type: Some("application/json".into()),
629629
cache_control: Some(CACHE_CONTROL_DO_NOT_CACHE.into()),
630630
gzip_encoded: false,
@@ -898,7 +898,7 @@ pub async fn version_publish_handler(
898898
}
899899
};
900900

901-
let gcs_path = bucket_tarball_path(publishing_task.id);
901+
let s3_path = bucket_tarball_path(publishing_task.id);
902902

903903
let body = req.into_body();
904904
let total_size = Arc::new(AtomicU64::new(0));
@@ -923,9 +923,9 @@ pub async fn version_publish_handler(
923923
let upload_result = buckets
924924
.publishing_bucket
925925
.upload(
926-
gcs_path.into(),
926+
s3_path.into(),
927927
crate::s3::UploadTaskBody::Stream(Box::new(stream)),
928-
GcsUploadOptions {
928+
S3UploadOptions {
929929
content_type: Some("application/x-tar".into()),
930930
cache_control: None,
931931
gzip_encoded: true,
@@ -1063,7 +1063,7 @@ pub async fn version_update_handler(
10631063
.await?;
10641064

10651065
let package_metadata_path =
1066-
crate::gcs_paths::package_metadata(&scope, &package);
1066+
crate::s3_paths::package_metadata(&scope, &package);
10671067
let package_metadata = PackageMetadata::create(db, &scope, &package).await?;
10681068

10691069
let content = serde_json::to_vec(&package_metadata)?;
@@ -1072,7 +1072,7 @@ pub async fn version_update_handler(
10721072
.upload(
10731073
package_metadata_path.into(),
10741074
UploadTaskBody::Bytes(content.into()),
1075-
GcsUploadOptions {
1075+
S3UploadOptions {
10761076
content_type: Some("application/json".into()),
10771077
cache_control: Some(CACHE_CONTROL_DO_NOT_CACHE.into()),
10781078
gzip_encoded: false,
@@ -1081,7 +1081,7 @@ pub async fn version_update_handler(
10811081
.await?;
10821082

10831083
let npm_version_manifest_path =
1084-
crate::gcs_paths::npm_version_manifest_path(&scope, &package);
1084+
crate::s3_paths::npm_version_manifest_path(&scope, &package);
10851085
let npm_version_manifest =
10861086
generate_npm_version_manifest(db, npm_url, &scope, &package).await?;
10871087
let content = serde_json::to_vec_pretty(&npm_version_manifest)?;
@@ -1090,7 +1090,7 @@ pub async fn version_update_handler(
10901090
.upload(
10911091
npm_version_manifest_path.into(),
10921092
crate::s3::UploadTaskBody::Bytes(content.into()),
1093-
GcsUploadOptions {
1093+
S3UploadOptions {
10941094
content_type: Some("application/json".into()),
10951095
cache_control: Some(CACHE_CONTROL_DO_NOT_CACHE.into()),
10961096
gzip_encoded: false,
@@ -1143,20 +1143,20 @@ pub async fn version_delete_handler(
11431143
db.delete_package_version(&staff.id, &scope, &package, &version)
11441144
.await?;
11451145

1146-
let v1_path = crate::gcs_paths::docs_v1_path(&scope, &package, &version);
1147-
let v2_path = crate::gcs_paths::docs_v2_path(&scope, &package, &version);
1146+
let v1_path = crate::s3_paths::docs_v1_path(&scope, &package, &version);
1147+
let v2_path = crate::s3_paths::docs_v2_path(&scope, &package, &version);
11481148
buckets.docs_bucket.delete_file(v1_path.into()).await?;
11491149
buckets.docs_bucket.delete_file(v2_path.into()).await?;
11501150

1151-
let path = crate::gcs_paths::version_metadata(&scope, &package, &version);
1151+
let path = crate::s3_paths::version_metadata(&scope, &package, &version);
11521152
buckets.modules_bucket.delete_file(path.into()).await?;
11531153

11541154
let path =
1155-
crate::gcs_paths::file_path_root_directory(&scope, &package, &version);
1155+
crate::s3_paths::file_path_root_directory(&scope, &package, &version);
11561156
buckets.modules_bucket.delete_directory(path.into()).await?;
11571157

11581158
let package_metadata_path =
1159-
crate::gcs_paths::package_metadata(&scope, &package);
1159+
crate::s3_paths::package_metadata(&scope, &package);
11601160
let package_metadata = PackageMetadata::create(db, &scope, &package).await?;
11611161

11621162
let content = serde_json::to_vec(&package_metadata)?;
@@ -1165,7 +1165,7 @@ pub async fn version_delete_handler(
11651165
.upload(
11661166
package_metadata_path.into(),
11671167
UploadTaskBody::Bytes(content.into()),
1168-
GcsUploadOptions {
1168+
S3UploadOptions {
11691169
content_type: Some("application/json".into()),
11701170
cache_control: Some(CACHE_CONTROL_DO_NOT_CACHE.into()),
11711171
gzip_encoded: false,
@@ -1174,7 +1174,7 @@ pub async fn version_delete_handler(
11741174
.await?;
11751175

11761176
let npm_version_manifest_path =
1177-
crate::gcs_paths::npm_version_manifest_path(&scope, &package);
1177+
crate::s3_paths::npm_version_manifest_path(&scope, &package);
11781178
let npm_version_manifest =
11791179
generate_npm_version_manifest(db, npm_url, &scope, &package).await?;
11801180
let content = serde_json::to_vec_pretty(&npm_version_manifest)?;
@@ -1183,7 +1183,7 @@ pub async fn version_delete_handler(
11831183
.upload(
11841184
npm_version_manifest_path.into(),
11851185
crate::s3::UploadTaskBody::Bytes(content.into()),
1186-
GcsUploadOptions {
1186+
S3UploadOptions {
11871187
content_type: Some("application/json".into()),
11881188
cache_control: Some(CACHE_CONTROL_DO_NOT_CACHE.into()),
11891189
gzip_encoded: false,
@@ -1296,14 +1296,14 @@ pub async fn get_docs_handler(
12961296
&& version.readme_path.is_some();
12971297

12981298
let readme_fut = if has_readme {
1299-
let gcs_path = crate::gcs_paths::file_path(
1299+
let s3_path = crate::s3_paths::file_path(
13001300
&scope,
13011301
&package_name,
13021302
&version.version,
13031303
version.readme_path.as_ref().unwrap(),
13041304
)
13051305
.into();
1306-
Either::Left(buckets.modules_bucket.download(gcs_path))
1306+
Either::Left(buckets.modules_bucket.download(s3_path))
13071307
} else {
13081308
Either::Right(futures::future::ready(Ok(None)))
13091309
};
@@ -1578,14 +1578,14 @@ pub async fn get_source_handler(
15781578
let version = maybe_version.ok_or(ApiError::PackageVersionNotFound)?;
15791579

15801580
let file = if path == "meta.json" {
1581-
let source_file_path = crate::gcs_paths::package_metadata(&scope, &package);
1581+
let source_file_path = crate::s3_paths::package_metadata(&scope, &package);
15821582
buckets
15831583
.modules_bucket
15841584
.download(source_file_path.into())
15851585
.await?
15861586
} else if path == format!("{}_meta.json", version.version) {
15871587
let source_file_path =
1588-
crate::gcs_paths::version_metadata(&scope, &package, &version.version);
1588+
crate::s3_paths::version_metadata(&scope, &package, &version.version);
15891589
buckets
15901590
.modules_bucket
15911591
.download(source_file_path.into())
@@ -1596,7 +1596,7 @@ pub async fn get_source_handler(
15961596
ApiError::MalformedRequest { msg }
15971597
})?;
15981598

1599-
let source_file_path = crate::gcs_paths::file_path(
1599+
let source_file_path = crate::s3_paths::file_path(
16001600
&scope,
16011601
&package,
16021602
&version.version,
@@ -2047,7 +2047,7 @@ impl DepTreeLoader {
20472047
async move {
20482048
let Some(bytes) = bucket
20492049
.download(
2050-
crate::gcs_paths::file_path(&scope, &package, &version, &path)
2050+
crate::s3_paths::file_path(&scope, &package, &version, &path)
20512051
.into(),
20522052
)
20532053
.await
@@ -2556,11 +2556,11 @@ pub async fn get_dependencies_graph_handler(
25562556
Span::current().record("version", field::display(&version));
25572557

25582558
let buckets = req.data::<Buckets>().unwrap().clone();
2559-
let gcs_path =
2560-
crate::gcs_paths::version_metadata(&scope, &package, &version).into();
2559+
let s3_path =
2560+
crate::s3_paths::version_metadata(&scope, &package, &version).into();
25612561
let version_meta = buckets
25622562
.modules_bucket
2563-
.download(gcs_path)
2563+
.download(s3_path)
25642564
.await?
25652565
.ok_or(ApiError::PackageVersionNotFound)?;
25662566
let version_meta = serde_json::from_slice::<VersionMetadata>(&version_meta)?;

0 commit comments

Comments
 (0)