Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.

Commit 9874247

Browse files
committed
reintroduce dist-server
dist-worker was not correct
1 parent 4428260 commit 9874247

File tree

11 files changed

+72
-72
lines changed

11 files changed

+72
-72
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ jobs:
192192
include:
193193
- os: ubuntu-20.04
194194
target: x86_64-unknown-linux-musl
195-
extra_args: --features="dist-worker"
195+
extra_args: --features="dist-server"
196196
- os: ubuntu-20.04
197197
binary: cachepot-dist
198-
extra_args: --features="dist-worker"
198+
extra_args: --features="dist-server"
199199
target: x86_64-unknown-linux-musl
200200
- os: ubuntu-20.04
201201
target: aarch64-unknown-linux-musl

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ path = "src/main.rs"
2222

2323
[[bin]]
2424
name = "cachepot-dist"
25-
required-features = ["dist-worker"]
25+
required-features = ["dist-server"]
2626
path = "src/bin/cachepot-dist/main.rs"
2727

2828
[dependencies]
@@ -96,7 +96,7 @@ zstd = "0.6"
9696
structopt = "0.3.25"
9797
strum = { version = "0.23.0", features = ["derive"] }
9898

99-
# dist-worker only
99+
# dist-server only
100100
crossbeam-utils = { version = "0.8", optional = true }
101101
libmount = { version = "0.1.10", optional = true }
102102
nix = { version = "0.19", optional = true }
@@ -134,7 +134,7 @@ features = [
134134

135135
[features]
136136
default = ["all"]
137-
all = ["dist-worker", "dist-client", "redis", "s3", "memcached", "gcs", "azure"]
137+
all = ["dist-server", "dist-client", "redis", "s3", "memcached", "gcs", "azure"]
138138
azure = ["chrono", "hyper", "hyperx", "url", "hmac", "md-5", "sha2"]
139139
s3 = ["chrono", "hyper", "hyper-tls", "hyperx", "reqwest", "rusoto_core", "rusoto_s3", "hmac", "sha-1"]
140140
gcs = ["chrono", "hyper", "hyperx", "percent-encoding", "reqwest", "ring", "untrusted", "url"]
@@ -145,11 +145,11 @@ unstable = []
145145
# Enables distributed support in the cachepot client
146146
dist-client = ["ar", "flate2", "hyper", "hyperx", "reqwest/stream", "url", "sha2", "tokio/fs"]
147147
# Enables the cachepot-dist binary
148-
dist-worker = ["chrono", "crossbeam-utils", "jsonwebtoken", "flate2", "hyperx", "libmount", "nix", "reqwest", "rouille", "sha2", "syslog", "void", "version-compare"]
148+
dist-server = ["chrono", "crossbeam-utils", "jsonwebtoken", "flate2", "hyperx", "libmount", "nix", "reqwest", "rouille", "sha2", "syslog", "void", "version-compare"]
149149
# Enables dist tests with external requirements
150-
dist-tests = ["dist-client", "dist-worker"]
150+
dist-tests = ["dist-client", "dist-server"]
151151
# Run JWK token crypto against openssl ref impl
152-
vs_openssl = ["openssl", "dist-worker"]
152+
vs_openssl = ["openssl", "dist-server"]
153153

154154
# Make sure to always optimize big integer calculations as this cuts down
155155
# certificate generation time by two orders of magnitude (down to ~0.1s)

docs/book/src/dist/dist.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,5 +290,5 @@ certificate will be requested from the scheduler.
290290
Until these binaries [are included in releases](https://github.com/paritytech/cachepot/issues/393) I've put together a Docker container that can be used to easily build a release binary:
291291

292292
```toml
293-
docker run -ti --rm -v $PWD:/cachepot luser/cachepot-musl-build:0.1 /bin/bash -c "cd /cachepot; cargo build --release --target x86_64-unknown-linux-musl --features=dist-worker && strip target/x86_64-unknown-linux-musl/release/cachepot-dist && cd target/x86_64-unknown-linux-musl/release/ && tar czf cachepot-dist.tar.gz cachepot-dist"
293+
docker run -ti --rm -v $PWD:/cachepot luser/cachepot-musl-build:0.1 /bin/bash -c "cd /cachepot; cargo build --release --target x86_64-unknown-linux-musl --features=dist-server && strip target/x86_64-unknown-linux-musl/release/cachepot-dist && cd target/x86_64-unknown-linux-musl/release/ && tar czf cachepot-dist.tar.gz cachepot-dist"
294294
```

docs/book/src/dist/quickstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ macOS and Windows clients are supported but have seen significantly less testing
55

66
## Get cachepot binaries
77

8-
Either download pre-built cachepot binaries (not currently available), or build cachepot locally with the `dist-client` and `dist-worker` features enabled:
8+
Either download pre-built cachepot binaries (not currently available), or build cachepot locally with the `dist-client` and `dist-server` features enabled:
99

1010
```sh
11-
cargo build --release --features="dist-client dist-worker"
11+
cargo build --release --features="dist-client dist-server"
1212
```
1313

1414
The `target/release/cachepot` binary will be used on the client, and the `target/release/cachepot-dist` binary will be used on the scheduler and build server.

scripts/extratest.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,36 @@ wintarget() {
2424
# all-windows doesn't work as redis-rs build.rs has issues (checks for cfg!(unix))
2525

2626
if [ "$1" = checkall ]; then
27-
$CARGO check --target $target --all-targets --features 'all dist-client dist-worker dist-tests'
28-
$CARGO check --target $target --all-targets --features 'all dist-client dist-worker'
27+
$CARGO check --target $target --all-targets --features 'all dist-client dist-server dist-tests'
28+
$CARGO check --target $target --all-targets --features 'all dist-client dist-server'
2929
$CARGO check --target $target --all-targets --features 'all dist-client dist-tests'
30-
$CARGO check --target $target --all-targets --features 'all dist-worker dist-tests'
30+
$CARGO check --target $target --all-targets --features 'all dist-server dist-tests'
3131
$CARGO check --target $target --all-targets --features 'all dist-client'
32-
$CARGO check --target $target --all-targets --features 'all dist-worker'
32+
$CARGO check --target $target --all-targets --features 'all dist-server'
3333
$CARGO check --target $target --all-targets --features 'all dist-tests'
3434
$CARGO check --target $target --all-targets --features 'all'
35-
$CARGO check --target $target --all-targets --features 'dist-client dist-worker dist-tests'
36-
$CARGO check --target $target --all-targets --features 'dist-client dist-worker'
35+
$CARGO check --target $target --all-targets --features 'dist-client dist-server dist-tests'
36+
$CARGO check --target $target --all-targets --features 'dist-client dist-server'
3737
$CARGO check --target $target --all-targets --features 'dist-client dist-tests'
38-
$CARGO check --target $target --all-targets --features 'dist-worker dist-tests'
38+
$CARGO check --target $target --all-targets --features 'dist-server dist-tests'
3939
$CARGO check --target $target --all-targets --features 'dist-client'
40-
$CARGO check --target $target --all-targets --features 'dist-worker'
40+
$CARGO check --target $target --all-targets --features 'dist-server'
4141
$CARGO check --target $target --all-targets --features 'dist-tests'
4242
$CARGO check --target $target --all-targets --features ''
43-
$CARGO check --target $target --all-targets --no-default-features --features 'all dist-client dist-worker dist-tests'
44-
$CARGO check --target $target --all-targets --no-default-features --features 'all dist-client dist-worker'
43+
$CARGO check --target $target --all-targets --no-default-features --features 'all dist-client dist-server dist-tests'
44+
$CARGO check --target $target --all-targets --no-default-features --features 'all dist-client dist-server'
4545
$CARGO check --target $target --all-targets --no-default-features --features 'all dist-client dist-tests'
46-
$CARGO check --target $target --all-targets --no-default-features --features 'all dist-worker dist-tests'
46+
$CARGO check --target $target --all-targets --no-default-features --features 'all dist-server dist-tests'
4747
$CARGO check --target $target --all-targets --no-default-features --features 'all dist-client'
48-
$CARGO check --target $target --all-targets --no-default-features --features 'all dist-worker'
48+
$CARGO check --target $target --all-targets --no-default-features --features 'all dist-server'
4949
$CARGO check --target $target --all-targets --no-default-features --features 'all dist-tests'
5050
$CARGO check --target $target --all-targets --no-default-features --features 'all'
51-
$CARGO check --target $target --all-targets --no-default-features --features 'dist-client dist-worker dist-tests'
52-
$CARGO check --target $target --all-targets --no-default-features --features 'dist-client dist-worker'
51+
$CARGO check --target $target --all-targets --no-default-features --features 'dist-client dist-server dist-tests'
52+
$CARGO check --target $target --all-targets --no-default-features --features 'dist-client dist-server'
5353
$CARGO check --target $target --all-targets --no-default-features --features 'dist-client dist-tests'
54-
$CARGO check --target $target --all-targets --no-default-features --features 'dist-worker dist-tests'
54+
$CARGO check --target $target --all-targets --no-default-features --features 'dist-server dist-tests'
5555
$CARGO check --target $target --all-targets --no-default-features --features 'dist-client'
56-
$CARGO check --target $target --all-targets --no-default-features --features 'dist-worker'
56+
$CARGO check --target $target --all-targets --no-default-features --features 'dist-server'
5757
$CARGO check --target $target --all-targets --no-default-features --features 'dist-tests'
5858
$CARGO check --target $target --all-targets --no-default-features --features ''
5959
wintarget
@@ -89,7 +89,7 @@ elif [ "$1" = test ]; then
8989
fi
9090
set -x
9191

92-
RUST_BACKTRACE=1 $CARGO test $NORUN --target $target --features 'all dist-client dist-worker dist-tests' $VERBOSE -- $NOCAPTURE $TESTTHREADS test_dist_nobuilder
92+
RUST_BACKTRACE=1 $CARGO test $NORUN --target $target --features 'all dist-client dist-server dist-tests' $VERBOSE -- $NOCAPTURE $TESTTHREADS test_dist_nobuilder
9393

9494
else
9595
echo invalid command

src/config.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::util::fs::{self, File};
1616
use directories::ProjectDirs;
1717
use regex::Regex;
1818
use serde::de::{Deserialize, DeserializeOwned, Deserializer};
19-
#[cfg(any(feature = "dist-client", feature = "dist-worker"))]
19+
#[cfg(any(feature = "dist-client", feature = "dist-server"))]
2020
use serde::ser::{Serialize, Serializer};
2121
use std::collections::HashMap;
2222
use std::env;
@@ -88,10 +88,10 @@ pub fn parse_size(val: &str) -> Option<u64> {
8888
})
8989
}
9090

91-
#[cfg(any(feature = "dist-client", feature = "dist-worker"))]
91+
#[cfg(any(feature = "dist-client", feature = "dist-server"))]
9292
#[derive(Clone, Debug, PartialEq, Eq)]
9393
pub struct HTTPUrl(reqwest::Url);
94-
#[cfg(any(feature = "dist-client", feature = "dist-worker"))]
94+
#[cfg(any(feature = "dist-client", feature = "dist-server"))]
9595
impl Serialize for HTTPUrl {
9696
fn serialize<S>(&self, serializer: S) -> StdResult<S::Ok, S::Error>
9797
where
@@ -100,7 +100,7 @@ impl Serialize for HTTPUrl {
100100
serializer.serialize_str(self.0.as_str())
101101
}
102102
}
103-
#[cfg(any(feature = "dist-client", feature = "dist-worker"))]
103+
#[cfg(any(feature = "dist-client", feature = "dist-server"))]
104104
impl<'a> Deserialize<'a> for HTTPUrl {
105105
fn deserialize<D>(deserializer: D) -> StdResult<Self, D::Error>
106106
where
@@ -112,7 +112,7 @@ impl<'a> Deserialize<'a> for HTTPUrl {
112112
Ok(HTTPUrl(url))
113113
}
114114
}
115-
#[cfg(any(feature = "dist-client", feature = "dist-worker"))]
115+
#[cfg(any(feature = "dist-client", feature = "dist-server"))]
116116
fn parse_http_url(url: &str) -> Result<reqwest::Url> {
117117
use std::net::SocketAddr;
118118
let url = if let Ok(sa) = url.parse::<SocketAddr>() {
@@ -130,7 +130,7 @@ fn parse_http_url(url: &str) -> Result<reqwest::Url> {
130130
}
131131
Ok(url)
132132
}
133-
#[cfg(any(feature = "dist-client", feature = "dist-worker"))]
133+
#[cfg(any(feature = "dist-client", feature = "dist-server"))]
134134
impl HTTPUrl {
135135
pub fn from_url(u: reqwest::Url) -> Self {
136136
HTTPUrl(u)
@@ -379,9 +379,9 @@ impl Default for DistAuth {
379379
#[serde(deny_unknown_fields)]
380380
pub struct DistConfig {
381381
pub auth: DistAuth,
382-
#[cfg(any(feature = "dist-client", feature = "dist-worker"))]
382+
#[cfg(any(feature = "dist-client", feature = "dist-server"))]
383383
pub scheduler_url: Option<HTTPUrl>,
384-
#[cfg(not(any(feature = "dist-client", feature = "dist-worker")))]
384+
#[cfg(not(any(feature = "dist-client", feature = "dist-server")))]
385385
pub scheduler_url: Option<String>,
386386
pub cache_dir: PathBuf,
387387
pub toolchains: Vec<DistToolchainConfig>,
@@ -693,7 +693,7 @@ impl CachedConfig {
693693
}
694694
}
695695

696-
#[cfg(feature = "dist-worker")]
696+
#[cfg(feature = "dist-server")]
697697
pub mod scheduler {
698698
use std::net::SocketAddr;
699699
use std::path::Path;
@@ -748,7 +748,7 @@ pub mod scheduler {
748748
}
749749
}
750750

751-
#[cfg(feature = "dist-worker")]
751+
#[cfg(feature = "dist-server")]
752752
pub mod coordinator {
753753
use super::HTTPUrl;
754754
use std::net::SocketAddr;
@@ -972,13 +972,13 @@ public = false
972972
auth: DistAuth::Token {
973973
token: "secrettoken".to_owned()
974974
},
975-
#[cfg(any(feature = "dist-client", feature = "dist-worker"))]
975+
#[cfg(any(feature = "dist-client", feature = "dist-server"))]
976976
scheduler_url: Some(
977977
parse_http_url("http://1.2.3.4:10600")
978978
.map(|url| { HTTPUrl::from_url(url) })
979979
.expect("Scheduler url must be valid url str")
980980
),
981-
#[cfg(not(any(feature = "dist-client", feature = "dist-worker")))]
981+
#[cfg(not(any(feature = "dist-client", feature = "dist-server")))]
982982
scheduler_url: Some("http://1.2.3.4:10600".to_owned()),
983983
cache_dir: PathBuf::from("/home/user/.cache/cachepot-dist-client"),
984984
toolchains: vec![],

src/dist/http.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
// limitations under the License.
1414
#[cfg(feature = "dist-client")]
1515
pub use self::client::Client;
16-
#[cfg(feature = "dist-worker")]
16+
#[cfg(feature = "dist-server")]
1717
pub use self::worker::Worker;
18-
#[cfg(feature = "dist-worker")]
18+
#[cfg(feature = "dist-server")]
1919
pub use self::worker::{
2020
CoordinatorAuthCheck, CoordinatorVisibleMsg, Scheduler, WorkerAuthCheck, HEARTBEAT_TIMEOUT,
2121
};
2222

2323
mod common {
24-
#[cfg(any(feature = "dist-client", feature = "dist-worker"))]
24+
#[cfg(any(feature = "dist-client", feature = "dist-server"))]
2525
use hyperx::header;
26-
#[cfg(feature = "dist-worker")]
26+
#[cfg(feature = "dist-server")]
2727
use std::collections::HashMap;
2828
use std::fmt;
2929

@@ -69,7 +69,7 @@ mod common {
6969
}
7070
}
7171

72-
#[cfg(feature = "dist-worker")]
72+
#[cfg(feature = "dist-server")]
7373
pub fn bincode_req<T: serde::de::DeserializeOwned + 'static>(
7474
req: reqwest::blocking::RequestBuilder,
7575
) -> Result<T> {
@@ -136,7 +136,7 @@ mod common {
136136
},
137137
}
138138
impl AllocJobHttpResponse {
139-
#[cfg(feature = "dist-worker")]
139+
#[cfg(feature = "dist-server")]
140140
pub fn from_alloc_job_result(
141141
res: dist::AllocJobResult,
142142
certs: &HashMap<dist::WorkerId, (Vec<u8>, Vec<u8>)>,
@@ -264,7 +264,7 @@ pub mod urls {
264264
}
265265
}
266266

267-
#[cfg(feature = "dist-worker")]
267+
#[cfg(feature = "dist-server")]
268268
mod worker {
269269
use crate::jwt;
270270
use byteorder::{BigEndian, ReadBytesExt};

src/dist/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ use std::net::SocketAddr;
2121
use std::path::{Path, PathBuf};
2222
use std::process;
2323
use std::str::FromStr;
24-
#[cfg(feature = "dist-worker")]
24+
#[cfg(feature = "dist-server")]
2525
use std::sync::Mutex;
2626

2727
use crate::errors::*;
2828

29-
#[cfg(any(feature = "dist-client", feature = "dist-worker"))]
29+
#[cfg(any(feature = "dist-client", feature = "dist-server"))]
3030
mod cache;
3131
#[cfg(feature = "dist-client")]
3232
pub mod client_auth;
33-
#[cfg(any(feature = "dist-client", feature = "dist-worker"))]
33+
#[cfg(any(feature = "dist-client", feature = "dist-server"))]
3434
pub mod http;
3535
#[cfg(test)]
3636
mod test;
3737

38-
#[cfg(any(feature = "dist-client", feature = "dist-worker"))]
38+
#[cfg(any(feature = "dist-client", feature = "dist-server"))]
3939
pub use crate::dist::cache::TcCache;
4040

4141
// TODO: paths (particularly outputs, which are accessed by an unsandboxed program)
@@ -472,7 +472,7 @@ impl From<ProcessOutput> for process::Output {
472472
#[serde(deny_unknown_fields)]
473473
pub struct OutputData(Vec<u8>, u64);
474474
impl OutputData {
475-
#[cfg(any(feature = "dist-worker", all(feature = "dist-client", test)))]
475+
#[cfg(any(feature = "dist-server", all(feature = "dist-client", test)))]
476476
pub fn try_from_reader<R: Read>(r: R) -> io::Result<Self> {
477477
use flate2::read::ZlibEncoder as ZlibReadEncoder;
478478
use flate2::Compression;
@@ -619,10 +619,10 @@ impl<'a> Read for InputsReader<'a> {
619619
}
620620
}
621621

622-
#[cfg(feature = "dist-worker")]
622+
#[cfg(feature = "dist-server")]
623623
type ExtResult<T, E> = ::std::result::Result<T, E>;
624624

625-
#[cfg(feature = "dist-worker")]
625+
#[cfg(feature = "dist-server")]
626626
pub trait SchedulerOutgoing {
627627
// To Server
628628
fn do_assign_job(
@@ -634,20 +634,20 @@ pub trait SchedulerOutgoing {
634634
) -> Result<AssignJobResult>;
635635
}
636636

637-
#[cfg(feature = "dist-worker")]
637+
#[cfg(feature = "dist-server")]
638638
pub trait ServerOutgoing {
639639
// To Scheduler
640640
fn do_update_job_state(&self, job_id: JobId, state: JobState) -> Result<UpdateJobStateResult>;
641641
}
642642

643643
// Trait to handle the creation and verification of job authorization tokens
644-
#[cfg(feature = "dist-worker")]
644+
#[cfg(feature = "dist-server")]
645645
pub trait JobAuthorizer: Send {
646646
fn generate_token(&self, job_id: JobId) -> Result<String>;
647647
fn verify_token(&self, job_id: JobId, token: &str) -> Result<()>;
648648
}
649649

650-
#[cfg(feature = "dist-worker")]
650+
#[cfg(feature = "dist-server")]
651651
pub trait SchedulerIncoming: Send + Sync {
652652
// From Client
653653
fn handle_alloc_job(
@@ -674,7 +674,7 @@ pub trait SchedulerIncoming: Send + Sync {
674674
fn handle_status(&self) -> ExtResult<SchedulerStatusResult, Error>;
675675
}
676676

677-
#[cfg(feature = "dist-worker")]
677+
#[cfg(feature = "dist-server")]
678678
pub trait WorkerIncoming: Send + Sync {
679679
// From Scheduler
680680
fn handle_assign_job(&self, job_id: JobId, tc: Toolchain) -> ExtResult<AssignJobResult, Error>;
@@ -696,7 +696,7 @@ pub trait WorkerIncoming: Send + Sync {
696696
) -> ExtResult<RunJobResult, Error>;
697697
}
698698

699-
#[cfg(feature = "dist-worker")]
699+
#[cfg(feature = "dist-server")]
700700
pub trait BuilderIncoming: Send + Sync {
701701
// From Server
702702
fn run_build(

systemd/Dockerfile.build.cachepot-dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN cd /bubblewrap-0.3.1 && \
1111
FROM rust:1.52-buster as cachepot-build
1212
RUN git clone https://github.com/paritytech/cachepot.git --depth=1 && \
1313
cd cachepot && \
14-
cargo build --bin cachepot-dist --release --features="dist-worker"
14+
cargo build --bin cachepot-dist --release --features="dist-server"
1515

1616
FROM ubuntu:20.04
1717
RUN apt-get update && \

tests/dist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(all(feature = "dist-client", feature = "dist-worker"))]
1+
#![cfg(all(feature = "dist-client", feature = "dist-server"))]
22

33
extern crate assert_cmd;
44
#[macro_use]

0 commit comments

Comments
 (0)