Skip to content

Commit 1df7a6c

Browse files
committed
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 5543667 commit 1df7a6c

File tree

38 files changed

+1056
-185
lines changed

38 files changed

+1056
-185
lines changed

.devcontainer/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ ARG CARGO_DENY_VERSION=0.11.1
1313
RUN curl --proto '=https' --tlsv1.3 -vsSfL "https://github.com/EmbarkStudios/cargo-deny/releases/download/${CARGO_DENY_VERSION}/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
1414
| tar zvxf - --strip-components=1 -C /usr/local/bin "cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl/cargo-deny"
1515

16+
FROM docker.io/rust:${RUST_VERSION}-bullseye as yq
17+
ARG YQ_VERSION=v4.2.0
18+
RUN curl --proto '=https' --tlsv1.3 -vsSfLo /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" \
19+
&& chmod +x /usr/local/bin/yq
20+
21+
FROM docker.io/rust:${RUST_VERSION}-bullseye as nightly
22+
RUN rustup toolchain add nightly
23+
24+
FROM nightly as fuzz
25+
RUN cargo +nightly install cargo-fuzz
26+
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+
1636
#
1737
# Main image
1838
#
@@ -58,5 +78,9 @@ COPY --from=cargo-deny /usr/local/bin/cargo-deny /usr/local/bin/cargo-deny
5878
COPY --from=k3d /usr/local/bin/k3d /usr/local/bin/k3d
5979
COPY --from=kubectl /usr/local/bin/kubectl /usr/local/bin/kubectl
6080

81+
COPY --from=protoc /tmp/bin/protoc /usr/local/bin/protoc
82+
ENV PROTOC_NO_VENDOR=1
83+
ENV PROTOC=/usr/local/bin/protoc
84+
6185
ENTRYPOINT ["/usr/local/share/docker-init.sh"]
6286
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ jobs:
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
6262
- uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
63+
- name: Install protoc
64+
if: matrix.crate == 'linkerd-transport-header' || matrix.crate == 'opencensus-proto'
65+
uses: ./.github/actions/install-protoc
6366
- run: cargo fetch
6467
- run: cargo check -p ${{ matrix.crate }} --frozen --all-targets --message-format=json | cargo-action-fmt
6568

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
image: docker://rust:1.59.0-buster
2929
steps:
3030
- uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
31+
- uses: ./.github/actions/install-protoc
3132
- run: |
3233
cargo test --all --no-run \
3334
--exclude=linkerd-app \

Cargo.lock

Lines changed: 39 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ version = "1.0.0"
127127
source = "registry+https://github.com/rust-lang/crates.io-index"
128128
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
129129

