nacos icon indicating copy to clipboard operation
nacos copied to clipboard

Nacos unable to publish flow control rules to Sentinel Dashboard

Open Zengwenliang0416 opened this issue 6 months ago • 2 comments

Describe the bug Nacos unable to publish flow control rules to Sentinel Dashboard

Expected behavior Nacos releases flow control rules that can be synchronized to Sentinel Dashboard

Actually behavior

【Bug】Nacos unable to publish flow control rules to Sentinel Dashboard

Version Description:nacos=2.4.0、Sentinel Dashborad=1.8.8、spring.cloud.alibaba.version=2023.0.1.2

dependencies

<!-- sentinel-gateway依赖 -->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
</dependency>
<!-- sentinel-datasource-nacos依赖 -->
<dependency>
    <groupId>com.alibaba.csp</groupId>
    <artifactId>sentinel-datasource-nacos</artifactId>
</dependency>

application.yaml

spring:
  cloud:
    nacos:
      server-addr:  # Nacos server address
      username: # Nacos username
      password: # Nacos password
      discovery: #  [Configuration Center] Configuration Items
        namespace: dev # Namespace. We use the dev development environment here
        group: DEFAULT_GROUP # The Nacos configuration group used defaults to DEFAULT_GROUP
      config: # [Registration Center] Configuration Items
        namespace: dev # Namespace. We use the dev development environment here
        group: DEFAULT_GROUP # The Nacos configuration group used defaults to DEFAULT_GROUP
    sentinel:
      datasource:
        r1:
          nacos:
            username: 
            password: 
            namespace: dev
            server-addr: # Nacos server address
            data-id: ${spring.application.name}-sentinel
            group-id: DEFAULT_GROUP
            rule-type: flow
      transport:
        dashboard: 127.0.0.1:8080
        client-ip: 127.0.0.1

Nacos configuration flow control

Since microservices are created using the 'dev' namespace, configurations need to be created in the 'dev' namespace.

[
	{
        "resource": "system-admin-api",
        "resourceMode": 0,
        "count": 10,
        "grade": 1,
		"controlBehavior": 0,
        "intervalSec": 10,
        "burst": 0,
        "maxQueueingTimeoutMs": 1000
	}
]
image-20240823110214338 image-20240823110601723

At this point, we can see that the QPS we have set is 10, and then start Sentinel Dashboard, gateway, and corresponding business microservices.

When accessing the system admin API service, it can be seen that there is no problem accessing when QPS is set to 10.

image-20240823111259823

Modify Nacos configuration for current limiting (change count to 2)

image-20240823111430213 By checking the record log of Sentinel, it can be seen that the modification has been successful. image-20240823111604519

After testing, it was found that it has already taken effect. If three requests are sent within 1 second, one will be intercepted.

image-20240823111854845 However, the Sentinel Dashboard did not display the corresponding value. image-20240823112005888

Sentinel Dashboard configuration flow control

Situation 1

In the above situation, we directly added flow control rules and set the threshold of QPS to 10.

image-20240823112259985 It can be seen that it has not taken effect yet image-20240823112409493 But the dashboard console shows that the modification was successful. image-20240823112548749

Situation 2

Restart the gateway and other services, first configure from the dashboard and then from Nacos

At this point, the configuration in Nacos is as follows

[
	{
        "resource": "system-admin-api",
        "resourceMode": 0,
        "count": 2,
        "grade": 1,
		"controlBehavior": 0,
        "intervalSec": 10,
        "burst": 0,
        "maxQueueingTimeoutMs": 1000
	}
]

The flow control rule interface of the dashboard is as follows. As it is read from memory, each flow control rule needs to be reconfigured.

image-20240823112842025 But from the real-time monitoring panel, it can be seen that the configuration in Nacos has already taken effect image-20240823112958524 At this point, configure the flow control rules through the dashboard to set QPS to 1. image-20240823113314096 You can see that it has already taken effect image-20240823113406477 Then go to Nacos to release the following configuration image-20240823113444349 In the sentinel record log, it can be seen that the update has been made image-20240823113542232 But in actual testing, the update failed image-20240823113653367 At the same time, the QPS of the flow control rules displayed in the dashboard has not changed. image-20240823113717103

How to Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See errors

Desktop (please complete the following information):

  • OS: MacOS
  • Version nacos-server 2.4.0
  • Module config
  • SDK spring-cloud-alibaba-nacos Additional context Add any other context about the problem here.

Zengwenliang0416 avatar Aug 23 '24 06:08 Zengwenliang0416