-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
025dac7
to
0a7ea3a
Compare
0a7ea3a
to
fff3503
Compare
Codecov ReportAttention:
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. |
d570df4
to
68d4e7d
Compare
@@ -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) |
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.
Any reason you are ignoring the errors returned by Record
in internal/hook/item_hook_handler.go
but handling the errors in this file?
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.
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.
internal/hook/item_hook_handler.go
Outdated
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 { |
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.
trivial: it'd be better to limit the scope of the var err
to the if
clause and use hookFailed
in line 242
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.
Sure, let me make it more clear.
68d4e7d
to
be9e3fd
Compare
Signed-off-by: allenxu404 <qix2@vmware.com>
be9e3fd
to
6051b3c
Compare
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:
/kind changelog-not-required
as a comment on this pull request.site/content/docs/main
.