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

Fix error handling about bridgeSetup #2215

Merged
merged 1 commit into from
Jul 5, 2018
Merged

Fix error handling about bridgeSetup #2215

merged 1 commit into from
Jul 5, 2018

Conversation

hzue
Copy link
Contributor

@hzue hzue commented Jul 1, 2018

Fix the error from bridgeSetup doesn't handle by the defer function in the createNetwork function.

Signed-off-by: Terry Chu jubosh.tw@gmail.com

@@ -735,7 +735,11 @@ func (d *driver) createNetwork(config *networkConfiguration) error {

// Apply the prepared list of steps, and abort at the first error.
bridgeSetup.queueStep(setupDeviceUp)
return bridgeSetup.apply()
if err = bridgeSetup.apply(); err != nil {

Choose a reason for hiding this comment

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

would be better if you change the method prototype like this:

func (d *driver) createNetwork(config *networkConfiguration) (err error) {

and remove line 618
that way we are sure that if the body of this function has a return the defer is still being honored

Copy link
Contributor

Choose a reason for hiding this comment

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

If we were going that route I'd probably suggest something less generic than err. It's almost idiomatic to shadow it.

@fcrisciani
Copy link

Thanks @hzue, I left a comment on the patch

Copy link
Contributor

@ctelfer ctelfer left a comment

Choose a reason for hiding this comment

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

LGTM -- hate these types of errors!

Fix the error from bridgeSetup doesn't handle by the defer function in the createNetwork function.

Signed-off-by: Terry Chu <jubosh.tw@gmail.com>
@hzue
Copy link
Contributor Author

hzue commented Jul 5, 2018

Hi @fcrisciani @ctelfer, thanks for your advice.
I have updated the commit.

@ctelfer
Copy link
Contributor

ctelfer commented Jul 5, 2018

Still LGTM.

Copy link

@fcrisciani fcrisciani left a comment

Choose a reason for hiding this comment

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

LGTM

@fcrisciani
Copy link

Thanks @hzue

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