Skip to content

Commit 4254922

Browse files
author
redyyang
committed
Merge remote-tracking branch 'upstream/master' into fix/7530-pr-followup
2 parents b010fa0 + 4835f40 commit 4254922

22 files changed

Lines changed: 805 additions & 84 deletions

File tree

‎.github/scripts/resolve-test-case-matrix-test.sh‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,21 @@ assert_file_output "k8s-examples-http" "shenyu-bootstrap/pom.xml" "run_k8s_examp
116116
assert_file_output "k8s-examples-http" "pom.xml" "run_k8s_examples" "true"
117117

118118
readonly E2E_GRPC="shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-grpc/compose/script/e2e-grpc-sync-compose.sh"
119+
readonly E2E_CLUSTER="shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-cluster/compose/script/e2e-cluster-jdbc-compose.sh"
119120
readonly E2E_RABBITMQ="shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-logging-rabbitmq/compose/script/e2e-logging-rabbitmq-compose.sh"
120121
readonly E2E_RABBITMQ_CASE="shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-logging-rabbitmq/src/test/java/org/apache/shenyu/e2e/testcase/logging/rabbitmq/DividePluginCases.java"
121122
readonly IT_GRPC="shenyu-integrated-test/shenyu-integrated-test-grpc/src/test/java/GrpcPluginTest.java"
122123
readonly IT_K8S_GRPC="shenyu-integrated-test/shenyu-integrated-test-k8s-ingress-grpc/script/healthcheck.sh"
123124
readonly PROD_GRPC="shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-grpc/pom.xml"
124125
readonly ADMIN_REGISTER="shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/AbstractShenyuClientRegisterServiceImpl.java"
125126
readonly ADMIN_SERVICE="shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/PluginServiceImpl.java"
127+
readonly CLUSTER_SERVICE="shenyu-admin/src/main/java/org/apache/shenyu/admin/mode/cluster/filter/ClusterForwardFilter.java"
126128
readonly ALL_K8S_INGRESS_MATRIX='{"include":[{"case":"shenyu-integrated-test-k8s-ingress-http"},{"case":"shenyu-integrated-test-k8s-ingress-apache-dubbo"},{"case":"shenyu-integrated-test-k8s-ingress-websocket"},{"case":"shenyu-integrated-test-k8s-ingress-grpc"}]}'
129+
readonly CLUSTER_E2E_MATRIX='{"include":[{"script":"e2e-cluster-jdbc-compose","case":"shenyu-e2e-case-cluster","example_projects":":shenyu-examples-http"},{"script":"e2e-cluster-zookeeper-compose","case":"shenyu-e2e-case-cluster","example_projects":":shenyu-examples-http"}]}'
127130
readonly ADMIN_REGISTER_E2E_MATRIX='{"include":[{"script":"e2e-http-sync-compose","case":"shenyu-e2e-case-http","example_projects":":shenyu-examples-http"},{"script":"e2e-springcloud-sync-compose","case":"shenyu-e2e-case-spring-cloud","example_projects":":shenyu-examples-eureka,:shenyu-examples-springcloud"},{"script":"e2e-apache-dubbo-sync-compose","case":"shenyu-e2e-case-apache-dubbo","example_projects":":shenyu-examples-apache-dubbo-service"},{"script":"e2e-grpc-sync-compose","case":"shenyu-e2e-case-grpc","example_projects":":shenyu-examples-grpc"},{"script":"e2e-websocket-sync-compose","case":"shenyu-e2e-case-websocket","example_projects":":shenyu-example-spring-native-websocket"}]}'
131+
readonly ALL_E2E_MATRIX="$(jq -c '.include += [{script:"e2e-logging-rocketmq-compose",case:"shenyu-e2e-case-logging-rocketmq",example_projects:":shenyu-examples-http"},{script:"e2e-cluster-jdbc-compose",case:"shenyu-e2e-case-cluster",example_projects:":shenyu-examples-http"},{script:"e2e-cluster-zookeeper-compose",case:"shenyu-e2e-case-cluster",example_projects:":shenyu-examples-http"}]' <<< "${ADMIN_REGISTER_E2E_MATRIX}")"
132+
readonly CLUSTER_SERVICE_E2E_MATRIX="$(jq -cn --argjson cluster "${CLUSTER_E2E_MATRIX}" --argjson all "${ALL_E2E_MATRIX}" \
133+
'{include: ($cluster.include + ($all.include | map(select(.case != "shenyu-e2e-case-cluster"))))}')"
128134
readonly ADMIN_REGISTER_IT_MATRIX='{"include":[{"case":"shenyu-integrated-test-apache-dubbo"},{"case":"shenyu-integrated-test-grpc"},{"case":"shenyu-integrated-test-http"},{"case":"shenyu-integrated-test-https"},{"case":"shenyu-integrated-test-spring-cloud"},{"case":"shenyu-integrated-test-websocket"},{"case":"shenyu-integrated-test-sdk-apache-dubbo"},{"case":"shenyu-integrated-test-sdk-http"}]}'
129135

