Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add resync period for each resource #157

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"syscall"
"time"

"github.com/api7/ingress-controller/pkg/metrics"
api6Informers "github.com/gxthrj/apisix-ingress-types/pkg/client/informers/externalversions"
"github.com/spf13/cobra"

Expand All @@ -32,6 +31,7 @@ import (
"github.com/api7/ingress-controller/pkg/ingress/controller"
"github.com/api7/ingress-controller/pkg/kube"
"github.com/api7/ingress-controller/pkg/log"
"github.com/api7/ingress-controller/pkg/metrics"
"github.com/api7/ingress-controller/pkg/seven/conf"
)

Expand Down Expand Up @@ -122,7 +122,7 @@ the apisix cluster and others are created`,

kubeClientSet := kube.GetKubeClient()
apisixClientset := kube.GetApisixClient()
sharedInformerFactory := api6Informers.NewSharedInformerFactory(apisixClientset, 0)
sharedInformerFactory := api6Informers.NewSharedInformerFactory(apisixClientset, 6.*time.Hour)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the resync_interval option here rather than hardcoding.

stop := make(chan struct{})
c := &controller.Api6Controller{
KubeClientSet: kubeClientSet,
Expand Down
4 changes: 2 additions & 2 deletions pkg/ingress/controller/apisix_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ func BuildApisixRouteController(
apisixRouteSynced: api6RouteInformer.Informer().HasSynced,
workqueue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemFastSlowRateLimiter(1*time.Second, 60*time.Second, 5), "ApisixRoutes"),
}
api6RouteInformer.Informer().AddEventHandler(
api6RouteInformer.Informer().AddEventHandlerWithResyncPeriod(
cache.ResourceEventHandlerFuncs{
AddFunc: controller.addFunc,
UpdateFunc: controller.updateFunc,
DeleteFunc: controller.deleteFunc,
})
}, 30.*time.Minute)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

return controller
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/ingress/controller/apisix_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ func BuildApisixServiceController(
apisixServiceSynced: apisixServiceInformer.Informer().HasSynced,
workqueue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemFastSlowRateLimiter(1*time.Second, 60*time.Second, 5), "ApisixServices"),
}
apisixServiceInformer.Informer().AddEventHandler(
apisixServiceInformer.Informer().AddEventHandlerWithResyncPeriod(
cache.ResourceEventHandlerFuncs{
AddFunc: controller.addFunc,
UpdateFunc: controller.updateFunc,
DeleteFunc: controller.deleteFunc,
})
}, 2*time.Hour)
return controller
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/ingress/controller/apisix_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ func BuildApisixTlsController(
apisixTlsSynced: apisixTlsInformer.Informer().HasSynced,
workqueue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemFastSlowRateLimiter(1*time.Second, 60*time.Second, 5), "ApisixTlses"),
}
apisixTlsInformer.Informer().AddEventHandler(
apisixTlsInformer.Informer().AddEventHandlerWithResyncPeriod(
cache.ResourceEventHandlerFuncs{
AddFunc: controller.addFunc,
UpdateFunc: controller.updateFunc,
DeleteFunc: controller.deleteFunc,
})
}, 30*time.Minute)
return controller
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/ingress/controller/apisix_upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ func BuildApisixUpstreamController(
apisixUpstreamSynced: apisixUpstreamInformer.Informer().HasSynced,
workqueue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemFastSlowRateLimiter(1*time.Second, 60*time.Second, 5), "ApisixUpstreams"),
}
apisixUpstreamInformer.Informer().AddEventHandler(
apisixUpstreamInformer.Informer().AddEventHandlerWithResyncPeriod(
cache.ResourceEventHandlerFuncs{
AddFunc: controller.addFunc,
UpdateFunc: controller.updateFunc,
DeleteFunc: controller.deleteFunc,
})
}, 6*time.Hour)
return controller
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/ingress/controller/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ func BuildEndpointController(kubeclientset kubernetes.Interface) *EndpointContro
endpointSynced: kube.EndpointsInformer.Informer().HasSynced,
workqueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "endpoints"),
}
kube.EndpointsInformer.Informer().AddEventHandler(
kube.EndpointsInformer.Informer().AddEventHandlerWithResyncPeriod(
cache.ResourceEventHandlerFuncs{
AddFunc: controller.addFunc,
UpdateFunc: controller.updateFunc,
DeleteFunc: controller.deleteFunc,
})
}, 6*time.Hour)
return controller
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/kube/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package kube

import (
"time"

clientSet "github.com/gxthrj/apisix-ingress-types/pkg/client/clientset/versioned"
"k8s.io/client-go/informers"
coreinformers "k8s.io/client-go/informers/core/v1"
Expand Down Expand Up @@ -55,7 +57,7 @@ func InitInformer(cfg *config.Config) error {
if err != nil {
return err
}
CoreSharedInformerFactory = informers.NewSharedInformerFactory(kubeClient, 0)
CoreSharedInformerFactory = informers.NewSharedInformerFactory(kubeClient, 6*time.Hour)

return nil
}