checks related fixes#787
Conversation
dseevr
left a comment
There was a problem hiding this comment.
LGTM aside from the capitalization stuff
There was a problem hiding this comment.
This should be all lowercase
| } | ||
| } | ||
| return errors.New("BGP connection persists") | ||
| return errors.New("bGP connection persists") |
| _, found := actVTEPs[vtep] | ||
| if !found { | ||
| return str, errors.New("VTEP " + vtep + " not found") | ||
| return str, errors.New("vTEP " + vtep + " not found") |
| _, found := actVTEPs[vtep] | ||
| if !found { | ||
| return str, errors.New("VTEP " + vtep + " not found") | ||
| return str, errors.New("vTEP " + vtep + " not found") |
| _, found := actVTEPs[vtep] | ||
| if !found { | ||
| return str, errors.New("VTEP " + vtep + " not found") | ||
| return str, errors.New("vTEP " + vtep + " not found") |
|
@dseevr: I've made the changes. PTAL |
jojimt
left a comment
There was a problem hiding this comment.
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.
| 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'") |
There was a problem hiding this comment.
I do not see the point of this change. The original string looks better to me.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This is also the convention that our errored repo follows
There was a problem hiding this comment.
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.
c437e95 to
8ff3c13
Compare
|
@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 |
31a3191 to
a418f42
Compare
|
This is running into some failures for some reason. I've got to look into this. |
|
This is only changing the error message format. I don't see how that is helping our tests. |
|
@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 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. |
60bcd54 to
81e2f3b
Compare
| if err == nil { | ||
| return nil, fmt.Errorf("EP %s already exists", req.EndpointID) | ||
| return nil, fmt.Errorf("the EP %s already exists", req.EndpointID) | ||
| } |
There was a problem hiding this comment.
can you change EP-> endpoint ?
|
|
||
| log.Errorf("Error making POST request. All master failed") | ||
| return errors.New("POST request failed") | ||
| return errors.New("the POST request failed") |
There was a problem hiding this comment.
In general if you are changing a string,
can you make it to more descriptive like "http POST request to master failed "
|
@unclejack can you fix the build failure ? |
|
@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) | ||
| } |
| 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") | ||
| } |
| 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 |
There was a problem hiding this comment.
Just to cover all the cases,
better make it independent case, (use string.Tolower(err.Error()) before comparison)
There was a problem hiding this comment.
@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.
|
LGTM other than the minor question/comment. |
|
Are there any other changes I should make for this? Please let me know. |
|
Is anyone still interested in this PR? |
rhim
left a comment
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
See the other comments in this PR discussion. This makes error messages composable
| 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) |
There was a problem hiding this comment.
EP has a specific meaning in contiv, and can be left as in.
|
@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>
b22e046 to
c12bcd6
Compare
|
I've fixed this, but the CI is failing. |
|
Is the k8s CI run expected to fail at this point? I remember there was some work in progress on it... |
|
@dseevr: It should work at this point. The failures are weird. |
|
ping @contiv/maintainers-core-networking. Please merge this PR. |
|
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. |

This PR makes the following changes:
make checksacross the entire repository, except for vendorThis was an issue whenever code was being modified in the test directory. Some files would end up being formatted by
gofmt. Thesegofmtrelated changes would appear in commits. It's a good idea to follow these rules for the entire code base and not play ping-pong withgofmtwhen making other changes.The fixes made to pass checks are the following:
gofmtall the code