-
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
Refactor PodRunner and KubeTask to use PodController under the hood. #1986
Conversation
Thanks for submitting this pull request 🎉. The team will review it soon and get back to you. If you haven't already, please take a moment to review our project contributing guideline and Code of Conduct document. |
@e-sumin could you please fix the linter issues? |
539ea68
to
4b2e41d
Compare
f391dab
to
da035a9
Compare
pkg/kube/pod_runner.go
Outdated
// PodRunner allows us to start / stop pod, write file to pod and execute command within it | ||
type PodRunner interface { | ||
Run(ctx context.Context, fn func(context.Context, *v1.Pod) (map[string]interface{}, error)) (map[string]interface{}, error) | ||
RunEx(ctx context.Context, fn PodRunnerFunc) (PodOutputMap, error) |
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. I think we should either make named function types for both - Run and RunEx, or for none. The same is for the returned map type.
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 think we should add a comment where on why we have to methods that are doing to the same things. Basically what you have explained in the comment below.
Also, I think RunEx
is not very intuitive, do we have other alternate names :) ?
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've added the comment, but don't have better name. If you have something in mind, please suggest.
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.
@denisvmedia I made returned type similar for both functions, but was unable to invent name for functor type, so I left it as is.
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.
If no one has better names I suggest these:
PodAwareRunFunc
PodControllerAwareRunFunc
Also, as I previously said:
map[string]interface{}
=> PodOutputMap
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 am assuming that we are going to get rid of Run
method eventually. And then we can rename RunEx
to Run
.
I am ok with RunEx
as well.
Co-authored-by: Denis Voytyuk <5462781+denisvmedia@users.noreply.github.com>
@e-sumin, |
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 overall.
pkg/kube/pod_runner.go
Outdated
// PodRunner allows us to start / stop pod, write file to pod and execute command within it | ||
type PodRunner interface { | ||
Run(ctx context.Context, fn func(context.Context, *v1.Pod) (map[string]interface{}, error)) (map[string]interface{}, error) | ||
RunEx(ctx context.Context, fn PodRunnerFunc) (PodOutputMap, error) |
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 think we should add a comment where on why we have to methods that are doing to the same things. Basically what you have explained in the comment below.
Also, I think RunEx
is not very intuitive, do we have other alternate names :) ?
@viveksinghggits yep, there are several places where pod runner is used. I think it's better to refactor them in separate PRs, so that the reviewing process will be faster. |
@e-sumin please fix the signatures in the interface before merging. I put |
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.
Approving, we can merge after addressing Denis' interface signature comment.
Change Overview
Here is a PodRunner refactoring using previously added PodController and PodCommandExecutor.
Pull request type
Please check the type of change your PR introduces:
Test Plan