130+
[[package]]
131+
name = "cmake"
132+
version = "0.1.48"
133+
source = "registry+https://github.com/rust-lang/crates.io-index"
134+
checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a"
135+
dependencies = [
136+
"cc",
137+
]
138+
130139
[[package]]
131140
name = "crc32fast"
132141
version = "1.3.2"
@@ -186,7 +195,7 @@ version = "0.4.0"
186195
source = "registry+https://github.com/rust-lang/crates.io-index"
187196
checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73"
188197
dependencies = [
189-
"heck 0.4.0",
198+
"heck",
190199
"proc-macro2",
191200
"quote",
192201
"syn",
@@ -373,15 +382,6 @@ dependencies = [
373382
"num-traits",
374383
]
375384

376-
[[package]]
377-
name = "heck"
378-
version = "0.3.3"
379-
source = "registry+https://github.com/rust-lang/crates.io-index"
380-
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
381-
dependencies = [
382-
"unicode-segmentation",
383-
]
384-
385385
[[package]]
386386
name = "heck"
387387
version = "0.4.0"
@@ -485,18 +485,6 @@ dependencies = [
485485
"tower",
486486
]
487487

488-
[[package]]
489-
name = "hyper-timeout"
490-
version = "0.4.1"
491-
source = "registry+https://github.com/rust-lang/crates.io-index"
492-
checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
493-
dependencies = [
494-
"hyper",
495-
"pin-project-lite",
496-
"tokio",
497-
"tokio-io-timeout",
498-
]
499-
500488
[[package]]
501489
name = "idna"
502490
version = "0.2.3"
@@ -1488,9 +1476,9 @@ dependencies = [
14881476

14891477
[[package]]
14901478
name = "linkerd2-proxy-api"
1491-
version = "0.3.1"
1479+
version = "0.5.0"
14921480
source = "registry+https://github.com/rust-lang/crates.io-index"
1493-
checksum = "c6aaf91178c272abeaac52b2472351e73affa723bfdd0c15e147e2f975f2fbe5"
1481+
checksum = "12c93aba8dbdc8f465de51ef08c5e1938790ea0ae7390d66b3f4d2d36c297d0b"
14941482
dependencies = [
14951483
"h2",
14961484
"http",
@@ -1500,7 +1488,6 @@ dependencies = [
15001488
"quickcheck",
15011489
"thiserror",
15021490
"tonic",
1503-
"tonic-build",
15041491
]
15051492

15061493
[[package]]
@@ -1725,6 +1712,16 @@ version = "0.2.16"
17251712
source = "registry+https://github.com/rust-lang/crates.io-index"
17261713
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
17271714

1715+
[[package]]
1716+
name = "prettyplease"
1717+
version = "0.1.9"
1718+
source = "registry+https://github.com/rust-lang/crates.io-index"
1719+
checksum = "3b83ec2d0af5c5c556257ff52c9f98934e243b9fd39604bfb2a9b75ec2e97f18"
1720+
dependencies = [
1721+
"proc-macro2",
1722+
"syn",
1723+
]
1724+
17281725
[[package]]
17291726
name = "proc-macro2"
17301727
version = "1.0.37"
@@ -1748,22 +1745,24 @@ dependencies = [
17481745

17491746
[[package]]
17501747
name = "prost"
1751-
version = "0.9.0"
1748+
version = "0.10.0"
17521749
source = "registry+https://github.com/rust-lang/crates.io-index"
1753-
checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
1750+
checksum = "1bd5316aa8f5c82add416dfbc25116b84b748a21153f512917e8143640a71bbd"
17541751
dependencies = [
17551752
"bytes",
17561753
"prost-derive",
17571754
]
17581755

17591756
[[package]]
17601757
name = "prost-build"
1761-
version = "0.9.0"
1758+
version = "0.10.0"
17621759
source = "registry+https://github.com/rust-lang/crates.io-index"
1763-
checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5"
1760+
checksum = "328f9f29b82409216decb172d81e936415d21245befa79cd34c3f29d87d1c50b"
17641761
dependencies = [
17651762
"bytes",
1766-
"heck 0.3.3",
1763+
"cfg-if",
1764+
"cmake",
1765+
"heck",
17671766
"itertools",
17681767
"lazy_static",
17691768
"log",
@@ -1778,9 +1777,9 @@ dependencies = [
17781777

17791778
[[package]]
17801779
name = "prost-derive"
1781-
version = "0.9.0"
1780+
version = "0.10.0"
17821781
source = "registry+https://github.com/rust-lang/crates.io-index"
1783-
checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe"
1782+
checksum = "df35198f0777b75e9ff669737c6da5136b59dba33cf5a010a6d1cc4d56defc6f"
17841783
dependencies = [
17851784
"anyhow",
17861785
"itertools",
@@ -1791,9 +1790,9 @@ dependencies = [
17911790

17921791
[[package]]
17931792
name = "prost-types"
1794-
version = "0.9.0"
1793+
version = "0.10.0"
17951794
source = "registry+https://github.com/rust-lang/crates.io-index"
1796-
checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
1795+
checksum = "926681c118ae6e512a3ccefd4abbe5521a14f4cc1e207356d4d00c0b7f2006fd"
17971796
dependencies = [
17981797
"bytes",
17991798
"prost",
@@ -2133,16 +2132,6 @@ dependencies = [
21332132
"winapi",
21342133
]
21352134

2136-
[[package]]
2137-
name = "tokio-io-timeout"
2138-
version = "1.2.0"
2139-
source = "registry+https://github.com/rust-lang/crates.io-index"
2140-
checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
2141-
dependencies = [
2142-
"pin-project-lite",
2143-
"tokio",
2144-
]
2145-
21462135
[[package]]
21472136
name = "tokio-macros"
21482137
version = "1.7.0"
@@ -2220,41 +2209,36 @@ dependencies = [
22202209

22212210
[[package]]
22222211
name = "tonic"
2223-
version = "0.6.2"
2212+
version = "0.7.1"
22242213
source = "registry+https://github.com/rust-lang/crates.io-index"
2225-
checksum = "ff08f4649d10a70ffa3522ca559031285d8e421d727ac85c60825761818f5d0a"
2214+
checksum = "30fb54bf1e446f44d870d260d99957e7d11fb9d0a0f5bd1a662ad1411cc103f9"
22262215
dependencies = [
22272216
"async-stream",
22282217
"async-trait",
22292218
"base64",
22302219
"bytes",
22312220
"futures-core",
22322221
"futures-util",
2233-
"h2",
22342222
"http",
22352223
"http-body",
2236-
"hyper",
2237-
"hyper-timeout",
22382224
"percent-encoding",
22392225
"pin-project",
22402226
"prost",
22412227
"prost-derive",
2242-
"tokio",
22432228
"tokio-stream",
2244-
"tokio-util 0.6.9",
2245-
"tower",
2229+
"tokio-util 0.7.1",
22462230
"tower-layer",
22472231
"tower-service",
22482232
"tracing",
2249-
"tracing-futures",
22502233
]
22512234

22522235
[[package]]
22532236
name = "tonic-build"
2254-
version = "0.6.2"
2237+
version = "0.7.0"
22552238
source = "registry+https://github.com/rust-lang/crates.io-index"
2256-
checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757"
2239+
checksum = "4d17087af5c80e5d5fc8ba9878e60258065a0a757e35efe7a05b7904bece1943"
22572240
dependencies = [
2241+
"prettyplease",
22582242
"proc-macro2",
22592243
"prost-build",
22602244
"quote",
@@ -2341,16 +2325,6 @@ dependencies = [
23412325
"valuable",
23422326
]
23432327

2344-
[[package]]
2345-
name = "tracing-futures"
2346-
version = "0.2.5"
2347-
source = "registry+https://github.com/rust-lang/crates.io-index"
2348-
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
2349-
dependencies = [
2350-
"pin-project",
2351-
"tracing",
2352-
]
2353-
23542328
[[package]]
23552329
name = "tracing-log"
23562330
version = "0.1.2"
@@ -2460,12 +2434,6 @@ dependencies = [
24602434
"tinyvec",
24612435
]
24622436

2463-
[[package]]
2464-
name = "unicode-segmentation"
2465-
version = "1.9.0"
2466-
source = "registry+https://github.com/rust-lang/crates.io-index"
2467-
checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99"
2468-
24692437
[[package]]
24702438
name = "unicode-xid"
24712439
version = "0.2.2"

deny.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ ignore = []
1717
unlicensed = "deny"
1818
allow = [
1919
"Apache-2.0",
20-
"BSD-3-Clause",
2120
"ISC",
2221
"MIT",
2322
]
@@ -48,14 +47,8 @@ deny = [
4847
{ name = "rustls", wrappers = ["tokio-rustls"] },
4948
]
5049
skip = [
51-
# Waiting on a tokio release that updates parking_lot to v0.12.
52-
{ name = "parking_lot", version = "0.11" },
53-
{ name = "parking_lot_core", version = "0.8" },
54-
# Waiting on a prost-build release that includes
55-
# https://github.com/tokio-rs/prost/pull/583
56-
{ name = "heck", version = "0.3" },
5750
# waiting on `h2` and `tower` releases that update h2 to v0.7
58-
{ name = "tokio-util", version = "0.6" }
51+
{ name = "tokio-util", version = "0.6" },
5952
]
6053
skip-tree = [
6154
# Hasn't seen a new release since 2017. Pulls in an older version of nom.

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)