PMK-6388: fix prep-node failure with segmentation fault#400
Merged
mridulgain merged 1 commit intomasterfrom Feb 25, 2025
Merged
PMK-6388: fix prep-node failure with segmentation fault#400mridulgain merged 1 commit intomasterfrom
mridulgain merged 1 commit intomasterfrom
Conversation
Signed-off-by: Mridul Gain <mridul@platform9.com>
Contributor
Code Review Agent Run #a50a7bActionable Suggestions - 1
Review Details
|
Contributor
cruizen
approved these changes
Feb 25, 2025
vaibhavd21
approved these changes
Feb 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ISSUE(S):
https://platform9.atlassian.net/browse/PMK-6388
SUMMARY
Root cause: Error was not reported back correctly.
2023-09-06T17:49:09.0543Z DEBUG Running command https_proxy=http://qcwebproxylb.juniper.net:3128 bash "-c" "grep host_id /etc/pf9/host_id.conf | cut -d '=' -f2"stdout:stderr:grep: /etc/pf9/host_id.conf: No such file or directoryIn scenarios when "file is not found", it's expected to receive a non nil error.
When piping commands, the status code reported by
grepis overwritten by that ofcutWhich leads to a nil
err& despite of having error handling it fails to gracefully handle it and later panics with nil pointer dereference due to emptyhostIDinsideAuthorizeHostfunction.Suggested fix:
use
&&instead of|operator to achieve same behavior with correct exit status.ISSUE TYPE
IMPACTED FEATURES/COMPONENTS:
prepNodeRELATED ISSUE(S):
DEPENDS ON:
TESTING DONE
Automated
Manual
Prior to the fix: the
prep-nodeworkflow was going into panic, leading to segmentation fault.After the fix: It gracefully handles & reports the issue.
Reviewers
Summary by Bito
Fixed a bug in command pipeline error handling by replacing the pipe operator (|) with logical AND (&&) when reading host_id from /etc/pf9/host_id.conf. This change ensures proper error reporting from grep commands and prevents potential nil pointer dereference panics.Unit tests added: False
Estimated effort to review (1-5, lower is better): 1