Skip to content

Commit aaa095c

Browse files
committed
Replace Sleep with Ticker
1 parent 04da2a2 commit aaa095c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cns/service/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,12 +1136,15 @@ func pollNodeInfoCRDAndUpdatePlugin(ctx context.Context, zlog *zap.Logger, plugi
11361136
Cli: directcli,
11371137
}
11381138

1139+
ticker := time.NewTicker(defaultNodeInfoCRDPollInterval)
1140+
defer ticker.Stop()
1141+
11391142
for {
11401143
select {
11411144
case <-ctx.Done():
11421145
zlog.Info("Polling context canceled, exiting")
11431146
return nil
1144-
default:
1147+
case <-ticker.C:
11451148
// Fetch the CRD status
11461149
nodeInfo, err := nodeInfoCli.Get(ctx, node.Name)
11471150
if err != nil {
@@ -1175,9 +1178,6 @@ func pollNodeInfoCRDAndUpdatePlugin(ctx context.Context, zlog *zap.Logger, plugi
11751178
// Exit polling loop once the CRD status is successfully processed
11761179
return nil
11771180
}
1178-
1179-
// Wait before polling again
1180-
time.Sleep(defaultNodeInfoCRDPollInterval)
11811181
}
11821182
}
11831183
}

0 commit comments

Comments
 (0)