lingsamuel commented on code in PR #1022:
URL:
https://github.com/apache/apisix-ingress-controller/pull/1022#discussion_r892998217
##########
conf/config-default.yaml:
##########
@@ -44,7 +44,7 @@ ingress_status_address: [] # when there is no available
information on the Ser
# For example, no available LB exists in the bare
metal environment.
enable_profiling: true # enable profiling via web interfaces
# host:port/debug/pprof, default is true.
-
+apisix-resource-sync-interval: "300s" # The Kubernetes resources sync to
apisix default interval time.
Review Comment:
`Default interval for synchronizing Kubernetes resources to APISIX`
##########
cmd/ingress/ingress.go:
##########
@@ -171,6 +171,7 @@ For example, no available LB exists in the bare metal
environment.`)
cmd.PersistentFlags().StringVar(&cfg.APISIX.DefaultClusterBaseURL,
"default-apisix-cluster-base-url", "", "the base URL of admin api / manager api
for the default APISIX cluster")
cmd.PersistentFlags().StringVar(&cfg.APISIX.DefaultClusterAdminKey,
"default-apisix-cluster-admin-key", "", "admin key used for the authorization
of admin api / manager api for the default APISIX cluster")
cmd.PersistentFlags().StringVar(&cfg.APISIX.DefaultClusterName,
"default-apisix-cluster-name", "default", "name of the default apisix cluster")
+
cmd.PersistentFlags().DurationVar(&cfg.ApisixResourceSyncInterval.Duration,
"apisix-resource-sync-interval", 300*time.Second, "sync-time of the default
300s")
Review Comment:
`interval between syncs in seconds. Default value is 300s.`
##########
pkg/ingress/apisix_consumer.go:
##########
@@ -318,3 +318,29 @@ func (c *apisixConsumerController) onDelete(obj
interface{}) {
c.controller.MetricsCollector.IncrEvents("consumer", "delete")
}
+
+func (c *apisixConsumerController) ResourceSync() {
+ objs := c.controller.apisixConsumerInformer.GetIndexer().List()
+ for _, obj := range objs {
+ key, err := cache.MetaNamespaceKeyFunc(obj)
+ if err != nil {
+ log.Errorf("ApisixConsumer sync failed, found
ApisixConsumer resource with bad meta namespace key: %s", err)
Review Comment:
same
##########
pkg/ingress/apisix_route.go:
##########
@@ -448,3 +448,25 @@ func (c *apisixRouteController) onDelete(obj interface{}) {
c.controller.MetricsCollector.IncrEvents("route", "delete")
}
+
+func (c *apisixRouteController) ResourceSync() {
+ objs := c.controller.apisixRouteInformer.GetIndexer().List()
+ for _, obj := range objs {
+ key, err := cache.MetaNamespaceKeyFunc(obj)
+ if err != nil {
+ log.Errorf("ApisixRoute sync failed, found ApisixRoute
resource with bad meta namespace key: %s", err)
Review Comment:
same
##########
pkg/ingress/controller.go:
##########
@@ -770,3 +774,54 @@ func (c *Controller) checkClusterHealth(ctx
context.Context, cancelFunc context.
c.MetricsCollector.IncrCheckClusterHealth(c.name)
}
}
+
+func (c *Controller) syncResourceAll() {
Review Comment:
`syncAllResources`
##########
samples/deploy/configmap/apisix-ingress-cm.yaml:
##########
@@ -35,7 +35,7 @@ data:
http_listen: ":8080" # the HTTP Server listen address, default is ":8080"
enable_profiling: true # enable profiling via web interfaces
# host:port/debug/pprof, default is true.
-
+ apisix-resource-sync-interval: 300s # Ingress sync to apisix default
interval time.
Review Comment:
same as above
##########
pkg/ingress/apisix_pluginconfig.go:
##########
@@ -366,3 +366,25 @@ func (c *apisixPluginConfigController) onDelete(obj
interface{}) {
c.controller.MetricsCollector.IncrEvents("PluginConfig", "delete")
}
+
+func (c *apisixPluginConfigController) ResourceSync() {
+ objs := c.controller.apisixPluginConfigInformer.GetIndexer().List()
+ for _, obj := range objs {
+ key, err := cache.MetaNamespaceKeyFunc(obj)
+ if err != nil {
+ log.Errorf("ApisixPluginConfig sync failed, found
ApisixPluginConfig resource with bad meta namespace key: %s", err)
Review Comment:
same
##########
pkg/ingress/apisix_cluster_config.go:
##########
@@ -403,3 +403,29 @@ func (c *apisixClusterConfigController) onDelete(obj
interface{}) {
c.controller.MetricsCollector.IncrEvents("clusterConfig", "delete")
}
+
+func (c *apisixClusterConfigController) ResourceSync() {
+ objs := c.controller.apisixClusterConfigInformer.GetIndexer().List()
+ for _, obj := range objs {
+ key, err := cache.MetaNamespaceKeyFunc(obj)
+ if err != nil {
+ log.Errorf("ApisixClusterConfig sync failed, found
ApisixClusterConfig resource with bad meta namespace key: %s", err)
Review Comment:
Please change to `Errorw`.
##########
pkg/ingress/apisix_tls.go:
##########
@@ -359,3 +359,29 @@ func (c *apisixTlsController) onDelete(obj interface{}) {
c.controller.MetricsCollector.IncrEvents("TLS", "delete")
}
+
+func (c *apisixTlsController) ResourceSync() {
+ objs := c.controller.apisixTlsInformer.GetIndexer().List()
+ for _, obj := range objs {
+ key, err := cache.MetaNamespaceKeyFunc(obj)
+ if err != nil {
+ log.Errorf("ApisixTls sync failed, found ApisixTls
object with bad namespace/name: %s, ignore it", err)
Review Comment:
same
##########
pkg/ingress/ingress.go:
##########
@@ -402,3 +402,25 @@ func (c *ingressController) isIngressEffective(ing
kube.Ingress) bool {
}
return false
}
+
+func (c *ingressController) ResourceSync() {
+ objs := c.controller.ingressInformer.GetIndexer().List()
+ for _, obj := range objs {
+ key, err := cache.MetaNamespaceKeyFunc(obj)
+ if err != nil {
+ log.Errorf("found ApisixConsumer resource with bad meta
namespace key: %s", err)
Review Comment:
`Errorw`
##########
pkg/ingress/controller.go:
##########
@@ -770,3 +774,54 @@ func (c *Controller) checkClusterHealth(ctx
context.Context, cancelFunc context.
c.MetricsCollector.IncrCheckClusterHealth(c.name)
}
}
+
+func (c *Controller) syncResourceAll() {
+ wg := sync.WaitGroup{}
+ goAttach := func(handler func()) {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ handler()
+ }()
+ }
+ goAttach(func() {
+ c.apisixConsumerController.ResourceSync()
+ })
+ goAttach(func() {
+ c.apisixRouteController.ResourceSync()
+ })
+ goAttach(func() {
+ c.apisixClusterConfigController.ResourceSync()
+ })
+ goAttach(func() {
+ c.apisixPluginConfigController.ResourceSync()
+ })
+ goAttach(func() {
+ c.apisixUpstreamController.ResourceSync()
+ })
+ goAttach(func() {
+ c.apisixTlsController.ResourceSync()
+ })
+ goAttach(func() {
+ c.ingressController.ResourceSync()
+ })
+ wg.Wait()
+}
+
+func (c *Controller) resourceSyncLoop(ctx context.Context, interval
time.Duration) {
+ // The interval shall not be less than 60 seconds.
+ if interval < _mininumApisixResourceSyncInterval {
+ interval = _mininumApisixResourceSyncInterval
Review Comment:
We should add a log to notify this behavior
##########
pkg/ingress/apisix_upstream.go:
##########
@@ -301,3 +301,21 @@ func (c *apisixUpstreamController) onDelete(obj
interface{}) {
c.controller.MetricsCollector.IncrEvents("upstream", "delete")
}
+
+func (c *apisixUpstreamController) ResourceSync() {
+ clusterConfigs :=
c.controller.apisixUpstreamInformer.GetIndexer().List()
+ for _, clusterConfig := range clusterConfigs {
+ key, err := cache.MetaNamespaceKeyFunc(clusterConfig)
+ if err != nil {
+ log.Errorf("ApisixUpstream sync failed, found
ApisixUpstream resource with bad meta namespace key: %s", err)
Review Comment:
same
##########
pkg/ingress/controller.go:
##########
@@ -64,6 +64,8 @@ const (
_resourceSyncAborted = "ResourceSyncAborted"
// _messageResourceFailed is used to report error
_messageResourceFailed = "%s synced failed, with error: %s"
+ // ingress sync to apsix mininum interval
Review Comment:
`minimum interval for ingress sync to APISIX`
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]