Skip to content
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

Merged
merged 2 commits into from
Aug 5, 2024
Merged

misc fixes #12

merged 2 commits into from
Aug 5, 2024

Conversation

synarete
Copy link
Collaborator

@synarete synarete commented Aug 5, 2024

Minor fixes as part of end-to-end testing with Samba, Ceph, cephadm and Promtheus.

The current default smbmetrics port number is 9922. Reflect this in
top-level README file.

Signed-off-by: Shachar Sharon <[email protected]>
@synarete synarete requested a review from anoopcs9 August 5, 2024 11:03
Copy link

@obnoxxx obnoxxx left a 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.

}
return vers, nil
return vers, status
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use a deferstatement for the return at the top of the function?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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]>
Copy link
Collaborator

@phlogistonjohn phlogistonjohn left a 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!

Copy link

@obnoxxx obnoxxx left a 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!

@obnoxxx obnoxxx merged commit 1dbb4ef into samba-in-kubernetes:main Aug 5, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants