Skip to content

Commit

Permalink
Code review markups.
Browse files Browse the repository at this point in the history
  • Loading branch information
fasaxc committed Jul 11, 2017
1 parent 99dd95b commit fd834d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions routetable/route_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ func (r *RouteTable) syncRoutesForLink(ifaceName string) error {

// startConntrackDeletion starts the deletion of conntrack entries for the given CIDR in the background. Pending
// deletions are tracked in the pendingConntrackCleanups map so we can block waiting for them later.
//
// It's important to do the conntrack deletions in the background because scanning the conntrack
// table is very slow if there are a lot of entries. Previously, we did the deletion synchronously
// but that led to lengthy Apply() calls on the critical path.
func (r *RouteTable) startConntrackDeletion(ipAddr ip.Addr) {
log.WithField("ip", ipAddr).Debug("Starting goroutine to delete conntrack entries")
done := make(chan struct{})
Expand Down
7 changes: 4 additions & 3 deletions routetable/route_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ var _ = Describe("RouteTable", func() {
})

Describe("with a slow conntrack deletion", func() {
const delay = 300 * time.Millisecond
BeforeEach(func() {
dataplane.ConntrackSleep = 30 * time.Millisecond
dataplane.ConntrackSleep = delay
})
It("should block a route add until conntrack finished", func() {
// Initial apply starts a background thread to delete
Expand All @@ -129,7 +130,7 @@ var _ = Describe("RouteTable", func() {
})
start := time.Now()
rt.Apply()
Expect(time.Since(start)).To(BeNumerically(">=", 30*time.Millisecond))
Expect(time.Since(start)).To(BeNumerically(">=", delay))
})
It("should not block an unrelated route add ", func() {
// Initial apply starts a background thread to delete
Expand All @@ -141,7 +142,7 @@ var _ = Describe("RouteTable", func() {
})
start := time.Now()
rt.Apply()
Expect(time.Since(start)).To(BeNumerically("<", 10*time.Millisecond))
Expect(time.Since(start)).To(BeNumerically("<", delay/2))
})
})

Expand Down

0 comments on commit fd834d8

Please sign in to comment.