Copilot commented on code in PR #2534:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2534#discussion_r2313400550


##########
internal/provider/apisix/provider.go:
##########
@@ -223,32 +229,46 @@ func (d *apisixProvider) Start(ctx context.Context) error 
{
 
        initalSyncDelay := d.InitSyncDelay
        if initalSyncDelay > 0 {
-               time.AfterFunc(initalSyncDelay, func() {
-                       if err := d.sync(ctx); err != nil {
-                               log.Error(err)
-                               return
-                       }
-               })
+               if d.SyncPeriod < 1 {

Review Comment:
   The condition checks if SyncPeriod is less than 1, but this comparison 
against an integer literal doesn't match the time.Duration type. This should 
compare against a time.Duration value like `time.Duration(0)` or use 
`d.SyncPeriod <= 0`.



##########
internal/provider/apisix/provider.go:
##########
@@ -223,32 +229,46 @@ func (d *apisixProvider) Start(ctx context.Context) error 
{
 
        initalSyncDelay := d.InitSyncDelay
        if initalSyncDelay > 0 {
-               time.AfterFunc(initalSyncDelay, func() {
-                       if err := d.sync(ctx); err != nil {
-                               log.Error(err)
-                               return
-                       }
-               })
+               if d.SyncPeriod < 1 {
+                       time.AfterFunc(initalSyncDelay, func() {
+                               if err := d.sync(ctx); err != nil {
+                                       log.Error(err)
+                                       return
+                               }
+                       })
+               } else {
+                       time.AfterFunc(initalSyncDelay, d.syncNotify)
+               }
        }
 
        if d.SyncPeriod < 1 {

Review Comment:
   Same issue as above - comparing time.Duration with integer literal 1. This 
should be `d.SyncPeriod <= 0` to properly check if periodic sync is disabled.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to