Skip to content

Commit fb4f44c

Browse files
authored
Update to linkerd2-proxy-api v0.5 and tonic v0.7 (#1596)
With tonic v0.7, we now have the ability to provide a fixed PROTOC binary (rather than building/fetching a protoc implementation at build-time). This change updates the `linkerd-transport-header` and `opencensus-proto` crates to use statically-generated sources, eliminating the need for a `protoc` binary at build-time. Each crate includes a `bootstrap` test that fails if the generated sources differ from what is checked into git. These tests can also be used to regenerate sources when the protobuf (or tonic generation) changes. A local `install-protoc` action is added that fetches a protoc binary and configures the `PROTOC_NO_VENDOR` and `PROTOC` environment variables. This action is used by the check-all, check-each, and test workflows. Signed-off-by: Oliver Gould <ver@buoyant.io>
1 parent b49a87f commit fb4f44c

File tree

38 files changed

+1042
-183
lines changed

38 files changed

+1042
-183
lines changed

.devcontainer/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ RUN rustup toolchain add nightly
2424
FROM nightly as fuzz
2525
RUN cargo +nightly install cargo-fuzz
2626

27+
FROM docker.io/rust:${RUST_VERSION}-bullseye as protoc
28+
ARG PROTOC_VERSION=v3.20.0
29+
WORKDIR /tmp
30+
RUN arch="$(uname -m)" ; \
31+
version="$PROTOC_VERSION" ; \
32+
curl --proto '=https' --tlsv1.3 -vsSfLo protoc.zip "https://github.com/google/protobuf/releases/download/$version/protoc-${version#v}-linux-$arch.zip" && \
33+
unzip protoc.zip bin/protoc && \
34+
chmod 755 bin/protoc
35+
2736
#
2837
# Main image
2938
#
@@ -72,5 +81,9 @@ COPY --from=yq /usr/local/bin/yq /usr/local/bin/yq
7281
COPY --from=nightly /usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu /usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu
7382
COPY --from=fuzz /usr/local/cargo/bin/cargo-fuzz /usr/local/cargo/bin/cargo-fuzz
7483

84+
COPY --from=protoc /tmp/bin/protoc /usr/local/bin/protoc
85+
ENV PROTOC_NO_VENDOR=1
86+
ENV PROTOC=/usr/local/bin/protoc
87+
7588
ENTRYPOINT ["/usr/local/share/docker-init.sh"]
7689
CMD ["sleep", "infinity"]

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "linkerd2-proxy",
3-
"image": "ghcr.io/linkerd/dev-proxy:v8",
3+
"image": "ghcr.io/linkerd/dev-proxy:v9",
44
// "dockerFile": "./Dockerfile",
55
"extensions": [
66
"matklad.rust-analyzer",

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
Cargo.lock linguist-generated=false
2+
linkerd/transport-header/src/gen/* linguist-generated=true
3+
opencensus-proto/src/gen/* linguist-generated=true
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: install-protoc
2+
3+
description: Install protoc and set the `PROTOC` environment variablec
4+
5+
inputs:
6+
version:
7+
required: true
8+
description: "Protoc version"
9+
default: "v3.20.0"
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Install protoc
15+
shell: bash
16+
run: |
17+
os=linux
18+
if [ "$(uname -s)" = Darwin ]; then
19+
os=osx
20+
fi
21+
arch="$(uname -m)"
22+
version="${{ inputs.version }}"
23+
tmp=$(mktemp -d -t protoc.XXX)
24+
curl --fail --silent --show-error --location \
25+
--proto '=https' --tlsv1.3 \
26+
--output "$tmp/protoc.zip" \
27+
"https://github.com/google/protobuf/releases/download/$version/protoc-${version#v}-$os-$arch.zip"
28+
unzip $tmp/protoc.zip bin/protoc -d /usr/local
29+
chmod 755 /usr/local/bin/protoc
30+
( echo "PROTOC_NO_VENDOR=1"
31+
echo "PROTOC=/usr/local/bin/protoc"
32+
) >> $GITHUB_ENV
33+

.github/workflows/check-all.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
curl --proto =https --tlsv1.3 -vsSfLo /usr/local/bin/cargo-action-fmt "https://github.com/olix0r/cargo-action-fmt/releases/download/release%2F${CARGO_ACTION_FMT_VERSION}/cargo-action-fmt-x86_64-unknown-linux-gnu"
3333
chmod 755 /usr/local/bin/cargo-action-fmt
3434
- uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
35+
- uses: ./.github/actions/install-protoc
3536
- run: cargo fetch
3637
- run: |
3738
cargo check --frozen \

.github/workflows/check-each.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@ jobs:
5959
- run: |
6060
curl --proto =https --tlsv1.3 -vsSfLo /usr/local/bin/cargo-action-fmt "https://github.com/olix0r/cargo-action-fmt/releases/download/release%2F${CARGO_ACTION_FMT_VERSION}/cargo-action-fmt-x86_64-unknown-linux-gnu"
6161
chmod 755 /usr/local/bin/cargo-action-fmt
62-
- name: install meshtls-boring build deps
62+
- name: Install meshtls-boring build deps
6363
if: matrix.crate == 'linkerd-meshtls-boring'
6464
run: apt update && apt install -y clang cmake
6565
- uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
66+
- name: Install protoc
67+
if: matrix.crate == 'linkerd-transport-header' || matrix.crate == 'opencensus-proto'
68+
uses: ./.github/actions/install-protoc
6669
- run: cargo fetch
6770
- run: cargo check -p ${{ matrix.crate }} --frozen --all-targets --message-format=json | cargo-action-fmt
6871

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
image: docker://rust:1.59.0-buster
6363
steps:
6464
- uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
65+
- uses: ./.github/actions/install-protoc
6566
- run: |
6667
cargo test --all --no-run \
6768
--exclude=linkerd-app \

Cargo.lock

Lines changed: 30 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ version = "0.4.0"
256256
source = "registry+https://github.com/rust-lang/crates.io-index"
257257
checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73"
258258
dependencies = [
259-
"heck 0.4.0",
259+
"heck",
260260
"proc-macro2",
261261
"quote",
262262
"syn",
@@ -476,15 +476,6 @@ dependencies = [
476476
"num-traits",
477477
]
478478

479-
[[package]]
480-
name = "heck"
481-
version = "0.3.3"
482-
source = "registry+https://github.com/rust-lang/crates.io-index"
483-
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
484-
dependencies = [
485-
"unicode-segmentation",
486-
]
487-
488479
[[package]]
489480
name = "heck"
490481
version = "0.4.0"
@@ -594,18 +585,6 @@ dependencies = [
594585
"tower",
595586
]
596587

597-
[[package]]
598-
name = "hyper-timeout"
599-
version = "0.4.1"
600-
source = "registry+https://github.com/rust-lang/crates.io-index"
601-
checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
602-
dependencies = [
603-
"hyper",
604-
"pin-project-lite",
605-
"tokio",
606-
"tokio-io-timeout",
607-
]
608-
609588
[[package]]
610589
name = "idna"
611590
version = "0.2.3"
@@ -1693,9 +1672,9 @@ dependencies = [
16931672

16941673
[[package]]
16951674
name = "linkerd2-proxy-api"
1696-
version = "0.3.1"
1675+
version = "0.5.0"
16971676
source = "registry+https://github.com/rust-lang/crates.io-index"
1698-
checksum = "c6aaf91178c272abeaac52b2472351e73affa723bfdd0c15e147e2f975f2fbe5"
1677+
checksum = "12c93aba8dbdc8f465de51ef08c5e1938790ea0ae7390d66b3f4d2d36c297d0b"
16991678
dependencies = [
17001679
"h2",
17011680
"http",
@@ -1705,7 +1684,6 @@ dependencies = [
17051684
"quickcheck",
17061685
"thiserror",
17071686
"tonic",
1708-
"tonic-build",
17091687
]
17101688

17111689
[[package]]
@@ -1953,6 +1931,16 @@ version = "0.2.16"
19531931
source = "registry+https://github.com/rust-lang/crates.io-index"
19541932
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
19551933

1934+
[[package]]
1935+
name = "prettyplease"
1936+
version = "0.1.9"
1937+
source = "registry+https://github.com/rust-lang/crates.io-index"
1938+
checksum = "3b83ec2d0af5c5c556257ff52c9f98934e243b9fd39604bfb2a9b75ec2e97f18"
1939+
dependencies = [
1940+
"proc-macro2",
1941+
"syn",
1942+
]
1943+
19561944
[[package]]
19571945
name = "proc-macro2"
19581946
version = "1.0.37"
@@ -1976,22 +1964,24 @@ dependencies = [
19761964

19771965
[[package]]
19781966
name = "prost"
1979-
version = "0.9.0"
1967+
version = "0.10.0"
19801968
source = "registry+https://github.com/rust-lang/crates.io-index"
1981-
checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
1969+
checksum = "1bd5316aa8f5c82add416dfbc25116b84b748a21153f512917e8143640a71bbd"
19821970
dependencies = [
19831971
"bytes",
19841972
"prost-derive",
19851973
]
19861974

19871975
[[package]]
19881976
name = "prost-build"
1989-
version = "0.9.0"
1977+
version = "0.10.0"
19901978
source = "registry+https://github.com/rust-lang/crates.io-index"
1991-
checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5"
1979+
checksum = "328f9f29b82409216decb172d81e936415d21245befa79cd34c3f29d87d1c50b"
19921980
dependencies = [
19931981
"bytes",
1994-
"heck 0.3.3",
1982+
"cfg-if",
1983+
"cmake",
1984+
"heck",
19951985
"itertools",
19961986
"lazy_static",
19971987
"log",
@@ -2006,9 +1996,9 @@ dependencies = [
20061996

20071997
[[package]]
20081998
name = "prost-derive"
2009-
version = "0.9.0"
1999+
version = "0.10.0"
20102000
source = "registry+https://github.com/rust-lang/crates.io-index"
2011-
checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe"
2001+
checksum = "df35198f0777b75e9ff669737c6da5136b59dba33cf5a010a6d1cc4d56defc6f"
20122002
dependencies = [
20132003
"anyhow",
20142004
"itertools",
@@ -2019,9 +2009,9 @@ dependencies = [
20192009

20202010
[[package]]
20212011
name = "prost-types"
2022-
version = "0.9.0"
2012+
version = "0.10.0"
20232013
source = "registry+https://github.com/rust-lang/crates.io-index"
2024-
checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
2014+
checksum = "926681c118ae6e512a3ccefd4abbe5521a14f4cc1e207356d4d00c0b7f2006fd"
20252015
dependencies = [
20262016
"bytes",
20272017
"prost",
@@ -2392,16 +2382,6 @@ dependencies = [
23922382
"tokio",
23932383
]
23942384

2395-
[[package]]
2396-
name = "tokio-io-timeout"
2397-
version = "1.2.0"
2398-
source = "registry+https://github.com/rust-lang/crates.io-index"
2399-
checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
2400-
dependencies = [
2401-
"pin-project-lite",
2402-
"tokio",
2403-
]
2404-
24052385
[[package]]
24062386
name = "tokio-macros"
24072387
version = "1.7.0"
@@ -2479,41 +2459,36 @@ dependencies = [
24792459

24802460
[[package]]
24812461
name = "tonic"
2482-
version = "0.6.2"
2462+
version = "0.7.1"
24832463
source = "registry+https://github.com/rust-lang/crates.io-index"
2484-
checksum = "ff08f4649d10a70ffa3522ca559031285d8e421d727ac85c60825761818f5d0a"
2464+
checksum = "30fb54bf1e446f44d870d260d99957e7d11fb9d0a0f5bd1a662ad1411cc103f9"
24852465
dependencies = [
24862466
"async-stream",
24872467
"async-trait",
24882468
"base64",
24892469
"bytes",
24902470
"futures-core",
24912471
"futures-util",
2492-
"h2",
24932472
"http",
24942473
"http-body",
2495-
"hyper",
2496-
"hyper-timeout",
24972474
"percent-encoding",
24982475
"pin-project",
24992476
"prost",
25002477
"prost-derive",
2501-
"tokio",
25022478
"tokio-stream",
2503-
"tokio-util 0.6.9",
2504-
"tower",
2479+
"tokio-util 0.7.1",
25052480
"tower-layer",
25062481
"tower-service",
25072482
"tracing",
2508-
"tracing-futures",
25092483
]
25102484

25112485
[[package]]
25122486
name = "tonic-build"
2513-
version = "0.6.2"
2487+
version = "0.7.0"
25142488
source = "registry+https://github.com/rust-lang/crates.io-index"
2515-
checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757"
2489+
checksum = "4d17087af5c80e5d5fc8ba9878e60258065a0a757e35efe7a05b7904bece1943"
25162490
dependencies = [
2491+
"prettyplease",
25172492
"proc-macro2",
25182493
"prost-build",
25192494
"quote",
@@ -2600,16 +2575,6 @@ dependencies = [
26002575
"valuable",
26012576
]
26022577

2603-
[[package]]
2604-
name = "tracing-futures"
2605-
version = "0.2.5"
2606-
source = "registry+https://github.com/rust-lang/crates.io-index"
2607-
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
2608-
dependencies = [
2609-
"pin-project",
2610-
"tracing",
2611-
]
2612-
26132578
[[package]]
26142579
name = "tracing-log"
26152580
version = "0.1.2"
@@ -2719,12 +2684,6 @@ dependencies = [
27192684
"tinyvec",
27202685
]
27212686

2722-
[[package]]
2723-
name = "unicode-segmentation"
2724-
version = "1.9.0"
2725-
source = "registry+https://github.com/rust-lang/crates.io-index"
2726-
checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99"
2727-
27282687
[[package]]
27292688
name = "unicode-xid"
27302689
version = "0.2.2"

deny.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ deny = [
4848
{ name = "rustls", wrappers = ["tokio-rustls"] },
4949
]
5050
skip = [
51-
# Waiting on a prost-build release that includes
52-
# https://github.com/tokio-rs/prost/pull/583
53-
{ name = "heck", version = "0.3" },
5451
# waiting on `h2` and `tower` releases that update h2 to v0.7
5552
{ name = "tokio-util", version = "0.6" },
5653
]

linkerd/app/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ regex = "1"
2727
thiserror = "1"
2828
tokio = { version = "1", features = ["rt"] }
2929
tokio-stream = { version = "0.1", features = ["time", "sync"] }
30-
tonic = { version = "0.6", default-features = false, features = ["prost"] }
30+
tonic = { version = "0.7", default-features = false, features = ["prost"] }
3131
tower = "0.4"
3232
tracing = "0.1"

0 commit comments

Comments
 (0)