checks related fixes by unclejack · Pull Request #787 · contiv/netplugin · GitHub
Skip to content

checks related fixes#787

Merged
srampal merged 2 commits into
contiv:masterfrom
unclejack:checks_fixes
Sep 21, 2017
Merged

checks related fixes#787
srampal merged 2 commits into
contiv:masterfrom
unclejack:checks_fixes

Conversation

@unclejack

Copy link
Copy Markdown
Contributor

This PR makes the following changes:

  • fixes the issues reported by make checks across the entire repository, except for vendor
  • removes the exception which excluded the test directory from all tests

This was an issue whenever code was being modified in the test directory. Some files would end up being formatted by gofmt. These gofmt related changes would appear in commits. It's a good idea to follow these rules for the entire code base and not play ping-pong with gofmt when making other changes.

The fixes made to pass checks are the following:

  • remove punctuation from the end of the errors
  • make errors start with a lowercase character
  • gofmt all the code
  • rename one variable in the tests to pass checks

@dseevr dseevr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM aside from the capitalization stuff

Comment thread test/systemtests/bgp_test.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be all lowercase

Comment thread test/systemtests/bgp_test.go Outdated
}
}
return errors.New("BGP connection persists")
return errors.New("bGP connection persists")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here

Comment thread test/systemtests/docker_test.go Outdated
_, found := actVTEPs[vtep]
if !found {
return str, errors.New("VTEP " + vtep + " not found")
return str, errors.New("vTEP " + vtep + " not found")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here

Comment thread test/systemtests/k8setup_test.go Outdated
_, found := actVTEPs[vtep]
if !found {
return str, errors.New("VTEP " + vtep + " not found")
return str, errors.New("vTEP " + vtep + " not found")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here

Comment thread test/systemtests/swarm_test.go Outdated
_, found := actVTEPs[vtep]
if !found {
return str, errors.New("VTEP " + vtep + " not found")
return str, errors.New("vTEP " + vtep + " not found")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here

@unclejack

Copy link
Copy Markdown
Contributor Author

@dseevr: I've made the changes. PTAL

@jojimt jojimt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like this PR changes the capitalization of the first letter of a whole bunch of messages from upper case to lower case. It is unclear what value this adds. Can we not do this? It is likely to cause confusion/inconsistency as we print these errors in many paces, in a variety of formats.

Comment thread drivers/ovsSwitch.go
default:
log.Errorf("Invalid datapath mode")
return nil, errors.New("Invalid forwarding mode. Expects 'bridge' or 'routing'")
return nil, errors.New("invalid forwarding mode. Expects 'bridge' or 'routing'")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I do not see the point of this change. The original string looks better to me.

@unclejack unclejack Mar 17, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The point of this change is that error messages are meant to start with a lowercase letter and not have any punctuation at the end.

The goal of this convention is to be able to compose errors nicely. If you run into an error, you can do something like return fmt.Errorf("encountered error while opening file: %v", err); this error would be composable even further, e.g.: "failed to save data: encountered error while opening file: file doesn't exist".

There are some language conventions which should be followed. Others follow these conventions as well. I didn't come up with these conventions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is also the convention that our errored repo follows

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/pkg/errors is also using lowercase letters for the errors. The static analysis tools we use are used by other repositories as well. This is more of a convention, rather than a personal preference.

@unclejack unclejack force-pushed the checks_fixes branch 3 times, most recently from c437e95 to 8ff3c13 Compare March 28, 2017 16:40
@dseevr

dseevr commented May 26, 2017

Copy link
Copy Markdown
Contributor

@unclejack could you take a quick look at getting this one passing, too? I think this would be worthwhile to get merged as a step towards cleaning up our tests

@unclejack unclejack force-pushed the checks_fixes branch 2 times, most recently from 31a3191 to a418f42 Compare May 26, 2017 05:57
@unclejack

Copy link
Copy Markdown
Contributor Author

This is running into some failures for some reason. I've got to look into this.

@gkvijay

gkvijay commented May 26, 2017

Copy link
Copy Markdown
Member

This is only changing the error message format. I don't see how that is helping our tests.

@unclejack

Copy link
Copy Markdown
Contributor Author

@gkvijay: This PR is also removing a blacklist which prevents any kind of code quality tool on the tests themselves. The changes I've made are the ones needed to make it possible to run those tools on the code base. Please feel free to try the other commit on a code checkout to see how make checks fails.

I've had issues in the past where I had to craft PRs just to avoid gofmt related changes because the code wasn't properly formatted. We still have code in tests which isn't properly formatted. Obviously, this can never stop if we have the test directory in the blacklist.

@unclejack unclejack force-pushed the checks_fixes branch 3 times, most recently from 60bcd54 to 81e2f3b Compare June 26, 2017 15:25
if err == nil {
return nil, fmt.Errorf("EP %s already exists", req.EndpointID)
return nil, fmt.Errorf("the EP %s already exists", req.EndpointID)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you change EP-> endpoint ?

Comment thread netplugin/cluster/cluster.go Outdated

log.Errorf("Error making POST request. All master failed")
return errors.New("POST request failed")
return errors.New("the POST request failed")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In general if you are changing a string,
can you make it to more descriptive like "http POST request to master failed "

@rchirakk

Copy link
Copy Markdown
Contributor

@unclejack can you fix the build failure ?
let's merge it in 1.1 or post 1.1

@unclejack

Copy link
Copy Markdown
Contributor Author

@rchirakk: I've fixed the PR. The CI is running into some issues, but the issue is confirmed to be fixed. Perhaps this should be merged after 1.1. We can include it in 1.1.1.

if !ok {
return -1, fmt.Errorf("Invalid nw name space: %v", ns)
return -1, fmt.Errorf("invalid network namespace: %v", ns)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

log.Errorf("Got `tc qdisco show` output:\n%s", qdiscShow)
return fmt.Errorf("Unexpected `tc qdisco show` output")
return fmt.Errorf("unexpected `tc qdisc show` output")
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no more disco 👍

Comment thread core/error.go
func ErrIfKeyExists(err error) error {
if err == nil || strings.Contains(err.Error(), "Key not found") {
if err == nil || strings.Contains(err.Error(), "key not found") {
return nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just to cover all the cases,
better make it independent case, (use string.Tolower(err.Error()) before comparison)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@rchirakk: This was just a quick fix for us to be able to use gofmt, go vet, golint and the other tools on the entire code base. I intend to send some more PRs to refactor the error handling across the code base. I'd rather focus on starting the refactor work to avoid such issues in the future and make our code better.

@rchirakk

Copy link
Copy Markdown
Contributor

LGTM other than the minor question/comment.
@gkvijay @DivyaVavili possible candidate for 1.1.1 ?

@unclejack

Copy link
Copy Markdown
Contributor Author

Are there any other changes I should make for this? Please let me know.

@unclejack

Copy link
Copy Markdown
Contributor Author

The 1.1.x release is out.

We need to move forward with this PR.

/cc @DivyaVavili @gkvijay @rchirakk @rhim

@unclejack

Copy link
Copy Markdown
Contributor Author

Is anyone still interested in this PR?

@rhim rhim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Minor comments. Once CI is clean, it is OK to merge.

return nil, err
}
return &data, fmt.Errorf("Internal Server Error")
return &data, fmt.Errorf("internal Server Error")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lower case all words?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See the other comments in this PR discussion. This makes error messages composable

Comment thread mgmtfn/k8splugin/driver.go Outdated
ep, err := netdGetEndpoint(netID + "-" + req.EndpointID)
if err == nil {
return nil, fmt.Errorf("EP %s already exists", req.EndpointID)
return nil, fmt.Errorf("the endpoint %s already exists", req.EndpointID)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

EP has a specific meaning in contiv, and can be left as in.

@rhim

rhim commented Sep 11, 2017

Copy link
Copy Markdown
Contributor

@unclejack please rebase and resubmit to get it merged in.

Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
@unclejack

Copy link
Copy Markdown
Contributor Author

I've fixed this, but the CI is failing.

@dseevr

dseevr commented Sep 12, 2017

Copy link
Copy Markdown
Contributor

Is the k8s CI run expected to fail at this point? I remember there was some work in progress on it...

@unclejack

Copy link
Copy Markdown
Contributor Author

@dseevr: It should work at this point. The failures are weird.

@unclejack

Copy link
Copy Markdown
Contributor Author

@dseevr @rhim: This should be good to go now. PTAL

@rhim

rhim commented Sep 18, 2017

Copy link
Copy Markdown
Contributor

ping @contiv/maintainers-core-networking. Please merge this PR.

@unclejack

Copy link
Copy Markdown
Contributor Author

Is there something else I should do to get this PR merged? Does anyone have any questions or concerns related to this? I'd rather address any concerns now and not require another rebase and test cycle.

@rhim

rhim commented Sep 21, 2017 via email

Copy link
Copy Markdown
Contributor

@srampal srampal merged commit a2e4909 into contiv:master Sep 21, 2017
@unclejack unclejack deleted the checks_fixes branch September 21, 2017 21:18
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.

7 participants