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

feat(kuma-cp) dp sync tracker runs only one watchdog #731

Merged
merged 4 commits into from
May 12, 2020

Conversation

jakubdyszkiewicz
Copy link
Contributor

Summary

With ADS the relation was 1 DP = 1 gRPC stream. With SDS that uses Dataplane Sync Tracker the relation is that 1 DP can open many streams. We want to start only one watchdog for DP so we need to which DP the stream belongs. When closing the stream we need to cancel watchdog only if DP has no streams left.

Copy link
Contributor

@nickolaev nickolaev left a comment

Choose a reason for hiding this comment

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

A couple of nits from me.

pkg/xds/sync/dataplane_sync_tracker.go Outdated Show resolved Hide resolved
Expect(err).ToNot(HaveOccurred())

// then only one watchdog is active
time.Sleep(50 * time.Millisecond) // wait for goroutines
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a better way to syncronize here? Can this create flaky tests when running on slow instances in the CI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to do it with channels, but the // then watchdog is still active because other stream is opened is hard to do it.

I don't think that it would cause problems, but I changed the simple wait to gomega Eventually() so we will be checking conditions for 5s every 10ms so even slower machines can check it.

Copy link
Contributor

@nickolaev nickolaev left a comment

Choose a reason for hiding this comment

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

We can merge, thanks!

@jakubdyszkiewicz jakubdyszkiewicz changed the base branch from builtin-expiration to master May 12, 2020 14:26
}
}

var _ envoy_xds.Callbacks = &dataplaneSyncTracker{}

type streams struct {
watchdogCancel context.CancelFunc
activeStreams map[int64]bool
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we already have type alias for int64. Could it be used here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the sds streamID to core_xds and reused here

pkg/xds/sync/dataplane_sync_tracker.go Outdated Show resolved Hide resolved
})
go t.newDataplaneWatchdog(dataplaneKey, streamID).Start(stopCh)
dataplaneSyncTrackerLog.V(1).Info("started Watchdog for a Dataplane", "streamid", streamID, "proxyId", id, "dataplaneKey", dataplaneKey)
t.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it okay that checking of existence in line 81 is not atomic with the actual updating of streams? So after the second lock, some associated resource might exist

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OnStreamRequest for given streamID is synchronous so if I understand your question it should be fine

@jakubdyszkiewicz jakubdyszkiewicz merged commit 6b0d820 into master May 12, 2020
@lahabana lahabana deleted the dp-sync-tracker-fix branch December 2, 2021 10:48
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.

None yet

3 participants