-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
identity: add spire identity client #2580
Conversation
Signed-off-by: Zahari Dichev <[email protected]>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2580 +/- ##
==========================================
- Coverage 67.83% 67.64% -0.19%
==========================================
Files 328 332 +4
Lines 14989 15125 +136
==========================================
+ Hits 10168 10232 +64
- Misses 4821 4893 +72
... and 4 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Signed-off-by: Zahari Dichev <[email protected]>
ba38a84
to
189c777
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is still marked as draft but I had a look just to understand the changes. I won't be in for a while after today. Left some drive-by comments.
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
I have:
|
linkerd/app/src/identity.rs
Outdated
#[derive(Clone)] | ||
pub enum Addr { | ||
Spire(Arc<String>), | ||
Linkerd(control::ControlAddr), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to move this into the Provider type to avoid having redundant enums?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used in the App
, here. It was returning a control::ControlAddr
before.
@@ -0,0 +1,11 @@ | |||
[package] | |||
name = "linkerd-proxy-identity-client-metrics" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an alternative approach to this (against main) #2617 -- updating these metrics to reflect best practices (e.g. _total vs _count); it also means neither clients need to be explicitly aware of these metrics.
Signed-off-by: Zahari Dichev <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we're passing the server name as an ID into the identity watcher. That's wrong -- right? Is there a test we could run/write that would fail? Does this mean that the watch function doesn't actually need the identity?
In general, I think we my want to reorganize app::identity a little for consistency, modularization, etc.
It still feels icky (not a blocker) to me that we have an Addr enum, when the Config (neé Provider) already holds these addrs in effectively the same enum.
My gut tells me we're going against the grain here, and we need to restructure some of the app code for this. I did a quick and dirty attempt here.
Signed-off-by: Zahari Dichev <[email protected]>
…configured with wrong identity Signed-off-by: Zahari Dichev <[email protected]>
return credentials.set_certificate(svid.leaf, svid.intermediates, svid.private_key, exp); | ||
} | ||
|
||
Err("could not find an SVID".into()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We tend not to use string errors, instead using typed errors via the thiserror crate.
#[derive(Debug, thiserror::Error)]
#[error("no matching SVID found")]
pub struct NoMatchingSVIDFound(());
Note that the unit field ensures the error can't be built outside of the module.
Err("could not find an SVID".into()) | |
Err(NoMatchingSVIDFound(()).into()) |
if let Err(error) = process_svid(&mut credentials, svid_update, id) { | ||
tracing::error!("Error processing SVID update: {}", error); | ||
} | ||
|
||
if let Err(error) = updates.changed().await { | ||
tracing::debug!("SVID watch closed; terminating {}", error); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
if let Err(error) = process_svid(&mut credentials, svid_update, id) { | |
tracing::error!("Error processing SVID update: {}", error); | |
} | |
if let Err(error) = updates.changed().await { | |
tracing::debug!("SVID watch closed; terminating {}", error); | |
return; | |
} | |
if let Err(error) = process_svid(&mut credentials, svid_update, id) { | |
tracing::error!(%error, "Error processing SVID update"); | |
} | |
if updates.changed().await.is_err() { | |
tracing::debug!("SVID watch closed; terminating"); | |
return; | |
} |
We generally use field interpolation for errors (rather than direct string formatting).
Also, the error type from changed() is uninteresting -- it can only indicate that all receivers were dropped.
pub struct Svid { | ||
pub(super) spiffe_id: Id, | ||
pub(super) leaf: DerX509, | ||
pub(super) private_key: Vec<u8>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of yakshave that we can do as a followup, but I think we really ought to have a linkerd_identity::PrivateKey type so we're not passing around sensitive byte arrays everywhere.
Why does the private key need to be crate-visible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see this is for process_svid -- what if we moved process_svid into this module and made that pub(super)
-- this gives us a narrower module boundary where we can make all of the Svid stuff private
Signed-off-by: Zahari Dichev <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. One last (I think ;) nit
linkerd/app/src/identity.rs
Outdated
(Id::Dns(id), sni) if id == sni => id.clone(), | ||
(_id, _sni) => { | ||
return Err( | ||
"Linkerd identity requires a TLS Id and server name to be the same" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we'd use thiserror again here. Since is up at the app layer I don't care as much as I would in a lib.
let client = client.ready().await.expect("should be ready"); | ||
match client.call(()).await { | ||
Ok(rsp) => consume_updates(&self.id, rsp.into_inner(), credentials).await, | ||
Err(error) => error!(%error, "could not establish SVID stream"), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let client = client.ready().await.expect("should be ready"); | |
match client.call(()).await { | |
Ok(rsp) => consume_updates(&self.id, rsp.into_inner(), credentials).await, | |
Err(error) => error!(%error, "could not establish SVID stream"), | |
} | |
let client = client.ready().await.expect("should be ready"); | |
let rsp = client.call(()).await.expect("spire client must gracefully handle errors"); | |
consume_updates(&self.id, rsp.into_inner(), credentials).await |
Based on our earlier convo, I'm pretty sure that a failure here indicates something pathological (i.e., a bad request from the client). If so, it seems better to panic than to log and never satisfy an identity.
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌮
Signed-off-by: Zahari Dichev <[email protected]>
* build(deps): bump itertools from 0.10.5 to 0.11.0 (linkerd/linkerd2-proxy#2594) * build(deps): bump async-trait from 0.1.68 to 0.1.75 (linkerd/linkerd2-proxy#2595) * pool: Decompose the pool and balancer crates (linkerd/linkerd2-proxy#2597) * balance: Move endpoint state gauge into balancer (linkerd/linkerd2-proxy#2598) * cargo: Remove cyclic meshtls dependency (linkerd/linkerd2-proxy#2602) * build(deps): bump mime from 0.3.16 to 0.3.17 (linkerd/linkerd2-proxy#2599) * build(deps): bump parking_lot_core from 0.9.5 to 0.9.9 (linkerd/linkerd2-proxy#2600) * build(deps): bump prost-build from 0.12.1 to 0.12.3 (linkerd/linkerd2-proxy#2601) * outbound: Update route backend metrics implementation (linkerd/linkerd2-proxy#2603) * deps: Update to indexmap v2 (linkerd/linkerd2-proxy#2604) * build(deps): bump actions/download-artifact from 3.0.2 to 4.1.0 (linkerd/linkerd2-proxy#2569) * deps: h2 v0.3.22 (linkerd/linkerd2-proxy#2605) * tracing: Ensure that INFO-level spans are preserved (linkerd/linkerd2-proxy#2611) * build(deps): bump serde from 1.0.185 to 1.0.193 (linkerd/linkerd2-proxy#2606) * build(deps): bump tokio-boring from 3.0.4 to 3.1.0 (linkerd/linkerd2-proxy#2607) * build(deps): bump deranged from 0.3.10 to 0.3.11 (linkerd/linkerd2-proxy#2608) * build(deps): bump axum from 0.6.11 to 0.6.20 (linkerd/linkerd2-proxy#2609) * build(deps): bump proc-macro2 from 1.0.69 to 1.0.74 (linkerd/linkerd2-proxy#2610) * build(deps): bump ahash from 0.8.6 to 0.8.7 (linkerd/linkerd2-proxy#2612) * build(deps): bump cc from 1.0.79 to 1.0.83 (linkerd/linkerd2-proxy#2613) * build(deps): bump scopeguard from 1.1.0 to 1.2.0 (linkerd/linkerd2-proxy#2614) * build(deps): bump io-lifetimes from 1.0.10 to 1.0.11 (linkerd/linkerd2-proxy#2616) * build(deps): bump pem from 3.0.2 to 3.0.3 (linkerd/linkerd2-proxy#2615) * build(deps): bump anyhow from 1.0.76 to 1.0.79 (linkerd/linkerd2-proxy#2619) * build(deps): bump socket2 from 0.4.9 to 0.5.5 (linkerd/linkerd2-proxy#2622) * build(deps): bump libfuzzer-sys from 0.4.6 to 0.4.7 (linkerd/linkerd2-proxy#2620) * build(deps): bump tempfile from 3.5.0 to 3.6.0 (linkerd/linkerd2-proxy#2621) * build(deps): bump ryu from 1.0.13 to 1.0.16 (linkerd/linkerd2-proxy#2623) * identity: Update metrics to follow OpenMetrics best practices (linkerd/linkerd2-proxy#2617) * build(deps): bump tokio from 1.34.0 to 1.35.1 (linkerd/linkerd2-proxy#2627) * build(deps): bump tracing from 0.1.37 to 0.1.40 (linkerd/linkerd2-proxy#2628) * build(deps): bump slab from 0.4.8 to 0.4.9 (linkerd/linkerd2-proxy#2629) * build(deps): bump unicode-bidi from 0.3.11 to 0.3.14 (linkerd/linkerd2-proxy#2630) * build(deps): bump tokio-stream from 0.1.12 to 0.1.14 (linkerd/linkerd2-proxy#2632) * build(deps): bump boring-sys from 3.0.4 to 3.1.0 (linkerd/linkerd2-proxy#2633) * build(deps): bump rcgen from 0.11.3 to 0.12.0 (linkerd/linkerd2-proxy#2635) * build(deps): bump trust-dns-resolver from 0.22.0 to 0.23.2 (linkerd/linkerd2-proxy#2631) * build(deps): bump memchr from 2.6.4 to 2.7.1 (linkerd/linkerd2-proxy#2637) * build(deps): bump pin-project from 1.0.12 to 1.1.3 (linkerd/linkerd2-proxy#2638) * build(deps): bump futures from 0.3.28 to 0.3.30 (linkerd/linkerd2-proxy#2639) * build(deps): bump rangemap from 1.3.0 to 1.4.0 (linkerd/linkerd2-proxy#2640) * build(deps): bump actions/download-artifact from 4.1.0 to 4.1.1 (linkerd/linkerd2-proxy#2636) * build(deps): bump thingbuf from 0.1.3 to 0.1.4 (linkerd/linkerd2-proxy#2642) * build(deps): bump rustix from 0.36.16 to 0.36.17 (linkerd/linkerd2-proxy#2643) * build(deps): bump httpdate from 1.0.2 to 1.0.3 (linkerd/linkerd2-proxy#2645) * build(deps): bump num_cpus from 1.15.0 to 1.16.0 (linkerd/linkerd2-proxy#2646) * Change inbound port check log level to debug. (linkerd/linkerd2-proxy#2625) * docs: Fix bad reference link (linkerd/linkerd2-proxy#2647) * identity: add spire identity client (linkerd/linkerd2-proxy#2580) * config:add spire client config (linkerd/linkerd2-proxy#2641) * discovery: consume server_name and UriLikeIdentity from proto (linkerd/linkerd2-proxy#2618) * build(deps): bump h2 from 0.3.22 to 0.3.24 (linkerd/linkerd2-proxy#2660) * build(deps): bump procfs from 0.15.1 to 0.16.0 (linkerd/linkerd2-proxy#2649) * build(deps): bump async-trait from 0.1.75 to 0.1.77 (linkerd/linkerd2-proxy#2650) * build(deps): bump semver from 1.0.20 to 1.0.21 (linkerd/linkerd2-proxy#2651) * build(deps): bump smallvec from 1.10.0 to 1.13.1 (linkerd/linkerd2-proxy#2661) * build(deps): bump either from 1.8.1 to 1.9.0 (linkerd/linkerd2-proxy#2652) * build(deps): bump actions/upload-artifact from 4.0.0 to 4.2.0 (linkerd/linkerd2-proxy#2658) * build(deps): bump shlex from 1.1.0 to 1.3.0 (linkerd/linkerd2-proxy#2664) * build(deps): bump DavidAnson/markdownlint-cli2-action (linkerd/linkerd2-proxy#2656) * build(deps): bump EmbarkStudios/cargo-deny-action from 1.5.5 to 1.5.10 (linkerd/linkerd2-proxy#2665) * build(deps): bump serde from 1.0.193 to 1.0.195 (linkerd/linkerd2-proxy#2670) * build(deps): bump clang-sys from 1.6.0 to 1.7.0 (linkerd/linkerd2-proxy#2668) * build(deps): bump zerocopy from 0.7.31 to 0.7.32 (linkerd/linkerd2-proxy#2666) * build(deps): bump unicode-ident from 1.0.6 to 1.0.12 (linkerd/linkerd2-proxy#2667) * build(deps): bump actions/upload-artifact from 4.2.0 to 4.3.0 (linkerd/linkerd2-proxy#2671) * build(deps): bump prettyplease from 0.2.15 to 0.2.16 (linkerd/linkerd2-proxy#2673) * build(deps): bump getrandom from 0.2.8 to 0.2.12 (linkerd/linkerd2-proxy#2674) * build(deps): bump which from 4.4.0 to 4.4.2 (linkerd/linkerd2-proxy#2675) * build(deps): bump sharded-slab from 0.1.4 to 0.1.7 (linkerd/linkerd2-proxy#2676) * build(deps): bump EmbarkStudios/cargo-deny-action from 1.5.10 to 1.5.11 (linkerd/linkerd2-proxy#2672) * build(deps): bump tj-actions/changed-files from 41.0.1 to 42.0.0 (linkerd/linkerd2-proxy#2657) Signed-off-by: Oliver Gould <[email protected]>
* proxy: v2.220.0 * build(deps): bump itertools from 0.10.5 to 0.11.0 (linkerd/linkerd2-proxy#2594) * build(deps): bump async-trait from 0.1.68 to 0.1.75 (linkerd/linkerd2-proxy#2595) * pool: Decompose the pool and balancer crates (linkerd/linkerd2-proxy#2597) * balance: Move endpoint state gauge into balancer (linkerd/linkerd2-proxy#2598) * cargo: Remove cyclic meshtls dependency (linkerd/linkerd2-proxy#2602) * build(deps): bump mime from 0.3.16 to 0.3.17 (linkerd/linkerd2-proxy#2599) * build(deps): bump parking_lot_core from 0.9.5 to 0.9.9 (linkerd/linkerd2-proxy#2600) * build(deps): bump prost-build from 0.12.1 to 0.12.3 (linkerd/linkerd2-proxy#2601) * outbound: Update route backend metrics implementation (linkerd/linkerd2-proxy#2603) * deps: Update to indexmap v2 (linkerd/linkerd2-proxy#2604) * build(deps): bump actions/download-artifact from 3.0.2 to 4.1.0 (linkerd/linkerd2-proxy#2569) * deps: h2 v0.3.22 (linkerd/linkerd2-proxy#2605) * tracing: Ensure that INFO-level spans are preserved (linkerd/linkerd2-proxy#2611) * build(deps): bump serde from 1.0.185 to 1.0.193 (linkerd/linkerd2-proxy#2606) * build(deps): bump tokio-boring from 3.0.4 to 3.1.0 (linkerd/linkerd2-proxy#2607) * build(deps): bump deranged from 0.3.10 to 0.3.11 (linkerd/linkerd2-proxy#2608) * build(deps): bump axum from 0.6.11 to 0.6.20 (linkerd/linkerd2-proxy#2609) * build(deps): bump proc-macro2 from 1.0.69 to 1.0.74 (linkerd/linkerd2-proxy#2610) * build(deps): bump ahash from 0.8.6 to 0.8.7 (linkerd/linkerd2-proxy#2612) * build(deps): bump cc from 1.0.79 to 1.0.83 (linkerd/linkerd2-proxy#2613) * build(deps): bump scopeguard from 1.1.0 to 1.2.0 (linkerd/linkerd2-proxy#2614) * build(deps): bump io-lifetimes from 1.0.10 to 1.0.11 (linkerd/linkerd2-proxy#2616) * build(deps): bump pem from 3.0.2 to 3.0.3 (linkerd/linkerd2-proxy#2615) * build(deps): bump anyhow from 1.0.76 to 1.0.79 (linkerd/linkerd2-proxy#2619) * build(deps): bump socket2 from 0.4.9 to 0.5.5 (linkerd/linkerd2-proxy#2622) * build(deps): bump libfuzzer-sys from 0.4.6 to 0.4.7 (linkerd/linkerd2-proxy#2620) * build(deps): bump tempfile from 3.5.0 to 3.6.0 (linkerd/linkerd2-proxy#2621) * build(deps): bump ryu from 1.0.13 to 1.0.16 (linkerd/linkerd2-proxy#2623) * identity: Update metrics to follow OpenMetrics best practices (linkerd/linkerd2-proxy#2617) * build(deps): bump tokio from 1.34.0 to 1.35.1 (linkerd/linkerd2-proxy#2627) * build(deps): bump tracing from 0.1.37 to 0.1.40 (linkerd/linkerd2-proxy#2628) * build(deps): bump slab from 0.4.8 to 0.4.9 (linkerd/linkerd2-proxy#2629) * build(deps): bump unicode-bidi from 0.3.11 to 0.3.14 (linkerd/linkerd2-proxy#2630) * build(deps): bump tokio-stream from 0.1.12 to 0.1.14 (linkerd/linkerd2-proxy#2632) * build(deps): bump boring-sys from 3.0.4 to 3.1.0 (linkerd/linkerd2-proxy#2633) * build(deps): bump rcgen from 0.11.3 to 0.12.0 (linkerd/linkerd2-proxy#2635) * build(deps): bump trust-dns-resolver from 0.22.0 to 0.23.2 (linkerd/linkerd2-proxy#2631) * build(deps): bump memchr from 2.6.4 to 2.7.1 (linkerd/linkerd2-proxy#2637) * build(deps): bump pin-project from 1.0.12 to 1.1.3 (linkerd/linkerd2-proxy#2638) * build(deps): bump futures from 0.3.28 to 0.3.30 (linkerd/linkerd2-proxy#2639) * build(deps): bump rangemap from 1.3.0 to 1.4.0 (linkerd/linkerd2-proxy#2640) * build(deps): bump actions/download-artifact from 4.1.0 to 4.1.1 (linkerd/linkerd2-proxy#2636) * build(deps): bump thingbuf from 0.1.3 to 0.1.4 (linkerd/linkerd2-proxy#2642) * build(deps): bump rustix from 0.36.16 to 0.36.17 (linkerd/linkerd2-proxy#2643) * build(deps): bump httpdate from 1.0.2 to 1.0.3 (linkerd/linkerd2-proxy#2645) * build(deps): bump num_cpus from 1.15.0 to 1.16.0 (linkerd/linkerd2-proxy#2646) * Change inbound port check log level to debug. (linkerd/linkerd2-proxy#2625) * docs: Fix bad reference link (linkerd/linkerd2-proxy#2647) * identity: add spire identity client (linkerd/linkerd2-proxy#2580) * config:add spire client config (linkerd/linkerd2-proxy#2641) * discovery: consume server_name and UriLikeIdentity from proto (linkerd/linkerd2-proxy#2618) * build(deps): bump h2 from 0.3.22 to 0.3.24 (linkerd/linkerd2-proxy#2660) * build(deps): bump procfs from 0.15.1 to 0.16.0 (linkerd/linkerd2-proxy#2649) * build(deps): bump async-trait from 0.1.75 to 0.1.77 (linkerd/linkerd2-proxy#2650) * build(deps): bump semver from 1.0.20 to 1.0.21 (linkerd/linkerd2-proxy#2651) * build(deps): bump smallvec from 1.10.0 to 1.13.1 (linkerd/linkerd2-proxy#2661) * build(deps): bump either from 1.8.1 to 1.9.0 (linkerd/linkerd2-proxy#2652) * build(deps): bump actions/upload-artifact from 4.0.0 to 4.2.0 (linkerd/linkerd2-proxy#2658) * build(deps): bump shlex from 1.1.0 to 1.3.0 (linkerd/linkerd2-proxy#2664) * build(deps): bump DavidAnson/markdownlint-cli2-action (linkerd/linkerd2-proxy#2656) * build(deps): bump EmbarkStudios/cargo-deny-action from 1.5.5 to 1.5.10 (linkerd/linkerd2-proxy#2665) * build(deps): bump serde from 1.0.193 to 1.0.195 (linkerd/linkerd2-proxy#2670) * build(deps): bump clang-sys from 1.6.0 to 1.7.0 (linkerd/linkerd2-proxy#2668) * build(deps): bump zerocopy from 0.7.31 to 0.7.32 (linkerd/linkerd2-proxy#2666) * build(deps): bump unicode-ident from 1.0.6 to 1.0.12 (linkerd/linkerd2-proxy#2667) * build(deps): bump actions/upload-artifact from 4.2.0 to 4.3.0 (linkerd/linkerd2-proxy#2671) * build(deps): bump prettyplease from 0.2.15 to 0.2.16 (linkerd/linkerd2-proxy#2673) * build(deps): bump getrandom from 0.2.8 to 0.2.12 (linkerd/linkerd2-proxy#2674) * build(deps): bump which from 4.4.0 to 4.4.2 (linkerd/linkerd2-proxy#2675) * build(deps): bump sharded-slab from 0.1.4 to 0.1.7 (linkerd/linkerd2-proxy#2676) * build(deps): bump EmbarkStudios/cargo-deny-action from 1.5.10 to 1.5.11 (linkerd/linkerd2-proxy#2672) * build(deps): bump tj-actions/changed-files from 41.0.1 to 42.0.0 (linkerd/linkerd2-proxy#2657) Signed-off-by: Oliver Gould <[email protected]> * Bump helm version * +changes * Update CHANGES.md Co-authored-by: Alejandro Pedraza <[email protected]> --------- Signed-off-by: Oliver Gould <[email protected]> Co-authored-by: Alejandro Pedraza <[email protected]>
This PR adds SPIRE identity client that allows us to connect to the SPIRE workload API and stream new certificates through the
identity::Credentials
API. Notable changes include:spire-proto
crate that includes the workload API protobuf definitions and codegen utilitiesspire-client
crate that contains all the facilities to connect to the SPIRE UDS socket and consume updatesTODO:
Signed-off-by: Zahari Dichev [email protected]