Skip to content

Commit 4154e4e

Browse files
author
Raphael V Rosa
authored
Adds buffered chan to inventory client events in all RMs (#61)
1 parent 695fcfe commit 4154e4e

6 files changed

Lines changed: 19 additions & 6 deletions

File tree

attestationstatus/pkg/invclient/invclient.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const (
2929
// and 600ms per request on average.
3030
// TODO: fine tune this longer timeout based on target scale and inventory client batch size.
3131
ListAllDefaultTimeout = time.Minute // Longer timeout for reconciling all resources
32+
// eventsWatcherBufSize is the buffer size for the events channel.
33+
eventsWatcherBufSize = 10
3234
)
3335

3436
var (
@@ -44,7 +46,7 @@ func StartInventoryClient(wg *sync.WaitGroup, conf config.AttestationStatusMgrCo
4446

4547
zlog.InfraSec().Info().Msg("Starting Inventory gRPC Client")
4648

47-
events := make(chan *inv_client.WatchEvents)
49+
events := make(chan *inv_client.WatchEvents, eventsWatcherBufSize)
4850
cfg := inv_client.InventoryClientConfig{
4951
Name: "attestmgr",
5052
Address: conf.InventoryAddr,

host/pkg/hostmgr/hostmgr.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const (
4444
backoffRetries = uint64(5)
4545
// SetHostConnectionLost does 2 operation with Inventory, plus we leave some slack time.
4646
nOperationInventoryHostConnLost = 2.05
47+
// eventsWatcherBufSize is the buffer size for the events channel.
48+
eventsWatcherBufSize = 10
4749
)
4850

4951
func EnableAuth(enable bool) Option {
@@ -105,7 +107,7 @@ func StartInvGrpcCli(
105107
}
106108
zlog.InfraSec().Info().Msg("initial Inv Grpc Client start.")
107109

108-
events := make(chan *inv_client.WatchEvents)
110+
events := make(chan *inv_client.WatchEvents, eventsWatcherBufSize)
109111
cfg := inv_client.InventoryClientConfig{
110112
Name: "hostmgr",
111113
Address: conf.InventoryAddr,

maintenance/pkg/maintmgr/maintmgr.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ import (
2929

3030
var zlog = logging.GetLogger("MaintenanceManager")
3131

32+
// eventsWatcherBufSize is the buffer size for the events channel.
33+
var eventsWatcherBufSize = 10
34+
3235
// TODO(max): remove global instances.
3336
var invMgrCli invclient.InvGrpcClient
3437

@@ -104,7 +107,7 @@ func StartInvGrpcCli(
104107
inv_v1.ResourceKind_RESOURCE_KIND_REPEATEDSCHEDULE,
105108
}
106109

107-
events := make(chan *inv_client.WatchEvents)
110+
events := make(chan *inv_client.WatchEvents, eventsWatcherBufSize)
108111

109112
cfg := inv_client.InventoryClientConfig{
110113
Name: "maintmgr",

networking/internal/clients/invclient.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const (
3030

3131
// TODO: fine tune this longer timeout based on target scale and inventory client batch size.
3232
ListAllDefaultTimeout = time.Minute // Longer timeout for reconciling all resources
33+
// eventsWatcherBufSize is the buffer size for the events channel.
34+
eventsWatcherBufSize = 10
3335
)
3436

3537
var (
@@ -94,7 +96,7 @@ func NewNetInventoryClientWithOptions(opts ...Option) (*NetInventoryClient, erro
9496
for _, opt := range opts {
9597
opt(&options)
9698
}
97-
eventsWatcher := make(chan *client.WatchEvents)
99+
eventsWatcher := make(chan *client.WatchEvents, eventsWatcherBufSize)
98100
wg := sync.WaitGroup{}
99101
clientCfg := client.InventoryClientConfig{
100102
Name: clientName,

os-resource/internal/invclient/invclient.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ var (
3535
const (
3636
DefaultInventoryTimeout = 5 * time.Second
3737
ListAllDefaultTimeout = time.Minute // Longer timeout for reconciling all resources
38+
// eventsWatcherBufSize is the buffer size for the events channel.
39+
eventsWatcherBufSize = 10
3840
)
3941

4042
type InventoryClient struct {
@@ -57,7 +59,7 @@ func NewInventoryClient(
5759
inv_v1.ResourceKind_RESOURCE_KIND_TENANT,
5860
}
5961

60-
events := make(chan *inv_client.WatchEvents)
62+
events := make(chan *inv_client.WatchEvents, eventsWatcherBufSize)
6163
cfg := inv_client.InventoryClientConfig{
6264
Name: "osrm_clientsrv",
6365
Address: invsvcaddr,

telemetry/internal/invclient/invclient.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var (
3131
zlog = logging.GetLogger(clientName)
3232

3333
inventoryTimeout = flag.Duration("invTimeout", DefaultInventoryTimeout, "Inventory API calls timeout")
34+
// eventsWatcherBufSize is the buffer size for the events channel.
35+
eventsWatcherBufSize = 10
3436
)
3537

3638
type TelemetryInventoryClient struct {
@@ -107,7 +109,7 @@ func NewTelemetryInventoryClientWithOptions(wg *sync.WaitGroup, opts ...Option)
107109
opt(&options)
108110
}
109111

110-
eventsWatcher := make(chan *client.WatchEvents)
112+
eventsWatcher := make(chan *client.WatchEvents, eventsWatcherBufSize)
111113
cfg := client.InventoryClientConfig{
112114
Name: clientName,
113115
Address: options.InventoryAddress,

0 commit comments

Comments
 (0)