130136
# Non-code PRs still run required workflows, but must not schedule builds or E2E.
@@ -148,12 +154,14 @@ assert_output "e2e" "$(jq -cn --arg file "${ADMIN_SERVICE}" '["README.md", $file
148154
assert_ci_ignored "${E2E_GRPC}"
149155
assert_file_output "e2e" "${E2E_GRPC}" "e2e_matrix" \
150156
'{"include":[{"script":"e2e-grpc-sync-compose","case":"shenyu-e2e-case-grpc","example_projects":":shenyu-examples-grpc"}]}'
157+
assert_ci_ignored "${E2E_CLUSTER}"
158+
assert_file_output "e2e" "${E2E_CLUSTER}" "e2e_matrix" "${CLUSTER_E2E_MATRIX}"
159+
assert_file_output "e2e" "${CLUSTER_SERVICE}" "e2e_matrix" "${CLUSTER_SERVICE_E2E_MATRIX}"
151160
assert_file_output "e2e" "${E2E_RABBITMQ}" "e2e_matrix" \
152161
'{"include":[{"script":"e2e-logging-rocketmq-compose","case":"shenyu-e2e-case-logging-rocketmq","example_projects":":shenyu-examples-http"}]}'
153162
assert_file_output "e2e" "${E2E_RABBITMQ_CASE}" "e2e_matrix" \
154163
'{"include":[{"script":"e2e-logging-rocketmq-compose","case":"shenyu-e2e-case-logging-rocketmq","example_projects":":shenyu-examples-http"}]}'
155-
assert_file_output "e2e" "pom.xml" "e2e_matrix" \
156-
"$(jq -c '.include += [{script:"e2e-logging-rocketmq-compose",case:"shenyu-e2e-case-logging-rocketmq",example_projects:":shenyu-examples-http"}]' <<< "${ADMIN_REGISTER_E2E_MATRIX}")"
164+
assert_file_output "e2e" "pom.xml" "e2e_matrix" "${ALL_E2E_MATRIX}"
157165
assert_file_output "integration" "${E2E_GRPC}" "run_integration" "false"
158166
assert_file_output "k8s-ingress" "${E2E_GRPC}" "run_k8s_ingress" "false"
159167

‎.github/scripts/resolve-test-case-matrix.sh‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ add_e2e_all() {
6161
add_unique e2e_cases "e2e-grpc-sync-compose"
6262
add_unique e2e_cases "e2e-websocket-sync-compose"
6363
add_unique e2e_cases "e2e-logging-rocketmq-compose"
64+
add_unique e2e_cases "e2e-cluster-jdbc-compose"
65+
add_unique e2e_cases "e2e-cluster-zookeeper-compose"
6466
}
6567

