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

Enhance hooks tracker by adding an returned error to record function #7153

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

allenxu404
Copy link
Contributor

Thank you for contributing to Velero!

Please add a summary of your change

Does your change fix a particular issue?

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Created a changelog file or added /kind changelog-not-required as a comment on this pull request.
  • Updated the corresponding documentation in site/content/docs/main.

@allenxu404 allenxu404 changed the title Enhance hooks tracker by add an error as return value to record function Enhance hooks tracker by adding an returned error to record function Nov 28, 2023
Copy link

codecov bot commented Nov 28, 2023

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (85482ae) 61.77% compared to head (6051b3c) 61.78%.
Report is 21 commits behind head on main.

Files Patch % Lines
internal/hook/item_hook_handler.go 66.66% 4 Missing and 2 partials ⚠️
internal/hook/wait_exec_hook_handler.go 80.00% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #7153    +/-   ##
========================================
  Coverage   61.77%   61.78%            
========================================
  Files         259      261     +2     
  Lines       27859    27994   +135     
========================================
+ Hits        17210    17295    +85     
- Misses       9445     9479    +34     
- Partials     1204     1220    +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@allenxu404 allenxu404 force-pushed the hooktracker-update branch 2 times, most recently from d570df4 to 68d4e7d Compare November 28, 2023 11:01
@reasonerjt reasonerjt added this to the v1.13 milestone Dec 4, 2023
@@ -166,7 +166,11 @@ func (e *DefaultWaitExecHookHandler) HandleHooks(
err := fmt.Errorf("hook %s in container %s expired before executing", hook.HookName, hook.Hook.Container)
hookLog.Error(err)
errors = append(errors, err)
hookTracker.Record(newPod.Namespace, newPod.Name, hook.Hook.Container, hook.HookSource, hook.HookName, hookPhase(""), true)

trackerErr := hookTracker.Record(newPod.Namespace, newPod.Name, hook.Hook.Container, hook.HookSource, hook.HookName, hookPhase(""), true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason you are ignoring the errors returned by Record in internal/hook/item_hook_handler.go
but handling the errors in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Record error was ignored in internal/hook/item_hook_handler.go just for simplicity, which I consider might not be a good behavior.

Will change it.

hookTracker.Record(namespace, name, hookFromAnnotations.Container, HookSourceAnnotation, "", phase, false)
if err := h.PodCommandExecutor.ExecutePodCommand(hookLog, obj.UnstructuredContent(), namespace, name, "<from-annotation>", hookFromAnnotations); err != nil {
hookFailed := false
if err = h.PodCommandExecutor.ExecutePodCommand(hookLog, obj.UnstructuredContent(), namespace, name, "<from-annotation>", hookFromAnnotations); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

trivial: it'd be better to limit the scope of the var err to the if clause and use hookFailed in line 242

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, let me make it more clear.

Signed-off-by: allenxu404 <qix2@vmware.com>
@blackpiglet blackpiglet merged commit 45ae685 into vmware-tanzu:main Dec 5, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants