@@ -19,33 +19,33 @@ import (
1919
2020// TODO: make this file a sub pacakge?
2121
22- // NetworkContainerSyncState manages waiting on conflist to ge
22+ // ncWait manages making sure ncstate or nodesubnet state is ready before conflist writing
2323// Basically a wait group that can only be added once and waits with a context
2424// meant to be used uninitialized and then started once the sync loop begins.
25- type networkContainerSyncState struct {
25+ type ncWait struct {
2626 wg sync.WaitGroup
2727 started atomic.Bool
2828}
2929
30- // Start is like add except it only allows being called once.
31- func (n * networkContainerSyncState ) Start () error {
30+ // Start is like Add except it only allows being called once.
31+ func (n * ncWait ) Start () error {
3232 if ! n .started .CompareAndSwap (false , true ) {
3333 return errors .New ("sync loop already started" )
3434 }
3535 n .wg .Add (1 )
3636 return nil
3737}
3838
39- // NotifyReady is like Done but will ignore if Start was never called.
40- func (n * networkContainerSyncState ) NotifyReady () {
39+ // Done is like waitgroup Done but will ignore if Start was never called.
40+ func (n * ncWait ) Done () {
4141 if ! n .started .Load () {
4242 return //nobody ever set this up just move on.
4343 }
4444 n .wg .Done ()
4545}
4646
4747// Wait waits for the CNI conflist to be ready or for the context to be done.
48- func (n * networkContainerSyncState ) Wait (ctx context.Context ) {
48+ func (n * ncWait ) Wait (ctx context.Context ) {
4949 done := make (chan struct {})
5050 go func () {
5151 n .wg .Wait () //still fine to wait even if never started will just return immediately
@@ -61,7 +61,7 @@ func (n *networkContainerSyncState) Wait(ctx context.Context) {
6161// StartSyncHostNCVersionLoop loops until checking htat NCS are programmed annd also notifis when at least one has been programmed
6262// so we can write conflist and mark cns ready.
6363func (service * HTTPRestService ) StartSyncHostNCVersionLoop (ctx context.Context , cnsconfig configuration.CNSConfig ) error {
64- if err := service .ncSyncState .Start (); err != nil {
64+ if err := service .ncWait .Start (); err != nil {
6565 return err
6666 }
6767 go func () {
@@ -72,12 +72,12 @@ func (service *HTTPRestService) StartSyncHostNCVersionLoop(ctx context.Context,
7272 timeout := time .Duration (cnsconfig .SyncHostNCVersionIntervalMs ) * time .Millisecond
7373 for {
7474 if service .syncHostNCVersionWrapper (ctx , cnsconfig .ChannelMode , timeout ) {
75- one .Do (service .ncSyncState . NotifyReady )
75+ one .Do (service .ncWait . Done )
7676 }
7777 select {
7878 case <- ticker .C :
7979 if service .syncHostNCVersionWrapper (ctx , cnsconfig .ChannelMode , timeout ) {
80- one .Do (service .ncSyncState . NotifyReady )
80+ one .Do (service .ncWait . Done )
8181 }
8282 case <- ctx .Done ():
8383 logger .Printf ("Stopping SyncHostNCVersion loop." )
0 commit comments