@@ -567,9 +567,12 @@ func main() {
567567 }
568568 go func (ep , vnet , node string ) {
569569 // Periodically poll DNC for node updates
570+ tickerChannel := time .Tick (time .Duration (cnsconfig .ManagedSettings .NodeSyncIntervalInSeconds ) * time .Second )
570571 for {
571- <- time .NewTicker (time .Duration (cnsconfig .ManagedSettings .NodeSyncIntervalInSeconds ) * time .Second ).C
572- httpRestService .SyncNodeStatus (ep , vnet , node , json.RawMessage {})
572+ select {
573+ case <- tickerChannel :
574+ httpRestService .SyncNodeStatus (ep , vnet , node , json.RawMessage {})
575+ }
573576 }
574577 }(privateEndpoint , infravnet , nodeID )
575578 }
@@ -743,9 +746,14 @@ func InitializeMultiTenantController(httpRestService cns.HTTPService, cnsconfig
743746 rootCxt := context .Background ()
744747 go func () {
745748 // Periodically poll vfp programmed NC version from NMAgent
749+ tickerChannel := time .Tick (cnsconfig .SyncHostNCVersionIntervalMs * time .Millisecond )
746750 for {
747- <- time .NewTicker (cnsconfig .SyncHostNCVersionIntervalMs * time .Millisecond ).C
748- httpRestServiceImpl .SyncHostNCVersion (rootCxt , cnsconfig .ChannelMode , cnsconfig .SyncHostNCTimeoutMs )
751+ select {
752+ case <- tickerChannel :
753+ httpRestServiceImpl .SyncHostNCVersion (rootCxt , cnsconfig .ChannelMode , cnsconfig .SyncHostNCTimeoutMs )
754+ case <- rootCxt .Done ():
755+ return
756+ }
749757 }
750758 }()
751759
@@ -842,9 +850,14 @@ func InitializeCRDState(httpRestService cns.HTTPService, cnsconfig configuration
842850 rootCxt := context .Background ()
843851 go func () {
844852 // Periodically poll vfp programmed NC version from NMAgent
853+ tickerChannel := time .Tick (cnsconfig .SyncHostNCVersionIntervalMs * time .Millisecond )
845854 for {
846- <- time .NewTicker (cnsconfig .SyncHostNCVersionIntervalMs * time .Millisecond ).C
847- httpRestServiceImplementation .SyncHostNCVersion (rootCxt , cnsconfig .ChannelMode , cnsconfig .SyncHostNCTimeoutMs )
855+ select {
856+ case <- tickerChannel :
857+ httpRestServiceImplementation .SyncHostNCVersion (rootCxt , cnsconfig .ChannelMode , cnsconfig .SyncHostNCTimeoutMs )
858+ case <- rootCxt .Done ():
859+ return
860+ }
848861 }
849862
850863 logger .Printf ("[Azure CNS] Exiting SyncHostNCVersion" )
0 commit comments