Skip to content

Commit d213c13

Browse files
authored
internal: Spilt app from linkerd2-proxy (#375)
* internal: internal: Spilt app from linkerd2-proxy The `linkerd2-proxy crate currently comprises the entirety of the application logic for the proxy. This unfortunately leads to exceedingly high compile times (35+ minutes to compile the application with tests). Specifically: * Any change to the inbound or outbound proxy configuration necessitated recompiling the other; and this compilation could not be parallelized. * Integration tests depended on the `linkerd2-proxy` executable, adding about 10 minutes to every build. * The tests/support module (which is also extremely costly to build) was compiled _for each integration test_. This change restructures the crates in this repository to allow `cargo` to cache intermediate code that was otherwise being compiled redundantly or serially: * The `linkerd2-proxy` crate now contains _only_ the executable and need not be built during tests. * The `linkerd2-app` crate exposes the app's `Main`, but uses `linkerd2-app-inbound` and `linkerd2-app-outbound` subcrates to improve parellization/cacheability. * The rest of the top-level application code * The `linkerd2-app-integration` crate now contains all of the integration test support code (as well as the tests themselves), so that the tests only need to compile the support library once. All in all, this reduces compile time to under 20 minutes.
1 parent b0c7181 commit d213c13

File tree

256 files changed

+1557
-1057
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+1557
-1057
lines changed

Cargo.lock

Lines changed: 283 additions & 72 deletions
Large diffs are not rendered by default.

Cargo.toml

Lines changed: 33 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,40 @@
11
[workspace]
22
members = [
3-
".",
4-
"lib/hyper-balance",
5-
"lib/linkerd2-addr",
6-
"lib/linkerd2-conditional",
7-
"lib/linkerd2-dns-name",
8-
"lib/linkerd2-drain",
9-
"lib/linkerd2-error",
10-
"lib/linkerd2-exp-backoff",
11-
"lib/linkerd2-fallback",
12-
"lib/linkerd2-identity",
13-
"lib/linkerd2-metrics",
14-
"lib/linkerd2-opencensus",
15-
"lib/linkerd2-proxy-api-resolve",
16-
"lib/linkerd2-proxy-core",
17-
"lib/linkerd2-proxy-discover",
18-
"lib/linkerd2-proxy-resolve",
19-
"lib/linkerd2-proxy-transport",
20-
"lib/linkerd2-request-filter",
21-
"lib/linkerd2-reconnect",
22-
"lib/linkerd2-router",
23-
"lib/linkerd2-signal",
24-
"lib/linkerd2-stack",
25-
"lib/linkerd2-task",
26-
"lib/linkerd2-timeout",
27-
"lib/opencensus-proto",
3+
"hyper-balance",
4+
"linkerd/addr",
5+
"linkerd/app/core",
6+
"linkerd/app/inbound",
7+
"linkerd/app/integration",
8+
"linkerd/app/outbound",
9+
"linkerd/app",
10+
"linkerd/conditional",
11+
"linkerd/dns/name",
12+
"linkerd/dns",
13+
"linkerd/drain",
14+
"linkerd/duplex",
15+
"linkerd/error",
16+
"linkerd/exp-backoff",
17+
"linkerd/fallback",
18+
"linkerd/identity",
19+
"linkerd/metrics",
20+
"linkerd/opencensus",
21+
"linkerd/proxy/api-resolve",
22+
"linkerd/proxy/core",
23+
"linkerd/proxy/discover",
24+
"linkerd/proxy/http",
25+
"linkerd/proxy/resolve",
26+
"linkerd/proxy/transport",
27+
"linkerd/request-filter",
28+
"linkerd/reconnect",
29+
"linkerd/router",
30+
"linkerd/signal",
31+
"linkerd/stack",
32+
"linkerd/task",
33+
"linkerd/timeout",
34+
"linkerd2-proxy",
35+
"opencensus-proto",
2836
]
2937

30-
[package]
31-
name = "linkerd2-proxy"
32-
version = "0.1.0"
33-
authors = ["Linkerd Developers <[email protected]>"]
34-
edition = "2018"
35-
publish = false
36-
37-
[features]
38-
default = ["flaky_tests"]
39-
# Disable to skip certain tests that should not be run on CI.
40-
flaky_tests = []
41-
42-
[dependencies]
43-
hyper-balance = { path = "lib/hyper-balance" }
44-
linkerd2-addr = { path = "lib/linkerd2-addr" }
45-
linkerd2-conditional = { path = "lib/linkerd2-conditional" }
46-
linkerd2-dns-name = { path = "lib/linkerd2-dns-name" }
47-
linkerd2-drain = { path = "lib/linkerd2-drain" }
48-
linkerd2-error = { path = "lib/linkerd2-error" }
49-
linkerd2-exp-backoff = { path = "lib/linkerd2-exp-backoff" }
50-
linkerd2-fallback = { path = "lib/linkerd2-fallback" }
51-
linkerd2-identity = { path = "lib/linkerd2-identity" }
52-
linkerd2-metrics = { path = "lib/linkerd2-metrics" }
53-
linkerd2-opencensus = { path = "lib/linkerd2-opencensus" }
54-
linkerd2-proxy-core = { path = "lib/linkerd2-proxy-core" }
55-
linkerd2-proxy-api-resolve = { path = "lib/linkerd2-proxy-api-resolve" }
56-
linkerd2-proxy-discover = { path = "lib/linkerd2-proxy-discover" }
57-
linkerd2-proxy-resolve = { path = "lib/linkerd2-proxy-resolve" }
58-
linkerd2-proxy-transport = { path = "lib/linkerd2-proxy-transport" }
59-
linkerd2-reconnect = { path = "lib/linkerd2-reconnect" }
60-
linkerd2-request-filter = { path = "lib/linkerd2-request-filter" }
61-
linkerd2-router = { path = "lib/linkerd2-router" }
62-
linkerd2-signal = { path = "lib/linkerd2-signal" }
63-
linkerd2-stack = { path = "lib/linkerd2-stack" }
64-
linkerd2-task = { path = "lib/linkerd2-task" }
65-
linkerd2-timeout = { path = "lib/linkerd2-timeout" }
66-
linkerd2-trace-context = { path = "lib/linkerd2-trace-context" }
67-
opencensus-proto = { path = "lib/opencensus-proto" }
68-
69-
linkerd2-proxy-api = { git = "https://github.com/linkerd/linkerd2-proxy-api", tag = "v0.1.10" }
70-
71-
bytes = "0.4"
72-
futures = "0.1"
73-
h2 = "0.1.15"
74-
http = "0.1"
75-
http-body = "0.1"
76-
httparse = "1.2"
77-
hyper = "0.12.3"
78-
ipnet = "1.0"
79-
log = { version = "0.4.1", features = ["std"] }
80-
indexmap = "1.0.0"
81-
prost = "0.5.0"
82-
prost-types = "0.5.0"
83-
rand = "0.6.3"
84-
try-lock = "0.2"
85-
86-
# for config parsing
87-
regex = "1.0.0"
88-
89-
# networking
90-
tokio = "0.1.14"
91-
tokio-timer = "0.2.6" # for tokio_timer::clock
92-
tower = "0.1"
93-
tower-discover = "0.1"
94-
tower-service = "0.2"
95-
tower-util = "0.1"
96-
tokio-connect = { git = "https://github.com/carllerche/tokio-connect" }
97-
tower-balance = { git = "https://github.com/tower-rs/tower" }
98-
tower-load = { git = "https://github.com/tower-rs/tower" }
99-
tower-request-modifier = { git = "https://github.com/tower-rs/tower-http" }
100-
tower-spawn-ready = { git = "https://github.com/tower-rs/tower" }
101-
tower-grpc = { version = "0.1", default-features = false, features = ["protobuf"] }
102-
103-
# FIXME update to a release when available (>0.11)
104-
trust-dns-resolver = { git = "https://github.com/bluejekyll/trust-dns", rev = "7c8a0739dad495bf5a4fddfe86b8bbe2aa52d060", default-features = false }
105-
106-
# tracing
107-
tracing = "0.1.9"
108-
tracing-futures = "0.1"
109-
tracing-log = "0.1"
110-
111-
# tls
112-
ring = "0.16"
113-
webpki = "0.21"
114-
rustls = "0.16"
115-
tokio-rustls = "0.10"
116-
untrusted = "0.7"
117-
118-
[dependencies.tracing-subscriber]
119-
version = "0.1.4"
120-
# we don't need ANSI colors or `chrono` time formatting
121-
default-features = false
122-
features = ["env-filter", "fmt", "smallvec", "tracing-log"]
123-
124-
[target.'cfg(target_os = "linux")'.dependencies]
125-
libc = "0.2"
126-
procinfo = "0.4.2"
127-
128-
[dev-dependencies]
129-
net2 = "0.2"
130-
quickcheck = { version = "0.8", default-features = false }
131-
linkerd2-metrics = { path = "./lib/linkerd2-metrics", features = ["test_util"] }
132-
linkerd2-task = { path = "lib/linkerd2-task", features = ["test_util"] }
133-
linkerd2-proxy-api = { git = "https://github.com/linkerd/linkerd2-proxy-api", features = ["arbitrary"], tag = "v0.1.10" }
134-
flate2 = { version = "1.0.1", default-features = false, features = ["rust_backend"] }
135-
# `tokio-io` is needed for TCP tests, because `tokio::io` doesn't re-export
136-
# the `read` function.
137-
tokio-io = "0.1.6"
138-
tokio-current-thread = "0.1.4"
139-
14038
# Debug symbols end up chewing up several GB of disk space, so better to just
14139
# disable them.
14240
[profile.dev]
@@ -146,4 +44,3 @@ debug = false
14644

14745
[patch.crates-io]
14846
webpki = { git = "https://github.com/seanmonstar/webpki", branch = "cert-dns-names-0.21" }
149-

Dockerfile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@ FROM $RUST_IMAGE as build
1616

1717
WORKDIR /usr/src/linkerd2-proxy
1818

19-
# Fetch external dependencies.
20-
RUN mkdir -p src && touch src/lib.rs
21-
COPY Cargo.toml Cargo.lock ./
22-
COPY lib lib
19+
COPY . .
2320
RUN cargo fetch --locked
24-
25-
COPY src src
2621
RUN if [ -n "$PROXY_UNOPTIMIZED" ]; \
2722
then \
2823
cargo build -p linkerd2-proxy --bin linkerd2-proxy --frozen && \
29-
mv target/debug/linkerd1-proxy target/linkerd2-proxy ; \
24+
mv target/debug/linkerd2-proxy target/linkerd2-proxy ; \
3025
else \
3126
cargo build -p linkerd2-proxy --bin linkerd2-proxy --frozen --release && \
3227
mv target/release/linkerd2-proxy target/linkerd2-proxy ; \

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SHASUM = shasum -a 256
1818

1919
CARGO ?= cargo
2020
CARGO_BUILD = $(CARGO) build --frozen $(RELEASE)
21-
CARGO_TEST = $(CARGO) test --all --frozen $(RELEASE)
21+
CARGO_TEST = $(CARGO) test --frozen $(RELEASE)
2222
CARGO_FMT = $(CARGO) fmt --all
2323

2424
DOCKER = docker
@@ -74,18 +74,18 @@ fmt:
7474

7575
.PHONY: test-lib
7676
test-lib:: fetch
77-
$(CARGO_TEST) --lib --no-default-features
77+
$(CARGO_TEST) --lib
7878

7979
.PHONY: test-integration
8080
test-integration: fetch
81-
$(CARGO_TEST) --tests --no-default-features
81+
$(CARGO_TEST) --tests
8282

8383
.PHONY: test
8484
test: test-lib test-integration
8585

8686
.PHONY: test-flakey
8787
test-flakey: fetch
88-
$(CARGO_TEST)
88+
$(CARGO_TEST) --features linkerd-app-integration/flaky_tests
8989

9090
.PHONY: package
9191
package: $(PKG_ROOT)/$(PKG)

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ Usually, [Cargo][cargo], Rust's package manager, is used to build and test this
5252
project. If you don't have Cargo installed, we suggest getting it via
5353
https://rustup.rs/.
5454

55+
### Repository Structure
56+
57+
This project is broken into many small libraries, or _crates_, so that
58+
components may be compiled & tested independently. The following crate
59+
targets are especially important:
60+
61+
* [`linkerd2-proxy`] contains the proxy executable;
62+
* [`linkerd2-app-integration`] contains the proxy's integration tests;
63+
* [`linkerd2-app`] bundles the [`linkerd2-app-inbound`] and [`linkerd2-app-outbound`] crates so that they may be run by the executable or integration tests.
64+
65+
[`linkerd2-proxy`]: linkerd2-proxy
66+
[`linkerd2-app`]: linkerd/app
67+
[`linkerd2-app-integration`]: linkerd/app/integration
68+
[`linkerd2-app-inbound`]: linkerd/app/inbound
69+
[`linkerd2-app-outbound`]: linkerd/app/outbound
5570

5671
## Code of conduct
5772

File renamed without changes.
File renamed without changes.

lib/linkerd2-proxy-transport/Cargo.toml

Lines changed: 0 additions & 33 deletions
This file was deleted.

lib/linkerd2-proxy-transport/src/lib.rs

Lines changed: 0 additions & 35 deletions
This file was deleted.

lib/linkerd2-addr/Cargo.toml renamed to linkerd/addr/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ publish = false
77

88
[dependencies]
99
http = "0.1"
10-
linkerd2-dns-name = { path = "../linkerd2-dns-name" }
10+
linkerd2-dns-name = { path = "../dns/name" }

0 commit comments

Comments
 (0)