-
Notifications
You must be signed in to change notification settings - Fork 327
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
Conversation
d9193a6
to
5047bf5
Compare
5ba6394
to
cfb66e8
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.
A couple of nits from me.
Expect(err).ToNot(HaveOccurred()) | ||
|
||
// then only one watchdog is active | ||
time.Sleep(50 * time.Millisecond) // wait for goroutines |
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.
Is there a better way to syncronize here? Can this create flaky tests when running on slow instances in the CI?
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.
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.
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.
We can merge, thanks!
5047bf5
to
1b98015
Compare
36c437c
to
efd2ba5
Compare
} | ||
} | ||
|
||
var _ envoy_xds.Callbacks = &dataplaneSyncTracker{} | ||
|
||
type streams struct { | ||
watchdogCancel context.CancelFunc | ||
activeStreams map[int64]bool |
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.
I thought we already have type alias for int64
. Could it be used here as well?
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.
I moved the sds streamID
to core_xds and reused here
}) | ||
go t.newDataplaneWatchdog(dataplaneKey, streamID).Start(stopCh) | ||
dataplaneSyncTrackerLog.V(1).Info("started Watchdog for a Dataplane", "streamid", streamID, "proxyId", id, "dataplaneKey", dataplaneKey) | ||
t.Lock() |
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.
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
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.
OnStreamRequest
for given streamID
is synchronous so if I understand your question it should be fine
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.