-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Multiple fixes for k8s forwarder #5038
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awly
requested review from
a-palchikov,
fspmarshall,
klizhentas,
r0mant,
russjones and
webvictim
as code owners
December 2, 2020 23:59
a-palchikov
approved these changes
Dec 4, 2020
@@ -81,6 +81,12 @@ func (process *TeleportProcess) initKubernetesService(log *logrus.Entry, conn *C | |||
return trace.Wrap(err) | |||
} | |||
|
|||
// Start uploader that will scan a path on disk and upload completed | |||
// sessions to the Auth Server. | |||
if err := process.initUploaderService(accessPoint, conn.Client); err != nil { |
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.
Has this been moved here from somewhere or was it just missing and it was an error/omission?
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 was missing here due to omission
awly
force-pushed
the
andrew/kube-forwarder-fixes
branch
from
December 4, 2020 22:25
dc8ee86
to
ea847ed
Compare
r0mant
approved these changes
Dec 8, 2020
Using the request context can prevent audit events from getting emitted, if client disconnected and request context got closed. We shouldn't be losing audit events like that. Also, log all response errors from exec handler.
Rename a few config fields to be more descriptive. Avoid embedding unless necessary, to keep the package API clean.
The expensive part that we need to cache is the client certificate. Making a new one requires a round-trip to the auth server, plus entropy for crypto operations. The rest of clusterSession contains request-specific state, and only adds problems if cached. For example: clusterSession stores a reference to a remote teleport cluster (if needed); caching requires extra logic to invalidate the session when that cluster disappears (or tunnels drop out). Same problem happens with kubernetes_service tunnels. Instead, the forwarder now picks a new target for each request from the same user, providing a kind of "load-balancing".
It's started in all other services that upload sessions (app/proxy/ssh), but was missing here. Because of this, the session storage directory for async uploads wasn't created on disk and caused interactive sessions to fail.
awly
force-pushed
the
andrew/kube-forwarder-fixes
branch
from
December 8, 2020 17:24
ea847ed
to
9635274
Compare
awly
pushed a commit
that referenced
this pull request
Dec 8, 2020
* kube: emit audit events using process context Using the request context can prevent audit events from getting emitted, if client disconnected and request context got closed. We shouldn't be losing audit events like that. Also, log all response errors from exec handler. * kube: cleanup forwarder code Rename a few config fields to be more descriptive. Avoid embedding unless necessary, to keep the package API clean. * kube: cache only user certificates, not the entire session The expensive part that we need to cache is the client certificate. Making a new one requires a round-trip to the auth server, plus entropy for crypto operations. The rest of clusterSession contains request-specific state, and only adds problems if cached. For example: clusterSession stores a reference to a remote teleport cluster (if needed); caching requires extra logic to invalidate the session when that cluster disappears (or tunnels drop out). Same problem happens with kubernetes_service tunnels. Instead, the forwarder now picks a new target for each request from the same user, providing a kind of "load-balancing". * Init session uploader in kubernetes service It's started in all other services that upload sessions (app/proxy/ssh), but was missing here. Because of this, the session storage directory for async uploads wasn't created on disk and caused interactive sessions to fail.
awly
pushed a commit
that referenced
this pull request
Dec 10, 2020
* kube: emit audit events using process context Using the request context can prevent audit events from getting emitted, if client disconnected and request context got closed. We shouldn't be losing audit events like that. Also, log all response errors from exec handler. * kube: cleanup forwarder code Rename a few config fields to be more descriptive. Avoid embedding unless necessary, to keep the package API clean. * kube: cache only user certificates, not the entire session The expensive part that we need to cache is the client certificate. Making a new one requires a round-trip to the auth server, plus entropy for crypto operations. The rest of clusterSession contains request-specific state, and only adds problems if cached. For example: clusterSession stores a reference to a remote teleport cluster (if needed); caching requires extra logic to invalidate the session when that cluster disappears (or tunnels drop out). Same problem happens with kubernetes_service tunnels. Instead, the forwarder now picks a new target for each request from the same user, providing a kind of "load-balancing". * Init session uploader in kubernetes service It's started in all other services that upload sessions (app/proxy/ssh), but was missing here. Because of this, the session storage directory for async uploads wasn't created on disk and caused interactive sessions to fail.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
init session uploader in kubernetes service startup code
without this, session upload directory is not getting created and causes all recordings to fail
move the caching layer from then entire
clusterSession
to just the ephemeral user certsgenerating user certs on the fly is the expensive part we must cache
the rest of
clusterSession
has some fields that require extra handling for eviction: for example remote cluster orkubernetes_service
tunnels can disappear; caching the entireclusterSession
has little benefit performance-wiseuse process context for emitting audit events, not request context
request context can get cancelled by client disconnecting, losing us session.end events
clean up the code a bit, mostly get rid of all the embedding
Updates #5014