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

Refactor functions with pod runner #2308

Merged
merged 15 commits into from
Sep 20, 2023
Merged

Conversation

e-sumin
Copy link
Contributor

@e-sumin e-sumin commented Sep 6, 2023

Change Overview

This PR contains refactoring of all invokers of PodRunner.Run as it was proposed in issue #2070
Now all invokers are using PodRunner.RunEx which invokes functor with PodController instance.

Pull request type

Please check the type of change your PR introduces:

  • 🚧 Work in Progress
  • 🌈 Refactoring (no functional changes, no api changes)
  • 🐹 Trivial/Minor
  • 🐛 Bugfix
  • 🌻 Feature
  • 🗺️ Documentation
  • 🤖 Test

Issues

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2023

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
Copy link
Contributor Author

e-sumin commented Sep 6, 2023

I didn't split this PR to the train, because almost all changes are pretty similar. Also, you can review it commit by commit as they logically separated, this will simplify your work.

Comment on lines 126 to 127
format.LogWithCtx(ctx, pod.Name, pod.Spec.Containers[0].Name, logs)
out, err := parseLogAndCreateOutput(logs)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have strong feeling that this is almost equal to

		out, err := output.LogAndParse(ctx, r)

where r is an io.ReaderCloser instance.

but decided not to change it in this PR to not bring irrelevant changes.

Comment on lines +105 to +108
var stdout, stderr bytes.Buffer
err = commandExecutor.Exec(ctx, cmd, nil, &stdout, &stderr)
format.LogWithCtx(ctx, pod.Name, pod.Spec.Containers[0].Name, stdout.String())
format.LogWithCtx(ctx, pod.Name, pod.Spec.Containers[0].Name, stderr.String())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is very common pattern in functions - execute, log and then analyze output.
we can extract this functionality to utils and then reuse everywhere to reduce amount of code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also not sure whether we need to wait until end of execution and log at the end, probably we can log on the fly, since we passing io.Writer to Exec function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. Could you please create a GitHub issue with this suggestion? It could be good for first-time contributors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@chaitalisg chaitalisg left a comment

Choose a reason for hiding this comment

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

Looks pretty straight forward. Approved!

pkg/function/backup_data_stats.go Outdated Show resolved Hide resolved
Comment on lines +105 to +108
var stdout, stderr bytes.Buffer
err = commandExecutor.Exec(ctx, cmd, nil, &stdout, &stderr)
format.LogWithCtx(ctx, pod.Name, pod.Spec.Containers[0].Name, stdout.String())
format.LogWithCtx(ctx, pod.Name, pod.Spec.Containers[0].Name, stderr.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. Could you please create a GitHub issue with this suggestion? It could be good for first-time contributors

pkg/function/checkRepository.go Outdated Show resolved Hide resolved
pkg/function/checkRepository.go Outdated Show resolved Hide resolved
pkg/function/copy_volume_data.go Outdated Show resolved Hide resolved
pkg/function/delete_data.go Outdated Show resolved Hide resolved
pkg/function/delete_data.go Outdated Show resolved Hide resolved
pkg/function/describe_backups.go Outdated Show resolved Hide resolved
pkg/function/describe_backups.go Outdated Show resolved Hide resolved
pkg/function/restore_data.go Outdated Show resolved Hide resolved
@e-sumin e-sumin requested a review from pavannd1 September 14, 2023 14:01
@e-sumin e-sumin force-pushed the refactor_functions_with_pod_runner branch from c4c35e7 to db19f7f Compare September 19, 2023 10:13
@e-sumin e-sumin added the kueue label Sep 20, 2023
@mergify mergify bot merged commit bef2520 into master Sep 20, 2023
14 checks passed
@mergify mergify bot deleted the refactor_functions_with_pod_runner branch September 20, 2023 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

PodRunner.Run invokers should be refactored using PodController.
3 participants