-
Notifications
You must be signed in to change notification settings - Fork 55
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
improve error handling and signal management #61
base: main
Are you sure you want to change the base?
Conversation
- Replaced manual signal handling with `signal.NotifyContext` for cleaner shutdown management. - Introduced `fatal` helper function to reduce redundant error handling and improve readability. - Used `defer` to ensure proper resource cleanup for file and reader operations. - Consolidated and streamlined control flow between server mode and job mode. - Improved logging messages and ensured Cloud Profiler properly logs initialization failures. Signed-off-by: Radoslav Petkov <156192995+RadoslavPetkow@users.noreply.github.com>
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.
@RadoslavPetkow
First of all, thank you for contributing to our code!
I learned many things from your code, which seems to be very idiomatic in Golang and easier to read. I'm really happy to review this good PR as our first PR contributing the code base.
There is a nit fix and a part that we need to ask you to fix. Let me know if you think there is a better solution rather than my suggestion. We are open to improve.
} | ||
|
||
var taskSetRegistrer []inspection.PrepareInspectionServerFunc = make([]inspection.PrepareInspectionServerFunc, 0) | ||
var taskSetRegistrer []inspection.PrepareInspectionServerFunc |
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.
var taskSetRegistrer []inspection.PrepareInspectionServerFunc | |
var taskSetRegistrer []inspection.PrepareInspectionServerFunc = make([]inspection.PrepareInspectionServerFunc, 0) |
The reason taskSetRegisterer
is initialized with an empty array is actually so that multiple files in the cmd
folder have init()
and can easily extend the list of tasks.
For example, a user who wants to add functionality for their internal purpose can add a file like private.go
to cmd/kubernetes-history-inspector/
, add a task to init()
to add some set of tasks for their internal purpose, and customize it for internal use by ignoring only private.go
with .gitignore
.
I know it's impossible to get this purpose just from this code, but this is why we initialized the array with empty array and append tasks on init()
instead of assigning a value to the taskRegisterer
.
"sync" | ||
|
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.
"sync" |
nit: This no longer seems to be used anymore.
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.
And this is the failure reason of the Github Action
// Register inspection server preparation functions. | ||
taskSetRegistrer = []inspection.PrepareInspectionServerFunc{ | ||
common.PrepareInspectionServer, | ||
gcp.PrepareInspectionServer, | ||
} |
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.
We can't directly assign the value to the variable because of the reason that I commented few lines before. But thank you for adding comment to make it clear.
// Register inspection server preparation functions. | |
taskSetRegistrer = []inspection.PrepareInspectionServerFunc{ | |
common.PrepareInspectionServer, | |
gcp.PrepareInspectionServer, | |
} | |
// Register inspection server preparation functions. | |
taskSetRegistrer = append(taskSetRegistrer, common.PrepareInspectionServer) | |
taskSetRegistrer = append(taskSetRegistrer, gcp.PrepareInspectionServer) |
Just for a record. I verified the backend tests are passing on my local computer, even though there is no tests affected by this change. |
Hi , Thanks a lot for taking the time to review my PR and for your kind words! I really appreciate the detailed feedback and the insights you shared about the design choices in the codebase. Feedback Points:
Thanks again for the thoughtful review and for helping me contribute to this project! Best, |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I’ve addressed the requested changes by improving error handling and optimizing redundant logic. The code now avoids panic, ensuring safer execution, and refactors redundant HSL conversions. Let me know if further adjustments are needed. Signed-off-by: Radoslav Petkov <156192995+RadoslavPetkow@users.noreply.github.com>
@RadoslavPetkow Thank you for keeping working on this. But your last change seems to do something wrong. |
You’re right! It can be reverted to the last correct version, right? |
Yes, you just need to checkout the previous revision and commit the change that you actually wanted to and push it. |
@RadoslavPetkow How should we proceed this? |
signal.NotifyContext
for cleaner shutdown management.fatal
helper function to reduce redundant error handling and improve readability.defer
to ensure proper resource cleanup for file and reader operations.