Skip to content

Commit

Permalink
Make stores and schedulers lists of named specs (#1496)
Browse files Browse the repository at this point in the history
To migrate, change your config like this (similar for schedulers):

```
// Old:
"stores": {
  "SOMESTORE": {
    "memory": {}
  }
}

// New:
"stores": [
  {
    "name": "SOMESTORE",
    "memory": {}
  }
]
```

For now this is not a breaking change, but a backwards compatible one.
The backwards-compatibility code will be removed after the next release
in a breaking change.

Closes #834
  • Loading branch information
aaronmondal authored Jan 29, 2025
1 parent a67d4bd commit c99dca6
Show file tree
Hide file tree
Showing 16 changed files with 303 additions and 87 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

11 changes: 6 additions & 5 deletions deployment-examples/docker-compose/local-storage-cas.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
// so objects are compressed, deduplicated and uses some in-memory
// optimizations for certain hot paths.
{
"stores": {
"CAS_MAIN_STORE": {
"stores": [
{
"name": "CAS_MAIN_STORE",
"compression": {
"compression_algorithm": {
"lz4": {}
Expand All @@ -21,8 +22,8 @@
}
}
}
},
"AC_MAIN_STORE": {
}, {
"name": "AC_MAIN_STORE",
"filesystem": {
"content_path": "~/.cache/nativelink/content_path-ac",
"temp_path": "~/.cache/nativelink/tmp_path-ac",
Expand All @@ -32,7 +33,7 @@
}
}
}
},
],
"servers": [{
"listener": {
"http": {
Expand Down
18 changes: 10 additions & 8 deletions deployment-examples/docker-compose/scheduler.json5
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"stores": {
"GRPC_LOCAL_STORE": {
"stores": [
{
"name": "GRPC_LOCAL_STORE",
// Note: This file is used to test GRPC store.
"grpc": {
"instance_name": "",
Expand All @@ -9,8 +10,8 @@
],
"store_type": "cas"
}
},
"GRPC_LOCAL_AC_STORE": {
}, {
"name": "GRPC_LOCAL_AC_STORE",
// Note: This file is used to test GRPC store.
"grpc": {
"instance_name": "",
Expand All @@ -20,9 +21,10 @@
"store_type": "ac"
}
}
},
"schedulers": {
"MAIN_SCHEDULER": {
],
"schedulers": [
{
"name": "MAIN_SCHEDULER",
"simple": {
"supported_platform_properties": {
"cpu_count": "minimum",
Expand All @@ -32,7 +34,7 @@
}
}
}
},
],
"servers": [{
"listener": {
"http": {
Expand Down
15 changes: 8 additions & 7 deletions deployment-examples/docker-compose/worker.json5
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"stores": {
"GRPC_LOCAL_STORE": {
"stores": [
{
"name": "GRPC_LOCAL_STORE",
// Note: This file is used to test GRPC store.
"grpc": {
"instance_name": "",
Expand All @@ -9,8 +10,8 @@
],
"store_type": "cas"
}
},
"GRPC_LOCAL_AC_STORE": {
}, {
"name": "GRPC_LOCAL_AC_STORE",
// Note: This file is used to test GRPC store.
"grpc": {
"instance_name": "",
Expand All @@ -19,8 +20,8 @@
],
"store_type": "ac"
}
},
"WORKER_FAST_SLOW_STORE": {
}, {
"name": "WORKER_FAST_SLOW_STORE",
"fast_slow": {
"fast": {
"filesystem": {
Expand All @@ -39,7 +40,7 @@
}
}
}
},
],
"workers": [{
"local": {
"worker_api_endpoint": {
Expand Down
15 changes: 8 additions & 7 deletions kubernetes/components/worker/worker.json5
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"stores": {
"GRPC_LOCAL_STORE": {
"stores": [
{
"name": "GRPC_LOCAL_STORE",
// Note: This file is used to test GRPC store.
"grpc": {
"instance_name": "",
Expand All @@ -9,8 +10,8 @@
],
"store_type": "cas"
}
},
"GRPC_LOCAL_AC_STORE": {
}, {
"name": "GRPC_LOCAL_AC_STORE",
// Note: This file is used to test GRPC store.
"grpc": {
"instance_name": "",
Expand All @@ -19,8 +20,8 @@
],
"store_type": "ac"
}
},
"WORKER_FAST_SLOW_STORE": {
}, {
"name": "WORKER_FAST_SLOW_STORE",
"fast_slow": {
"fast": {
"filesystem": {
Expand All @@ -38,7 +39,7 @@
}
}
}
},
],
"workers": [{
"local": {
"worker_api_endpoint": {
Expand Down
18 changes: 10 additions & 8 deletions kubernetes/nativelink/nativelink-config.json5
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// `~/.cache/nativelink`. When this location is mounted as a PersistentVolume
// it persists the cache across restarts.
{
"stores": {
"CAS_MAIN_STORE": {
"stores": [
{
"name": "CAS_MAIN_STORE",
"existence_cache": {
"backend": {
"compression": {
Expand All @@ -22,8 +23,8 @@
}
}
}
},
"AC_MAIN_STORE": {
}, {
"name": "AC_MAIN_STORE",
"completeness_checking": {
"backend": {
"filesystem": {
Expand All @@ -41,9 +42,10 @@
}
}
}
},
"schedulers": {
"MAIN_SCHEDULER": {
],
"schedulers": [
{
"name": "MAIN_SCHEDULER",
// TODO(adams): use the right scheduler because reclient doesn't use the cached results?
// TODO(adams): max_bytes_per_stream
"simple": {
Expand All @@ -68,7 +70,7 @@
}
}
}
},
],
"servers": [{
// Only publish metrics on a private port.
"listener": {
Expand Down
2 changes: 2 additions & 0 deletions nativelink-config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ rust_test_suite(
name = "integration",
timeout = "short",
srcs = [
"tests/backwards_compat_test.rs",
"tests/deserialization_test.rs",
],
deps = [
Expand All @@ -40,6 +41,7 @@ rust_test_suite(
"@crates//:humantime",
"@crates//:pretty_assertions",
"@crates//:serde",
"@crates//:serde_json",
"@crates//:serde_json5",
],
)
Expand Down
1 change: 1 addition & 0 deletions nativelink-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ shellexpand = { version = "3.1.0", default-features = false, features = ["base-0

[dev-dependencies]
pretty_assertions = { version = "1.4.1", features = ["std"] }
serde_json = { version = "1.0.138", default-features = false }
18 changes: 10 additions & 8 deletions nativelink-config/examples/basic_cas.json5
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"stores": {
"AC_MAIN_STORE": {
"stores": [
{
"name": "AC_MAIN_STORE",
"filesystem": {
"content_path": "/tmp/nativelink/data-worker-test/content_path-ac",
"temp_path": "/tmp/nativelink/data-worker-test/tmp_path-ac",
Expand All @@ -9,8 +10,8 @@
"max_bytes": 1000000000
}
}
},
"WORKER_FAST_SLOW_STORE": {
}, {
"name": "WORKER_FAST_SLOW_STORE",
"fast_slow": {
// "fast" must be a "filesystem" store because the worker uses it to make
// hardlinks on disk to a directory where the jobs are running.
Expand All @@ -34,9 +35,10 @@
}
}
}
},
"schedulers": {
"MAIN_SCHEDULER": {
],
"schedulers": [
{
"name": "MAIN_SCHEDULER",
"simple": {
"supported_platform_properties": {
"cpu_count": "minimum",
Expand All @@ -59,7 +61,7 @@
}
}
}
},
],
"workers": [{
"local": {
"worker_api_endpoint": {
Expand Down
22 changes: 12 additions & 10 deletions nativelink-config/examples/filesystem_cas.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
// so objects are compressed, deduplicated and uses some in-memory
// optimizations for certain hot paths.
{
"stores": {
"FS_CONTENT_STORE": {
"stores": [
{
"name": "FS_CONTENT_STORE",
"compression": {
"compression_algorithm": {
"lz4": {}
Expand All @@ -21,8 +22,8 @@
}
}
}
},
"CAS_MAIN_STORE": {
}, {
"name": "CAS_MAIN_STORE",
"verify": {
"backend": {
// Because we are using a dedup store, we can bypass small objects
Expand Down Expand Up @@ -78,8 +79,8 @@
"verify_size": true,
"verify_hash": true
}
},
"AC_MAIN_STORE": {
}, {
"name": "AC_MAIN_STORE",
"filesystem": {
"content_path": "/tmp/nativelink/data/content_path-ac",
"temp_path": "/tmp/nativelink/data/tmp_path-ac",
Expand All @@ -89,9 +90,10 @@
}
}
}
},
"schedulers": {
"MAIN_SCHEDULER": {
],
"schedulers": [
{
"name": "MAIN_SCHEDULER",
"simple": {
"supported_platform_properties": {
"cpu_count": "minimum",
Expand All @@ -113,7 +115,7 @@
}
}
}
},
],
"servers": [{
"listener": {
"http": {
Expand Down
19 changes: 10 additions & 9 deletions nativelink-config/examples/redis.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"stores": {
"CAS_FAST_SLOW_STORE": {
"stores": [
{
"name": "CAS_FAST_SLOW_STORE",
"redis_store": {
"addresses": ["redis://127.0.0.1:6379/"],
"mode": "cluster"
}
},
"AC_FAST_SLOW_STORE": {
}, {
"name": "AC_FAST_SLOW_STORE",
"redis_store": {
"addresses": ["redis://127.0.0.1:6379/"],
"mode": "cluster"
}
},
"AC_MAIN_STORE": {
}, {
"name": "AC_MAIN_STORE",
"completeness_checking": {
"backend": {
"ref_store": {
Expand All @@ -25,8 +26,8 @@
}
}
}
},
"CAS_MAIN_STORE": {
}, {
"name": "CAS_MAIN_STORE",
"existence_cache": {
"backend": {
"compression": {
Expand All @@ -42,7 +43,7 @@
}
}
}
},
],
"servers": [
{
"listener": {
Expand Down
Loading

0 comments on commit c99dca6

Please sign in to comment.