This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/rocketmq-studio by this push:
new 2678bb606 fix(proxy): audit non-2xx proxy config reload failures
(#5149)
2678bb606 is described below
commit 2678bb606bbda385e3a5372a1a41bc1386745b6e
Author: Yexi Xiang <[email protected]>
AuthorDate: Thu Oct 1 17:31:35 2026 +0800
fix(proxy): audit non-2xx proxy config reload failures (#5149)
Co-authored-by: 艾克斯光年 <[email protected]>
---
.../rocketmq/studio/cluster/proxy/ProxyAddressService.java | 5 ++++-
.../studio/cluster/proxy/ProxyAddressServiceTest.java | 13 +++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git
a/server/src/main/java/org/apache/rocketmq/studio/cluster/proxy/ProxyAddressService.java
b/server/src/main/java/org/apache/rocketmq/studio/cluster/proxy/ProxyAddressService.java
index 90eac1e27..cbe22ec14 100644
---
a/server/src/main/java/org/apache/rocketmq/studio/cluster/proxy/ProxyAddressService.java
+++
b/server/src/main/java/org/apache/rocketmq/studio/cluster/proxy/ProxyAddressService.java
@@ -345,7 +345,10 @@ public class ProxyAddressService {
ResponseEntity<String> response = restTemplate.postForEntity(url,
null, String.class);
HttpStatusCode status = response.getStatusCode();
if (!status.is2xxSuccessful()) {
- throw new BusinessException(502, "Proxy returned " + status);
+ String errorMessage = "Proxy returned " + status;
+ recordAudit(Operation.RELOAD_PROXY_CONFIG, ResourceType.PROXY,
normalized, normalizedClusterId,
+ Result.FAILED, errorMessage);
+ throw new BusinessException(502, errorMessage);
}
recordAudit(Operation.RELOAD_PROXY_CONFIG, ResourceType.PROXY,
normalized, normalizedClusterId);
log.info("Proxy {} accepted config reload", normalized);
diff --git
a/server/src/test/java/org/apache/rocketmq/studio/cluster/proxy/ProxyAddressServiceTest.java
b/server/src/test/java/org/apache/rocketmq/studio/cluster/proxy/ProxyAddressServiceTest.java
index d52aa25a9..b9e71ae24 100644
---
a/server/src/test/java/org/apache/rocketmq/studio/cluster/proxy/ProxyAddressServiceTest.java
+++
b/server/src/test/java/org/apache/rocketmq/studio/cluster/proxy/ProxyAddressServiceTest.java
@@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
@@ -223,6 +224,18 @@ class ProxyAddressServiceTest {
"cluster-1", null, "SUCCESS", null);
}
+ @Test
+ void reloadConfigShouldAuditNonSuccessfulResponseAsFailure() {
+ doNothing().when(clusterService).requireProxy("cluster-1",
"10.0.0.11:8081");
+
when(restTemplate.postForEntity(eq("http://10.0.0.11:8081/admin/reloadConfig"),
isNull(), eq(String.class)))
+
.thenReturn(ResponseEntity.status(HttpStatus.FOUND).body("redirect"));
+
+ assertThatThrownBy(() -> proxyAddressService.reloadConfig("cluster-1",
"10.0.0.11:8081"))
+ .isInstanceOfSatisfying(BusinessException.class, error ->
assertThat(error.getCode()).isEqualTo(502));
+ verify(operationAuditService).record("RELOAD_PROXY_CONFIG", "PROXY",
"10.0.0.11:8081",
+ "cluster-1", null, "FAILED", "Proxy returned 302 FOUND");
+ }
+
@Test
void buildTopologyShouldReportUpPartialAndDownStatus() {
proxyAddressService.addProxyAddr("10.0.0.2:8081");