-
Notifications
You must be signed in to change notification settings - Fork 78
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
MINOR: kern_procargs more robust on darwin #78
MINOR: kern_procargs more robust on darwin #78
Conversation
This failure should not be related to changes. |
When working on elastic#78, I was hit by a test failing on linux (debian host) Our code is triming values so we need to adjust the test code to make sure we also trim values before doing the comparison. Example: ``` expected: "${debian_chroot:+($debian_chroot)}\\u@\\h:\\w\\$ " actual: "${debian_chroot:+($debian_chroot)}\\u@\\h:\\w\\$" ```
When working on elastic#78, I was hit by a test failing on linux (debian host) Our code is triming values so we need to adjust the test code to make sure we also trim values before doing the comparison. Example: ``` expected: "${debian_chroot:+($debian_chroot)}\\u@\\h:\\w\\$ " actual: "${debian_chroot:+($debian_chroot)}\\u@\\h:\\w\\$" ```
When working on elastic#78, I was hit by a test failing on linux (debian host) Our code is triming values so we need to adjust the test code to make sure we also trim values before doing the comparison. Example: ``` expected: "${debian_chroot:+($debian_chroot)}\\u@\\h:\\w\\$ " actual: "${debian_chroot:+($debian_chroot)}\\u@\\h:\\w\\$" ```
4ccc5c9
to
876f407
Compare
Require #79 to make the test green under linux. |
sigar_darwin.go
Outdated
@@ -420,7 +420,12 @@ func kern_procargs(pid int, | |||
return fmt.Errorf("Error reading args: %v", err) | |||
} | |||
pair := bytes.SplitN(chop(line), delim, 2) | |||
env(string(pair[0]), string(pair[1])) | |||
|
|||
if len(pair) == 2 { |
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.
It seems more common in Go to check for the error case and omit the else
(i.e. if len != 2 { return error }
).
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.
+1 will make the changes
When working on #78, I was hit by a test failing on linux (debian host) Our code is triming values so we need to adjust the test code to make sure we also trim values before doing the comparison. Example: ``` expected: "${debian_chroot:+($debian_chroot)}\\u@\\h:\\w\\$ " actual: "${debian_chroot:+($debian_chroot)}\\u@\\h:\\w\\$" ```
@andrewkroh updated with comments from the review. |
82cfe9e
to
b9dbf3b
Compare
Under some circonstance the code can fail, the root cause is not clear at the moment, but we should still make the code more robust when retrieving information for a specific process. The problem is the `bytes.SplitN` can return an array of one element making the process panic when we access the other element. This commit make the code a bit more robust and check to make sure we successfully retrieved 2 elements instead of one and return an error if it failed. Reference: elastic/beats#5337
b9dbf3b
to
d81aa9d
Compare
@ph Would you like to make a release and update the vendored copy in beats? (or I can do it) |
@andrewkroh I can do it, its only a matter of doing the following?
|
@ph Exactly. Plus add back the "Unreleased" placeholder to the changelog after tagging. That's not really required but it's nice touch for the next person that makes a change. |
Under some circonstance the code can fail, the root cause is not clear
at the moment, but we should still make the code more robust when
retrieving information for a specific process.
The problem is the
bytes.SplitN
can return an array of one elementmaking the process panic when we access the other element.
This commit make the code a bit more robust and check to make sure we
successfully retrieved 2 elements instead of one and return an error
if it failed.
Reference: elastic/beats#5337