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

*: Added errcheck and fixed not check errors [PART1]. #389

Merged
merged 1 commit into from
Jun 28, 2018
Merged

Conversation

bwplotka
Copy link
Member

Due to a high number of these issues, let's split the PR.

Thanks @asbjxrn for finding some not checked errors. This motivates us to fix all of these places. Some of them are serious, some not, but I think it is better to check all errors 100% time. (:

Signed-off-by: Bartek Plotka bwplotka@gmail.com

Changes

  • Added errcheck makefile step
  • Fixed some portion of not checked errors (mainly for bucket and commands)
  • Added runutil helpers for closing functions.

Verification

CI, errcheck

@@ -23,12 +24,12 @@ global:
testutil.Ok(t, err)

testutil.Ok(t, p.Start())
defer p.Stop()
defer func() { _ = p.Stop() }()
Copy link
Contributor

Choose a reason for hiding this comment

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

out of interest why this change? Is it due to error check needing to assign the error?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, errcheck requires explicit return to make sure we don't forget about someting. I think it makes sense. Let's use testutil.Ok here actually maybe (:

}

// There is already error, let's log this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit - whitesapce

@@ -363,33 +364,33 @@ func Repair(dir string, id ulid.ULID, source SourceType, ignoreChkFns ...ignoreF
if err != nil {
return resid, errors.Wrap(err, "open block")
}
defer b.Close()
defer runutil.BestEffortErr(nil, &err, b, "repair block reader")
Copy link
Contributor

Choose a reason for hiding this comment

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

how do you choose between BestEffortErr and LogOnErr?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ignore - I read the code again 😄

logger = log.NewLogfmtLogger(os.Stderr)
}

level.Warn(logger).Log("msg", "detected best effort error", "err", errors.Wrap(err, fmt.Sprintf(wrap, a...)))
Copy link
Contributor

Choose a reason for hiding this comment

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

This msg makes me think of the BestEffortErr func rather than LogOnErr ... maybe LogOnErr error closing?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point

Copy link
Contributor

@domgreen domgreen left a comment

Choose a reason for hiding this comment

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

LGTM ... only small nits and slight confusion msg logged in runutil

Due to high number of these issues, let's split the PR.

Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
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.

2 participants