Skip to content

Commit 43a0035

Browse files
committed
pr comments
1 parent b2fb6af commit 43a0035

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

agent/stats.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ type statsCollector interface {
2424
Collect(ctx context.Context, networkStats map[netlogtype.Connection]netlogtype.Counts) *proto.Stats
2525
}
2626

27-
type statsDest interface {
27+
type statsAPI interface {
2828
GetExperiments(ctx context.Context, req *proto.GetExperimentsRequest) (*proto.GetExperimentsResponse, error)
2929
UpdateStats(ctx context.Context, req *proto.UpdateStatsRequest) (*proto.UpdateStatsResponse, error)
3030
}
3131

3232
// statsReporter is a subcomponent of the agent that handles registering the stats callback on the
3333
// networkStatsSource (tailnet.Conn in prod), handling the callback, calling back to the
3434
// statsCollector (agent in prod) to collect additional stats, then sending the update to the
35-
// statsDest (agent API in prod)
35+
// statsAPI (agent API in prod)
3636
type statsReporter struct {
3737
*sync.Cond
3838
networkStats *map[netlogtype.Connection]netlogtype.Counts
@@ -70,12 +70,14 @@ func (s *statsReporter) callback(_, _ time.Time, virtual, _ map[netlogtype.Conne
7070
// connection to the agent API, then passes that connection to go routines like
7171
// this that use it. There is no retry and we fail on the first error since
7272
// this will be inside a larger retry loop.
73-
func (s *statsReporter) reportLoop(ctx context.Context, dest statsDest) error {
73+
func (s *statsReporter) reportLoop(ctx context.Context, dest statsAPI) error {
7474
exp, err := dest.GetExperiments(ctx, &proto.GetExperimentsRequest{})
7575
if err != nil {
7676
return xerrors.Errorf("get experiments: %w", err)
7777
}
78+
s.L.Lock()
7879
s.experiments = agentsdk.ExperimentsFromProto(exp)
80+
s.L.Unlock()
7981

8082
// send an initial, blank report to get the interval
8183
resp, err := dest.UpdateStats(ctx, &proto.UpdateStatsRequest{})
@@ -115,7 +117,7 @@ func (s *statsReporter) reportLoop(ctx context.Context, dest statsDest) error {
115117
}
116118

117119
func (s *statsReporter) reportLocked(
118-
ctx context.Context, dest statsDest, networkStats map[netlogtype.Connection]netlogtype.Counts,
120+
ctx context.Context, dest statsAPI, networkStats map[netlogtype.Connection]netlogtype.Counts,
119121
) error {
120122
// here we want to do our collecting/reporting while it is unlocked, but then relock
121123
// when we return to reportLoop.

tailnet/proto/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
const (
88
CurrentMajor = 2
9-
CurrentMinor = 1
9+
CurrentMinor = 2
1010
)
1111

1212
var CurrentVersion = apiversion.New(CurrentMajor, CurrentMinor).WithBackwardCompat(1)

0 commit comments

Comments
 (0)