-
Notifications
You must be signed in to change notification settings - Fork 5
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
misc fixes #12
misc fixes #12
Conversation
The current default smbmetrics port number is 9922. Reflect this in top-level README file. Signed-off-by: Shachar Sharon <[email protected]>
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.
This looks good in general, but see one comment/question about using defer
inline.
internal/metrics/versions.go
Outdated
} | ||
return vers, nil | ||
return vers, status |
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.
why not use a defer
statement for the return at the top of the function?
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.
Hmm, it looks to me like it would make an unnecessary complication to the code, and I don't think it is common by Go developers to use it for such cases.
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.
I am unclear on how defer would help here. I do find status
a bit odd. Maybe consider a pattern like:
var err, innerErr error
vers.foo, innerErr = doThing()
err = errors.Join(err, innerErr)
vers.bar, innerErr = doAnotherThing()
err = errors.Join(err, innerErr)
/* ... and so on ... */
return vers, err
I think that would simplify the function, but I won't demand it.
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.
Well, errors.Join
was added in Go 1.20, and I don't know what the lowest version of Go the project is trying to support, but I think it's worth consideration still.
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.
Agreed. errors.Join
would make the code cleaner. Will fix.
Do not bail-out in case of failure to resolve any of the sub-component versions but rather defer this failure to final status code. Required in order to avoid partial versions-view as part of exported status metric. Signed-off-by: Shachar Sharon <[email protected]>
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.
lgtm.
The Go code is clear and flat now, looks nice!
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.
I agree this is nice and clear now.
LGTM, thanks!
Minor fixes as part of end-to-end testing with Samba, Ceph, cephadm and Promtheus.