6668
add_integration_all() {
@@ -264,6 +266,10 @@ map_direct_case_path() {
264266
shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-logging-rocketmq/*)
265267
add_unique e2e_cases "e2e-logging-rocketmq-compose"
266268
;;
269+
shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-cluster/*)
270+
add_unique e2e_cases "e2e-cluster-jdbc-compose"
271+
add_unique e2e_cases "e2e-cluster-zookeeper-compose"
272+
;;
267273
esac
268274
else
269275
case "${file}" in
@@ -358,6 +364,12 @@ map_domain_path() {
358364
add_unique integration_cases "shenyu-integrated-test-http"
359365
fi
360366
;;
367+
*cluster*|*Cluster*)
368+
if [[ "${mode}" == "e2e" ]]; then
369+
add_unique e2e_cases "e2e-cluster-jdbc-compose"
370+
add_unique e2e_cases "e2e-cluster-zookeeper-compose"
371+
fi
372+
;;
361373
*rewrite*)
362374
if [[ "${mode}" == "e2e" ]]; then
363375
add_unique e2e_cases "e2e-http-sync-compose"
@@ -461,6 +473,14 @@ e2e_matrix="$(printf '%s\n' "${e2e_cases[@]}" | jq -R . | jq -cs '
461473
"e2e-logging-rocketmq-compose": {
462474
case: "shenyu-e2e-case-logging-rocketmq",
463475
example_projects: ":shenyu-examples-http"
476+
},
477+
"e2e-cluster-jdbc-compose": {
478+
case: "shenyu-e2e-case-cluster",
479+
example_projects: ":shenyu-examples-http"
480+
},
481+
"e2e-cluster-zookeeper-compose": {
482+
case: "shenyu-e2e-case-cluster",
483+
example_projects: ":shenyu-examples-http"
464484
}
465485
}[.];
466486

‎RELEASE-NOTES.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
### Behavior Changes
88

9+
- HTTP client registration now treats non-success Admin responses as failures,
10+
using the same bounded failback policy as transport errors (18 retry attempts
11+
per pending task). The text response contract does not reliably distinguish
12+
transient failures from permanent validation errors, so both consume that
13+
budget. Heartbeat failures are reported to the caller. Unregistration retains
14+
its existing policy: any successful Admin response is sufficient, and failure
15+
at every Admin is reported without adding a registration retry. (#7440)
16+
917
- Agent Gateway supports opt-in per-tool `mcp.structuredContentRemovals` field
1018
deletion with strict result-copy handling. Complete JSON text copies are rebuilt
1119
from filtered structuredContent. Opaque text/media, nonempty metadata and unknown

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
<kryo.version>4.0.0</kryo.version>
122122
<pagehelper.version>5.3.3</pagehelper.version>
123123
<apache.dubbo.version>3.2.14</apache.dubbo.version>
124-
<gson.version>2.9.0</gson.version>
124+
<gson.version>2.13.2</gson.version>
125125
<okhttp.version>4.9.3</okhttp.version>
126126
<prometheus-java-client.version>0.15.0</prometheus-java-client.version>
127127
<prometheus-jmx.version>0.15.0</prometheus-jmx.version>

‎shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AppAuthServiceImpl.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ public ConfigImportResult importData(final String namespace, final List<AppAuthD
380380
appAuthDO.setNamespaceId(namespace);
381381
int inserted = appAuthMapper.insertSelective(appAuthDO);
382382
if (inserted > 0) {
383+
existAppKeySet.add(appKey);
383384
successCount++;
384385
// auth path
385386
List<AuthPathDTO> authPathDTOList = appAuth.getAuthPathList();

‎shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/DiscoveryServiceImpl.java‎

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import org.springframework.transaction.support.TransactionTemplate;
6363

6464
import java.sql.Timestamp;
65+
import java.util.HashSet;
6566
import java.util.List;
6667
import java.util.Map;
6768
import java.util.Objects;
@@ -487,43 +488,42 @@ public ConfigImportResult importData(final String namespace, final List<Discover
487488
return ConfigImportResult.success();
488489
}
489490
Map<String, String> discoveryHandlerIdMapping = context.getDiscoveryHandlerIdMapping();
490-
Map<String, List<DiscoveryDO>> pluginDiscoveryMap = discoveryMapper
491+
Map<String, Set<String>> pluginDiscoveryMap = discoveryMapper
491492
.selectAllByNamespaceId(namespace)
492493
.stream()
493-
.collect(Collectors.groupingBy(DiscoveryDO::getPluginName));
494+
.collect(Collectors.groupingBy(DiscoveryDO::getPluginName,
495+
Collectors.mapping(DiscoveryDO::getDiscoveryName, Collectors.toSet())));
496+
Map<String, Map<String, String>> importedHandlerIdMap = Maps.newHashMap();
494497
int successCount = 0;
495498
StringBuilder errorMsgBuilder = new StringBuilder();
496499
for (DiscoveryDTO discoveryDTO : discoveryList) {
497500
String pluginName = discoveryDTO.getPluginName();
498501
String discoveryName = discoveryDTO.getName();
499-
Set<String> existDiscoveryNameSet = pluginDiscoveryMap
500-
.getOrDefault(pluginName, Lists.newArrayList())
501-
.stream()
502-
.map(DiscoveryDO::getDiscoveryName)
503-
.collect(Collectors.toSet());
502+
Set<String> existDiscoveryNameSet = pluginDiscoveryMap.computeIfAbsent(pluginName, key -> new HashSet<>());
503+
Map<String, String> importedHandlerIds = importedHandlerIdMap.computeIfAbsent(pluginName, key -> Maps.newHashMap());
504504
if (existDiscoveryNameSet.contains(discoveryName)) {
505505
errorMsgBuilder
506506
.append(discoveryName)
507507
.append(",");
508+
String importedHandlerId = importedHandlerIds.get(discoveryName);
509+
if (Objects.nonNull(importedHandlerId) && Objects.nonNull(discoveryDTO.getDiscoveryHandler())) {
510+
discoveryHandlerIdMapping.put(discoveryDTO.getDiscoveryHandler().getId(), importedHandlerId);
511+
}
508512
continue;
509513
}
510514
String discoveryId = UUIDUtils.getInstance().generateShortUuid();
511515
discoveryDTO.setId(discoveryId);
512516
discoveryDTO.setNamespaceId(namespace);
513-
create(discoveryDTO);
517+
if (Objects.isNull(create(discoveryDTO))) {
518+
continue;
519+
}
520+
existDiscoveryNameSet.add(discoveryName);
514521
successCount++;
515522

516523
// import discovery handler data
517-
String discoveryHandlerId = null;
518-
if (Objects.nonNull(discoveryDTO.getDiscoveryHandler())) {
519-
DiscoveryHandlerDO discoveryHandlerDO = DiscoveryTransfer
520-
.INSTANCE
521-
.mapToDO(discoveryDTO.getDiscoveryHandler());
522-
discoveryHandlerDO.setDiscoveryId(discoveryId);
523-
discoveryHandlerId = UUIDUtils.getInstance().generateShortUuid();
524-
discoveryHandlerIdMapping.put(discoveryHandlerDO.getId(), discoveryHandlerId);
525-
discoveryHandlerDO.setId(discoveryHandlerId);
526-
discoveryHandlerMapper.insertSelective(discoveryHandlerDO);
524+
String discoveryHandlerId = importDiscoveryHandler(discoveryDTO, context);
525+
if (Objects.nonNull(discoveryHandlerId)) {
526+
importedHandlerIds.put(discoveryName, discoveryHandlerId);
527527
}
528528

529529
// import discovery rel data
@@ -561,4 +561,17 @@ public ConfigImportResult importData(final String namespace, final List<Discover
561561
}
562562
return ConfigImportResult.success(successCount);
563563
}
564+
565+
private String importDiscoveryHandler(final DiscoveryDTO discoveryDTO, final ConfigsImportContext context) {
566+
if (Objects.isNull(discoveryDTO.getDiscoveryHandler())) {
567+
return null;
568+
}
569+
DiscoveryHandlerDO discoveryHandlerDO = DiscoveryTransfer.INSTANCE.mapToDO(discoveryDTO.getDiscoveryHandler());
570+
discoveryHandlerDO.setDiscoveryId(discoveryDTO.getId());
571+
String discoveryHandlerId = UUIDUtils.getInstance().generateShortUuid();
572+
context.getDiscoveryHandlerIdMapping().put(discoveryHandlerDO.getId(), discoveryHandlerId);
573+
discoveryHandlerDO.setId(discoveryHandlerId);
574+
discoveryHandlerMapper.insertSelective(discoveryHandlerDO);
575+
return discoveryHandlerId;
576+
}
564577
}

‎shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/DiscoveryUpstreamServiceImpl.java‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.springframework.util.StringUtils;
5656

5757
import java.util.Collections;
58+
import java.util.HashSet;
5859
import java.util.LinkedHashSet;
5960
import java.util.List;
6061
import java.util.Map;
@@ -358,18 +359,16 @@ public ConfigImportResult importData(final String namespace, final List<Discover
358359
Map<String, String> discoveryHandlerIdMapping = context.getDiscoveryHandlerIdMapping();
359360
int successCount = 0;
360361
StringBuilder errorMsgBuilder = new StringBuilder();
361-
Map<String, List<DiscoveryUpstreamDO>> discoveryHandlerUpstreamMap = discoveryUpstreamMapper
362+
Map<String, Set<String>> discoveryHandlerUpstreamMap = discoveryUpstreamMapper
362363
.selectByNamespaceId(namespace)
363364
.stream()
364-
.collect(Collectors.groupingBy(DiscoveryUpstreamDO::getDiscoveryHandlerId));
365+
.collect(Collectors.groupingBy(DiscoveryUpstreamDO::getDiscoveryHandlerId,
366+
Collectors.mapping(DiscoveryUpstreamDO::getUpstreamUrl, Collectors.toSet())));
365367
for (DiscoveryUpstreamDTO discoveryUpstreamDTO : discoveryUpstreamList) {
366368
String discoveryHandlerId = discoveryUpstreamDTO.getDiscoveryHandlerId();
367369
String url = discoveryUpstreamDTO.getUrl();
368-
Set<String> existsUpstreamUrlSet = discoveryHandlerUpstreamMap
369-
.getOrDefault(discoveryHandlerIdMapping.getOrDefault(discoveryHandlerId, discoveryHandlerId), Lists.newArrayList())
370-
.stream()
371-
.map(DiscoveryUpstreamDO::getUpstreamUrl)
372-
.collect(Collectors.toSet());
370+
String newDiscoveryHandlerId = discoveryHandlerIdMapping.getOrDefault(discoveryHandlerId, discoveryHandlerId);
371+
Set<String> existsUpstreamUrlSet = discoveryHandlerUpstreamMap.computeIfAbsent(newDiscoveryHandlerId, key -> new HashSet<>());
373372
if (existsUpstreamUrlSet.contains(url)) {
374373
errorMsgBuilder
375374
.append(url)
@@ -378,10 +377,12 @@ public ConfigImportResult importData(final String namespace, final List<Discover
378377
}
379378
discoveryUpstreamDTO.setNamespaceId(namespace);
380379
discoveryUpstreamDTO.setId(null);
381-
discoveryUpstreamDTO.setDiscoveryHandlerId(discoveryHandlerIdMapping.getOrDefault(discoveryUpstreamDTO.getDiscoveryHandlerId(), discoveryUpstreamDTO.getDiscoveryHandlerId()));
380+
discoveryUpstreamDTO.setDiscoveryHandlerId(newDiscoveryHandlerId);
382381
DiscoveryUpstreamDO discoveryUpstreamDO = DiscoveryUpstreamDO.buildDiscoveryUpstreamDO(discoveryUpstreamDTO);
383-
discoveryUpstreamMapper.insert(discoveryUpstreamDO);
384-
successCount++;
382+
if (discoveryUpstreamMapper.insert(discoveryUpstreamDO) > 0) {
383+
existsUpstreamUrlSet.add(url);
384+
successCount++;
385+
}
385386
}
386387
if (StringUtils.hasLength(errorMsgBuilder)) {
387388
errorMsgBuilder.setLength(errorMsgBuilder.length() - 1);

‎shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/MetaDataServiceImpl.java‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ public void saveOrUpdateMetaData(final MetaDataDO exist, final MetaDataRegisterD
104104
@Override
105105
@Transactional(rollbackFor = Exception.class)
106106
public String createOrUpdate(final MetaDataDTO metaDataDTO) {
107-
return StringUtils.isBlank(metaDataDTO.getId()) ? this.create(metaDataDTO) : this.update(metaDataDTO);
107+
if (StringUtils.isBlank(metaDataDTO.getId())) {
108+
create(metaDataDTO);
109+
return ShenyuResultMessage.CREATE_SUCCESS;
110+
}
111+
return update(metaDataDTO);
108112
}
109113

110114
@Override
@@ -276,8 +280,10 @@ public ConfigImportResult importData(final String namespace, final List<MetaData
276280
continue;
277281
}
278282
metaDataDTO.setNamespaceId(namespace);
279-
create(metaDataDTO);
280-
successCount++;
283+
if (create(metaDataDTO) > 0) {
284+
existMetadataPathSet.add(metaDataPath);
285+
successCount++;
286+
}
281287
}
282288
if (StringUtils.isNotEmpty(errorMsgBuilder)) {
283289
errorMsgBuilder.setLength(errorMsgBuilder.length() - 1);
@@ -286,22 +292,23 @@ public ConfigImportResult importData(final String namespace, final List<MetaData
286292
return ConfigImportResult.success(successCount);
287293
}
288294

289-
private String create(final MetaDataDTO metaDataDTO) {
295+
private int create(final MetaDataDTO metaDataDTO) {
290296
Assert.isNull(metaDataMapper.pathExisted(metaDataDTO.getPath(), metaDataDTO.getNamespaceId()), AdminConstants.DATA_PATH_IS_EXIST);
291297
MetaDataDO metaDataDO = MetaDataTransfer.INSTANCE.mapToEntity(metaDataDTO);
292298
metaDataDO.setId(UUIDUtils.getInstance().generateShortUuid());
293299
metaDataDO.setPathDesc(Objects.isNull(metaDataDO.getPathDesc()) ? "" : metaDataDO.getPathDesc());
294300
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
295301
metaDataDO.setDateCreated(currentTime);
296302
metaDataDO.setDateUpdated(currentTime);
297-
if (metaDataMapper.insert(metaDataDO) > 0) {
303+
final int inserted = metaDataMapper.insert(metaDataDO);
304+
if (inserted > 0) {
298305
publisher.onCreated(metaDataDO);
299306
}
300307

301308
// publish MetaData's create event
302309
eventPublisher.publishEvent(new DataChangedEvent(ConfigGroupEnum.META_DATA, DataEventTypeEnum.CREATE,
303310
Collections.singletonList(MetaDataTransfer.INSTANCE.mapToData(metaDataDO))));
304-
return ShenyuResultMessage.CREATE_SUCCESS;
311+
return inserted;
305312
}
306313

307314
private String update(final MetaDataDTO metaDataDTO) {

0 commit comments

Comments
 (0)