-
Notifications
You must be signed in to change notification settings - Fork 797
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
check bridge's port state #468
Conversation
3a7c98a
to
1e59e0f
Compare
return err | ||
} | ||
|
||
// check bridge port state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"wait for bridge port state to be Up"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should we make this section into to a utility function?
plugins/main/bridge/bridge.go
Outdated
} | ||
|
||
// check bridge port state | ||
for i := 0; i < 3; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if this had some backoff - sleeping 50, then, 500, then 1000 ms.
A more idiomatic way of writing this might be
retries := []int{50, 500, 1000, 1000}
for idx, sleep := range retries {
(check host)
if idx == len(retries) - 1) {
fail
}
time.Sleep(sleep + time.Millisecond)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@squeed have been modified.
1e59e0f
to
6e44f73
Compare
lgtm |
break | ||
} | ||
|
||
if idx == len(retries)-1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we try to escape from here, we only try 4 times and need 3 intervals, so I think we should sleep in the beginning of the loop and let retries := []int{0,50,500,1000,1000}
, so we will make full use of retries
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mars1024 add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I think sleep should be the first step of the loop... just like
retries := []int{0, 50, 500, 1000, 1000}
for idx, sleep := range retries {
time.Sleep(sleep * time.Millisecond)
(check host)
if idx == (len(retries) - 1) {
fail
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sleep 0 before do something ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, 0 means no sleep in the first time, then we will have 5 tries and 4 non-zero intervals as expectation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mars1024 , have changed.
return err | ||
} | ||
|
||
// check bridge port state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should we make this section into to a utility function?
6e44f73
to
b0417b6
Compare
fix containernetworking#463 link host veth pair to bridge, the Initial state of port is BR_STATE_DISABLED and change to BR_STATE_FORWARDING async. Signed-off-by: honglichang <honglichang@tencent.com>
b0417b6
to
30776ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm, thanks!
lgtm |
fix #463
link host veth pair to bridge, the Initial state
of port is BR_STATE_DISABLED and change to
BR_STATE_FORWARDING async.