Skip to content
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

Merged
merged 1 commit into from
Apr 8, 2020

Conversation

hongli-my
Copy link

fix #463
link host veth pair to bridge, the Initial state
of port is BR_STATE_DISABLED and change to
BR_STATE_FORWARDING async.

return err
}

// check bridge port state
Copy link
Member

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"

Copy link
Member

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?

}

// check bridge port state
for i := 0; i < 3; i++ {
Copy link
Member

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)
}

Copy link
Author

Choose a reason for hiding this comment

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

@squeed have been modified.

@squeed
Copy link
Member

squeed commented Apr 6, 2020

lgtm

break
}

if idx == len(retries)-1 {
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

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

@mars1024 add it.

Copy link
Member

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
  }
}

Copy link
Author

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 ?

Copy link
Member

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.

Copy link
Author

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
Copy link
Member

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?

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>
Copy link
Member

@mars1024 mars1024 left a comment

Choose a reason for hiding this comment

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

/lgtm, thanks!

@dcbw
Copy link
Member

dcbw commented Apr 8, 2020

lgtm

@mccv1r0 mccv1r0 merged commit f4332fe into containernetworking:master Apr 8, 2020
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.

GratuitousArp not work, bridge can not receive arp package
5 participants