Skip to content
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

Initial connection MDS implementation #802

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

howardjohn
Copy link
Member

@howardjohn howardjohn commented Feb 7, 2024

  • Store each connection in a shared map
  • Capture special IP address, redirect to MDS handler
  • MDS handler takes 4 tuple as input.
  • Response is JSON containing identity

Also has an example Golang library implementation to add HTTP middleware that extracts the identity.

Istio tests: istio/istio#44536 (blocked by this PR, of course), which also show how to use it

Original PR in #504 got force deleted so cannot re-open

@howardjohn howardjohn added the release-notes-none Indicates a PR that does not require release notes. label Feb 7, 2024
@howardjohn howardjohn requested a review from a team as a code owner February 7, 2024 19:33
@istio-testing istio-testing added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 7, 2024
@howardjohn howardjohn marked this pull request as draft February 7, 2024 19:33
@istio-testing istio-testing added the do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. label Feb 7, 2024
src/proxy/metadata.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@ilrudie ilrudie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't envision connection manager being used in this way so we'll probably need to make more changes to ensure all outbound connections register and release correctly

src/proxy/outbound.rs Outdated Show resolved Hide resolved
Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add desc of the usage

#[derive(Clone, Debug, Serialize)]
pub struct ConnectionMetadata {
#[serde(default)]
identity: Option<Identity>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused about a connection's identity. Usually, we say the src identity or dest identity

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the implementation we've got it will be the source identity. I suppose keeping the type general would allow us to represent peer identity generically with the same type in the future though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I documented a bit more now

go-metadata/istio.go Outdated Show resolved Hide resolved
@istio-testing istio-testing added the needs-rebase Indicates a PR needs to be rebased before being merged label Feb 27, 2024
@istio-testing istio-testing removed the needs-rebase Indicates a PR needs to be rebased before being merged label Feb 27, 2024
@howardjohn howardjohn marked this pull request as ready for review February 27, 2024 22:57
@istio-testing istio-testing removed the do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. label Feb 27, 2024
Copy link
Contributor

@ilrudie ilrudie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. I have a few comments but nothing I suspect to be a show stopper for this direction.

#[derive(Clone, Debug, Serialize)]
pub struct ConnectionMetadata {
#[serde(default)]
identity: Option<Identity>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the implementation we've got it will be the source identity. I suppose keeping the type general would allow us to represent peer identity generically with the same type in the future though.

serve_request(&ct, remote_addr, req).await.or_else(|e| {
Ok(crate::hyper_util::plaintext_response(
StatusCode::UNPROCESSABLE_ENTITY,
e.to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to be concerned about e leaking something we shouldn't to the mds client?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its ok? I documented that we expose errors which could help a bit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can iterate if it becomes a problem later.

src/proxy/metadata.rs Outdated Show resolved Hide resolved
@@ -118,6 +133,19 @@ impl ConnectionManager {
// potentially large copy under read lock, could require optomization
self.drains.read().await.keys().cloned().collect()
}

/// fetch looks up a tuple and returns the connection metadata
// TODO: we should key on tuple so we can more efficiently lookup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe another index instead of re-keying? I suppose we could see about keying on tuple and storing the full ProxyRbacContext in the ConnectionDrain struct. Otherwise we'll need to do work to re-construct the full context when we need to assert.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I would probably do the index if we do it

@istio-testing istio-testing added needs-rebase Indicates a PR needs to be rebased before being merged size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 28, 2024
@istio-testing istio-testing removed the needs-rebase Indicates a PR needs to be rebased before being merged label Feb 29, 2024
ilrudie
ilrudie previously approved these changes Feb 29, 2024
Copy link
Contributor

@ilrudie ilrudie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@istio-testing istio-testing added the needs-rebase Indicates a PR needs to be rebased before being merged label Mar 15, 2024
@istio-testing
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@istio-testing
Copy link
Contributor

@howardjohn: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
test_ztunnel c8c232c link unknown /test test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@stevenctl
Copy link
Contributor

Do we still want to merge this anytime soon? Sorry I missed it.

@ilrudie
Copy link
Contributor

ilrudie commented May 15, 2024

IMO it's worth doing. also, I did not realize that my review would get retroactively upgraded... 😬

@ilrudie ilrudie dismissed their stale review May 15, 2024 21:32

months old, will take another look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR needs to be rebased before being merged release-notes-none Indicates a PR that does not require release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants