Add warning message for the failure of deleting link device#2085
Add warning message for the failure of deleting link device#2085fcrisciani merged 1 commit intomoby:masterfrom
Conversation
|
@luzhipeng-zte thanks for the contributions, right now the CI fails because of: |
| 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) |
There was a problem hiding this comment.
can you use the format with: logrus.WithError(dellinkerr).Warnf
There was a problem hiding this comment.
Thanks. i think using the same formats better
| 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) |
There was a problem hiding this comment.
maybe instead of (%s) you can use %q that will keep the string "quoted"
| } | ||
| if link, err := d.nlh.LinkByName(ep.srcName); err == nil { | ||
| d.nlh.LinkDel(link) | ||
| if dellinkerr := d.nlh.LinkDel(link); dellinkerr != nil { |
There was a problem hiding this comment.
you can also simply use err := d.nlh.LinkDel(link) err will shadows the other err but is fine
selansen
left a comment
There was a problem hiding this comment.
you can reuse err instead of adding new variable dellinkerr. This can be applicable all the places.
|
Did you fix CI failure ? |
f68c909 to
feac87d
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
|
@selansen @fcrisciani , i have updated the PR. |
| 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) |
There was a problem hiding this comment.
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
165c2c5 to
cbfd981
Compare
|
Please sign your commits following these rules: $ 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 -fAmending updates the existing PR. You DO NOT need to open a new one. |
|
ping @fcrisciani @selansen, i have updated the PR. could you take a look ? |
| defer func() { | ||
| if err != nil { | ||
| d.nlh.LinkDel(host) | ||
| if dellinkerr := d.nlh.LinkDel(host); dellinkerr != nil { |
There was a problem hiding this comment.
Can we reuse err instead of dellinkerr like above change ?
There was a problem hiding this comment.
I worry that this will overwrite the previous errorand the error of LinkDel can be recorded by log
| defer func() { | ||
| if err != nil { | ||
| d.nlh.LinkDel(sbox) | ||
| if dellinkerr := d.nlh.LinkDel(sbox); dellinkerr != nil { |
There was a problem hiding this comment.
Can we reuse err instead of dellinkerr like above change ?
|
@selansen, i have updated the PR. |
|
LGTM |
| 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) |
|
ping @fcrisciani , i have updated the PR. |
Signed-off-by: ZhiPeng Lu <[email protected]>
|
Thanks @luzhipeng-zte |
We can know the reason for the failure of deleting the link device.
Signed-off-by: ZhiPeng Lu [email protected]