Skip to content

Add warning message for the failure of deleting link device#2085

Merged
fcrisciani merged 1 commit intomoby:masterfrom
luzhipeng-zte:linkdel
Mar 6, 2018
Merged

Add warning message for the failure of deleting link device#2085
fcrisciani merged 1 commit intomoby:masterfrom
luzhipeng-zte:linkdel

Conversation

@luzhipeng-zte
Copy link
Copy Markdown
Contributor

We can know the reason for the failure of deleting the link device.

Signed-off-by: ZhiPeng Lu [email protected]

@fcrisciani
Copy link
Copy Markdown

@luzhipeng-zte thanks for the contributions, right now the CI fails because of: please format Go code with 'gofmt -s -w'

Comment thread drivers/bridge/bridge.go Outdated
if link, err := d.nlh.LinkByName(ep.srcName); err == nil {
d.nlh.LinkDel(link)
if dellinkerr := d.nlh.LinkDel(link); dellinkerr != nil {
logrus.Warnf("Failed to delete interface (%s)'s link on endpoint (%s) delete: %v", ep.srcName, ep.id, dellinkerr)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can you use the format with: logrus.WithError(dellinkerr).Warnf

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you maybe want this to be Errorf

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.

Thanks. i think using the same formats better

Comment thread drivers/ipvlan/ipvlan_endpoint.go Outdated
if link, err := ns.NlHandle().LinkByName(ep.srcName); err == nil {
ns.NlHandle().LinkDel(link)
if dellinkerr := ns.NlHandle().LinkDel(link); dellinkerr != nil {
logrus.Warnf("Failed to delete interface (%s)'s link on endpoint (%s) delete: %v", ep.srcName, ep.id, dellinkerr)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maybe instead of (%s) you can use %q that will keep the string "quoted"

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.

ok

Comment thread drivers/bridge/bridge.go Outdated
}
if link, err := d.nlh.LinkByName(ep.srcName); err == nil {
d.nlh.LinkDel(link)
if dellinkerr := d.nlh.LinkDel(link); dellinkerr != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you can also simply use err := d.nlh.LinkDel(link) err will shadows the other err but is fine

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.

ok

@fcrisciani fcrisciani requested a review from selansen February 23, 2018 21:42
Copy link
Copy Markdown
Contributor

@selansen selansen left a comment

Choose a reason for hiding this comment

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

you can reuse err instead of adding new variable dellinkerr. This can be applicable all the places.

@selansen
Copy link
Copy Markdown
Contributor

Did you fix CI failure ?

@luzhipeng-zte luzhipeng-zte force-pushed the linkdel branch 2 times, most recently from f68c909 to feac87d Compare February 27, 2018 10:58
@codecov-io
Copy link
Copy Markdown

codecov-io commented Feb 27, 2018

Codecov Report

Merging #2085 into master will increase coverage by 0.02%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2085      +/-   ##
==========================================
+ Coverage   40.38%   40.41%   +0.02%     
==========================================
  Files         139      139              
  Lines       22356    22361       +5     
==========================================
+ Hits         9029     9037       +8     
+ Misses      12000    11995       -5     
- Partials     1327     1329       +2
Impacted Files Coverage Δ
drivers/macvlan/macvlan_network.go 0% <0%> (ø) ⬆️
drivers/macvlan/macvlan_endpoint.go 0% <0%> (ø) ⬆️
drivers/ipvlan/ipvlan_network.go 0% <0%> (ø) ⬆️
drivers/ipvlan/ipvlan_endpoint.go 0% <0%> (ø) ⬆️
drivers/overlay/ov_network.go 2.8% <0%> (-0.01%) ⬇️
drivers/bridge/bridge.go 55% <0%> (-0.42%) ⬇️
cmd/proxy/tcp_proxy.go 82.97% <0%> (-2.13%) ⬇️
service_common.go 7.1% <0%> (+0.13%) ⬆️
networkdb/delegate.go 75.09% <0%> (+0.73%) ⬆️
networkdb/cluster.go 63.3% <0%> (+1.97%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f6d309...3141524. Read the comment docs.

@luzhipeng-zte
Copy link
Copy Markdown
Contributor Author

@selansen @fcrisciani , i have updated the PR.
thanks

Comment thread drivers/bridge/bridge.go Outdated
if link, err := d.nlh.LinkByName(ep.srcName); err == nil {
d.nlh.LinkDel(link)
if err := d.nlh.LinkDel(link); err != nil {
logrus.WithError(err).Errorf("Failed to delete interface (%q)'s link on endpoint (%q) delete", ep.srcName, ep.id)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

sorry probably I was not clear in the previous comment, what I was suggesting is that if you use the formatter %q you can remove the brackets.
See here the difference: https://play.golang.com/p/HBUIUuAx7UE
(%q) seems too much

@luzhipeng-zte luzhipeng-zte force-pushed the linkdel branch 3 times, most recently from 165c2c5 to cbfd981 Compare March 1, 2018 00:25
@GordonTheTurtle
Copy link
Copy Markdown

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "linkdel" [email protected]:luzhipeng-zte/libnetwork.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842354473656
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

@luzhipeng-zte
Copy link
Copy Markdown
Contributor Author

ping @fcrisciani @selansen, i have updated the PR. could you take a look ?
Thanks.

Comment thread drivers/bridge/bridge.go Outdated
defer func() {
if err != nil {
d.nlh.LinkDel(host)
if dellinkerr := d.nlh.LinkDel(host); dellinkerr != 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.

Can we reuse err instead of dellinkerr like above change ?

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.

I worry that this will overwrite the previous errorand the error of LinkDel can be recorded by log

Comment thread drivers/bridge/bridge.go Outdated
defer func() {
if err != nil {
d.nlh.LinkDel(sbox)
if dellinkerr := d.nlh.LinkDel(sbox); dellinkerr != 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.

Can we reuse err instead of dellinkerr like above change ?

@luzhipeng-zte
Copy link
Copy Markdown
Contributor Author

@selansen, i have updated the PR.
Thanks.

@selansen
Copy link
Copy Markdown
Contributor

selansen commented Mar 4, 2018

LGTM

Comment thread drivers/bridge/bridge.go Outdated
if err != nil {
d.nlh.LinkDel(sbox)
if err := d.nlh.LinkDel(sbox); err != nil {
logrus.WithError(err).Warnf("Failed to del sandbox side interface (%s)'s link", containerIfName)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

here should still be delete

@luzhipeng-zte
Copy link
Copy Markdown
Contributor Author

ping @fcrisciani , i have updated the PR.
Thanks

Copy link
Copy Markdown

@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 fcrisciani merged commit 37b12fb into moby:master Mar 6, 2018
@fcrisciani
Copy link
Copy Markdown

Thanks @luzhipeng-zte

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.

5 participants