Skip to content

Commit

Permalink
Added implementation for Google Cloud Store
Browse files Browse the repository at this point in the history
  • Loading branch information
amankrx committed Jan 10, 2025
1 parent b1df876 commit 0b456d3
Show file tree
Hide file tree
Showing 10 changed files with 2,411 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ bazel-*
target/
.vscode/
.zed
.idea/
.cache
.terraform*
.config
Expand Down
53 changes: 53 additions & 0 deletions Cargo.lock

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

168 changes: 168 additions & 0 deletions nativelink-config/examples/gcs_backend.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
{
"stores": {
"CAS_MAIN_STORE": {
"verify": {
"backend": {
"dedup": {
"index_store": {
"fast_slow": {
"fast": {
"filesystem": {
"content_path": "/tmp/nativelink/data/content_path-index",
"temp_path": "/tmp/nativelink/data/tmp_path-index",
"eviction_policy": {
// 500mb.
"max_bytes": 500000000
}
}
},
"slow": {
"experimental_gcs_store": {
"project_id": "inbound-entity-447014-k2",
"bucket": "test-bucket-aman-nativelink",
"key_prefix": "test-prefix-index/",
"retry": {
"max_retries": 6,
"delay": 0.3,
"jitter": 0.5
},
"max_concurrent_uploads": 10
}
}
}
},
"content_store": {
"compression": {
"compression_algorithm": {
"lz4": {}
},
"backend": {
"fast_slow": {
"fast": {
"filesystem": {
"content_path": "/tmp/nativelink/data/content_path-content",
"temp_path": "/tmp/nativelink/data/tmp_path-content",
"eviction_policy": {
"max_bytes": 2000000000
}
}
},
"slow": {
"experimental_gcs_store": {
"project_id": "inbound-entity-447014-k2",
"bucket": "test-bucket-aman-nativelink",
"key_prefix": "test-prefix-dedup-cas/",
"retry": {
"max_retries": 6,
"delay": 0.3,
"jitter": 0.5
},
"max_concurrent_uploads": 10
}
}
}
}
}
}
}
},
"verify_size": true
}
},
"AC_MAIN_STORE": {
"fast_slow": {
"fast": {
"memory": {
"eviction_policy": {
"max_bytes": 100000000
}
},
"filesystem": {
"content_path": "/tmp/nativelink/data/content_path-ac",
"temp_path": "/tmp/nativelink/data/tmp_path-ac",
"eviction_policy": {
// 500mb.
"max_bytes": 500000000
}
}
},
"slow": {
"experimental_gcs_store": {
"project_id": "inbound-entity-447014-k2",
// Name of the bucket to upload to.
"bucket": "test-bucket-aman-nativelink",
"key_prefix": "test-prefix-ac/",
"retry": {
"max_retries": 6,
"delay": 0.3,
"jitter": 0.5
},
"max_concurrent_uploads": 10
}
}
}
},
},
"schedulers": {
"MAIN_SCHEDULER": {
"simple": {
"supported_platform_properties": {
"cpu_count": "minimum",
"memory_kb": "minimum",
"network_kbps": "minimum",
"disk_read_iops": "minimum",
"disk_read_bps": "minimum",
"disk_write_iops": "minimum",
"disk_write_bps": "minimum",
"shm_size": "minimum",
"gpu_count": "minimum",
"gpu_model": "exact",
"cpu_vendor": "exact",
"cpu_arch": "exact",
"cpu_model": "exact",
"kernel_version": "exact",
"docker_image": "priority",
"lre-rs": "priority"
}
}
}
},
"servers": [{
"listener": {
"http": {
"socket_address": "0.0.0.0:50051"
}
},
"services": {
"cas": {
"main": {
"cas_store": "CAS_MAIN_STORE"
}
},
"ac": {
"main": {
"ac_store": "AC_MAIN_STORE"
}
},
"execution": {
"main": {
"cas_store": "CAS_MAIN_STORE",
"scheduler": "MAIN_SCHEDULER"
}
},
"capabilities": {
"main": {
"remote_execution": {
"scheduler": "MAIN_SCHEDULER"
}
}
},
"bytestream": {
"cas_stores": {
"main": "CAS_MAIN_STORE"
}
},
"health": {}
}
}]
}
93 changes: 93 additions & 0 deletions nativelink-config/src/stores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ pub enum StoreSpec {
///
experimental_s3_store(S3Spec),

/// GCS store will use Google's GCS service as a backend to store
/// the files. This configuration can be used to share files
/// across multiple instances.
///
/// **Example JSON Config:**
/// ```json
/// "experimental_gcs_store": {
/// "project_id": "sample-project",
/// "bucket": "test-bucket",
/// "key_prefix": "test-prefix-index/",
/// "retry": {
/// "max_retries": 6,
/// "delay": 0.3,
/// "jitter": 0.5
/// },
/// "max_concurrent_uploads": 10
/// }
/// ```
///
experimental_gcs_store(GcsSpec),

/// Verify store is used to apply verifications to an underlying
/// store implementation. It is strongly encouraged to validate
/// as much data as you can before accepting data from a client,
Expand Down Expand Up @@ -787,6 +808,78 @@ pub struct S3Spec {
pub disable_http2: bool,
}

#[derive(Serialize, Deserialize, Debug, Default, Clone)]
#[serde(deny_unknown_fields)]
pub struct GcsSpec {
/// Project ID for the GCS service
#[serde(default, deserialize_with = "convert_string_with_shellexpand")]
pub project_id: String,

/// Bucket name to use as the backend
#[serde(default, deserialize_with = "convert_string_with_shellexpand")]
pub bucket: String,

/// If you wish to prefix the location in GCS. If None, no prefix will be used.
#[serde(default)]
pub key_prefix: Option<String>,

/// Retry configuration to use when a network request fails.
#[serde(default)]
pub retry: Retry,

/// If the number of seconds since the `last_modified` time of the object
/// is greater than this value, the object will not be considered
/// "existing". This allows for external tools to delete objects that
/// have not been uploaded in a long time. If a client receives a `NotFound`
/// the client should re-upload the object.
///
/// There should be sufficient buffer time between how long the expiration
/// configuration of the external tool is and this value. Keeping items
/// around for a few days is generally a good idea.
///
/// Default: 0. Zero means never consider an object expired.
#[serde(default, deserialize_with = "convert_duration_with_shellexpand")]
pub consider_expired_after_s: u32,

/// The maximum buffer size to retain in case of a retryable error
/// during upload. Setting this to zero will disable upload buffering;
/// this means that in the event of a failure during upload, the entire
/// upload will be aborted and the client will likely receive an error.
///
/// Default: 5MB.
pub max_retry_buffer_per_request: Option<usize>,

/// Size of chunks for resumeable uploads (in bytes).
/// Must be a multiple of 256 KB.
///
/// Default: 8MB.
pub resumable_chunk_size: Option<usize>,

/// Maximum number of concurrent uploads for resumable operations
///
/// Default: 10.
pub max_concurrent_uploads: Option<usize>,

/// Optional endpoint override for testing
/// Example: "localhost:8080" for local development
///
/// Default: None (uses production GCS endpoint)
#[serde(default)]
pub endpoint: Option<String>,

/// Allow unencrypted HTTP connections. Only use this for local testing.
///
/// Default: false
#[serde(default)]
pub insecure_allow_http: bool,

/// Disable http/2 connections and only use http/1.1.
///
/// Default: false
#[serde(default)]
pub disable_http2: bool,
}

#[allow(non_camel_case_types)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
pub enum StoreType {
Expand Down
Loading

0 comments on commit 0b456d3

Please sign in to comment.