-
Notifications
You must be signed in to change notification settings - Fork 152
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
Add New ExecOutput Function To Support Custom Writers #1331
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
ihcsim
changed the title
Add New ExecAsync Function To Stream Remote Outputs
Add New ExecAsync Function To Stream Inbound Outputs
Mar 25, 2022
ihcsim
force-pushed
the
exec-async
branch
2 times, most recently
from
March 30, 2022 20:58
f4ac288
to
40e802b
Compare
ihcsim
changed the title
Add New ExecAsync Function To Stream Inbound Outputs
Add New ExecOutput Function To Stream Inbound Outputs
Apr 11, 2022
ihcsim
changed the title
Add New ExecOutput Function To Stream Inbound Outputs
Add New ExecOutput Function To Support Custom Writers
Apr 11, 2022
pavannd1
reviewed
Apr 28, 2022
ihcsim
force-pushed
the
exec-async
branch
2 times, most recently
from
May 3, 2022 01:45
17c673f
to
481a08a
Compare
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
This new library function works like kube.Exec(), except that it writes the inbound outputs to stdout and stderr immediately. It delegates the writes to a new format.Writer instance, which formats the outputs to match the Kanister-style logs, before writing them to either stdout or stderr. This ensures that the outputs of the remote exec operation is available to log consumers immediately. Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
pavannd1
approved these changes
May 3, 2022
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
This was referenced May 5, 2022
akankshakumari393
pushed a commit
that referenced
this pull request
May 9, 2022
* Stream output from KubeExec * Set error in pipe readers instead of a channel * Fix compile errors Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com> * Handle returned error by exec stream Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com> * Don't add error while closing pipe Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com> * Add a new kube.ExecAsync() function to handle async 'exec' outputs This new library function works like kube.Exec(), except that it writes the inbound outputs to stdout and stderr immediately. It delegates the writes to a new format.Writer instance, which formats the outputs to match the Kanister-style logs, before writing them to either stdout or stderr. This ensures that the outputs of the remote exec operation is available to log consumers immediately. Signed-off-by: Ivan Sim <ivan.sim@kasten.io> * Remove merge error Signed-off-by: Ivan Sim <ivan.sim@kasten.io> * Fix unit test Signed-off-by: Ivan Sim <ivan.sim@kasten.io> * Add stdout and stderr as function params Signed-off-by: Ivan Sim <ivan.sim@kasten.io> * Handle phase outputs found in stdout Signed-off-by: Ivan Sim <ivan.sim@kasten.io> Co-authored-by: Tom Manville <tom@kasten.io> Co-authored-by: Prasad Ghangal <prasad.ghangal@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
10 tasks
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.
Change Overview
This PR introduces a new
kube.ExecOutput()
library function that can writekube.Exec()
outputs to custom writers, allowing callers to provide either buffered writers or async (pipe) writers. This new function delegates the writes operation to a newformat.Writer
instance that formats the outputs to match the Kanister-style logs, before writing them to the custom writers.The
KubeExec
Kanister function has been updated to usekube.ExecOutput()
, withos.Stdout
andos.Stderr
. Other callers in thepkg/app
andpkg/function
packages remain untouched. By offering bothkube.Exec()
andkube.ExecAsync()
, downstream has the flexibility to decide which output mechanism to use, based on their use cases.Pull request type
Please check the type of change your PR introduces:
Issues
Follow-up of:
Test Plan
Deploy this
timer
pod that has a script to tail the current datetime at one second interval:Deploy this blueprint that uses
KubeExec
to invoke the remote script in thetimer
pod:Creates the actionset to trigger the function call:
Observe the datetime being streamed to the Kanister operator's logs: