Skip to content

Commit 3644d53

Browse files
authored
Merge pull request #13173 from alibaba/develop
Release 2.5.1
2 parents 11de43f + 3d2f10b commit 3644d53

File tree

95 files changed

+2198
-1620
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2198
-1620
lines changed

.github/workflows/pr-ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Build distribution tar
2222
run: |
2323
mvn -Prelease-nacos -DskipTests clean install -U -e -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
24-
- uses: actions/upload-artifact@v3
24+
- uses: actions/upload-artifact@v4
2525
name: Upload distribution tar
2626
with:
2727
name: nacos
@@ -30,7 +30,7 @@ jobs:
3030
run: |
3131
mkdir -p ./pr
3232
echo ${{ github.event.pull_request.number }} > ./pr/pr.txt
33-
- uses: actions/upload-artifact@v3
33+
- uses: actions/upload-artifact@v4
3434
name: Upload PR number
3535
with:
3636
name: pr

.github/workflows/pr-e2e-test.yml

+15-15
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ jobs:
3131
version-json: ${{ steps.show_versions.outputs.version-json }}
3232
steps:
3333
- name: 'Download artifact'
34-
uses: actions/github-script@v3.1.0
34+
uses: actions/github-script@v6
3535
with:
3636
script: |
37-
var artifacts = await github.actions.listWorkflowRunArtifacts({
37+
let artifacts = await github.rest.actions.listWorkflowRunArtifacts({
3838
owner: context.repo.owner,
3939
repo: context.repo.repo,
4040
run_id: ${{ github.event.workflow_run.id }},
4141
});
42-
var matchArtifactNacos = artifacts.data.artifacts.filter((artifact) => {
42+
let matchArtifactNacos = artifacts.data.artifacts.filter((artifact) => {
4343
return artifact.name == "nacos"
4444
})[0];
45-
var download = await github.actions.downloadArtifact({
45+
let download = await github.rest.actions.downloadArtifact({
4646
owner: context.repo.owner,
4747
repo: context.repo.repo,
4848
artifact_id: matchArtifactNacos.id,
@@ -157,7 +157,7 @@ jobs:
157157
branch: main
158158
repoType: git
159159
retries: 3
160-
url: https://ghproxy.com/https://github.com/nacos-group/nacos-e2e.git
160+
url: https://github.com/nacos-group/nacos-e2e.git
161161
values:
162162
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
163163
global:
@@ -226,7 +226,7 @@ jobs:
226226
RESOURCE_REQUIRE:
227227
cpu: 2
228228
memory: 2Gi
229-
- uses: actions/upload-artifact@v3
229+
- uses: actions/upload-artifact@v4
230230
if: always()
231231
name: Upload test log
232232
with:
@@ -278,7 +278,7 @@ jobs:
278278
RESOURCE_REQUIRE:
279279
cpu: 2
280280
memory: 2Gi
281-
- uses: actions/upload-artifact@v3
281+
- uses: actions/upload-artifact@v4
282282
if: always()
283283
name: Upload test log
284284
with:
@@ -333,7 +333,7 @@ jobs:
333333
RESOURCE_REQUIRE:
334334
cpu: 2
335335
memory: 2Gi
336-
- uses: actions/upload-artifact@v3
336+
- uses: actions/upload-artifact@v4
337337
if: always()
338338
name: Upload test log
339339
with:
@@ -386,7 +386,7 @@ jobs:
386386
RESOURCE_REQUIRE:
387387
cpu: 2
388388
memory: 2Gi
389-
- uses: actions/upload-artifact@v3
389+
- uses: actions/upload-artifact@v4
390390
if: always()
391391
name: Upload test log
392392
with:
@@ -437,7 +437,7 @@ jobs:
437437
RESOURCE_REQUIRE:
438438
cpu: 2
439439
memory: 2Gi
440-
- uses: actions/upload-artifact@v3
440+
- uses: actions/upload-artifact@v4
441441
if: always()
442442
name: Upload test log
443443
with:
@@ -490,7 +490,7 @@ jobs:
490490
RESOURCE_REQUIRE:
491491
cpu: 2
492492
memory: 2Gi
493-
- uses: actions/upload-artifact@v3
493+
- uses: actions/upload-artifact@v4
494494
if: always()
495495
name: Upload test log
496496
with:
@@ -529,19 +529,19 @@ jobs:
529529
timeout-minutes: 5
530530
steps:
531531
- name: 'Download artifact'
532-
uses: actions/github-script@v3.1.0
532+
uses: actions/github-script@v6
533533
with:
534534
script: |
535-
var artifacts = await github.actions.listWorkflowRunArtifacts({
535+
let artifacts = await github.rest.actions.listWorkflowRunArtifacts({
536536
owner: context.repo.owner,
537537
repo: context.repo.repo,
538538
run_id: ${{ github.event.workflow_run.id }},
539539
});
540540
541-
var matchArtifactPR = artifacts.data.artifacts.filter((artifact) => {
541+
let matchArtifactPR = artifacts.data.artifacts.filter((artifact) => {
542542
return artifact.name == "pr"
543543
})[0];
544-
var download = await github.actions.downloadArtifact({
544+
let download = await github.rest.actions.downloadArtifact({
545545
owner: context.repo.owner,
546546
repo: context.repo.repo,
547547
artifact_id: matchArtifactPR.id,

.github/workflows/push-ci.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ jobs:
168168
branch: main
169169
repoType: git
170170
retries: 3
171-
url: https://ghproxy.com/https://github.com/nacos-group/nacos-e2e.git
171+
url: https://github.com/nacos-group/nacos-e2e.git
172172
values:
173173
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
174174
global:
@@ -238,7 +238,7 @@ jobs:
238238
cpu: 2
239239
memory: 2Gi
240240
241-
- uses: actions/upload-artifact@v3
241+
- uses: actions/upload-artifact@v4
242242
if: always()
243243
name: Upload test log
244244
with:
@@ -290,7 +290,7 @@ jobs:
290290
RESOURCE_REQUIRE:
291291
cpu: 2
292292
memory: 2Gi
293-
- uses: actions/upload-artifact@v3
293+
- uses: actions/upload-artifact@v4
294294
if: always()
295295
name: Upload test log
296296
with:
@@ -345,7 +345,7 @@ jobs:
345345
RESOURCE_REQUIRE:
346346
cpu: 2
347347
memory: 2Gi
348-
- uses: actions/upload-artifact@v3
348+
- uses: actions/upload-artifact@v4
349349
if: always()
350350
name: Upload test log
351351
with:
@@ -398,7 +398,7 @@ jobs:
398398
RESOURCE_REQUIRE:
399399
cpu: 2
400400
memory: 2Gi
401-
- uses: actions/upload-artifact@v3
401+
- uses: actions/upload-artifact@v4
402402
if: always()
403403
name: Upload test log
404404
with:
@@ -449,7 +449,7 @@ jobs:
449449
RESOURCE_REQUIRE:
450450
cpu: 2
451451
memory: 2Gi
452-
- uses: actions/upload-artifact@v3
452+
- uses: actions/upload-artifact@v4
453453
if: always()
454454
name: Upload test log
455455
with:
@@ -500,7 +500,7 @@ jobs:
500500
RESOURCE_REQUIRE:
501501
cpu: 2
502502
memory: 2Gi
503-
- uses: actions/upload-artifact@v3
503+
- uses: actions/upload-artifact@v4
504504
if: always()
505505
name: Upload test log
506506
with:

api/src/main/java/com/alibaba/nacos/api/exception/NacosException.java

+5
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ public String toString() {
143143
*/
144144
public static final int CONFLICT = 409;
145145

146+
/**
147+
* config already exists(配置已存在).
148+
*/
149+
public static final int CONFIG_ALREADY_EXISTS = 410;
150+
146151
/**
147152
* server error(server异常,如超时).
148153
*/

api/src/main/java/com/alibaba/nacos/api/model/v2/ErrorCode.java

+29
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,26 @@ public enum ErrorCode {
110110
*/
111111
CONFIG_GRAY_NAME_UNRECOGNIZED_ERROR(20013, "config gray name not recognized"),
112112

113+
/**
114+
* reach cluster quota.
115+
*/
116+
OVER_CLUSTER_QUOTA(5031, "cluster capacity reach quota"),
117+
118+
/**
119+
* reach group quota.
120+
*/
121+
OVER_GROUP_QUOTA(5032, "group capacity reach quota"),
122+
123+
/**
124+
* reach tenant quota.
125+
*/
126+
OVER_TENANT_QUOTA(5033, "tenant capacity reach quota"),
127+
128+
/**
129+
* over max content size.
130+
*/
131+
OVER_MAX_SIZE(5034, "config content size is over limit"),
132+
113133
/**
114134
* service name error.
115135
*/
@@ -217,6 +237,15 @@ public String getMsg() {
217237
return msg;
218238
}
219239

240+
public static ErrorCode getErrorCode(String name) {
241+
for (ErrorCode errorCode : ErrorCode.values()) {
242+
if (errorCode.name().equals(name)) {
243+
return errorCode;
244+
}
245+
}
246+
return null;
247+
}
248+
220249
ErrorCode(Integer code, String msg) {
221250
this.code = code;
222251
this.msg = msg;

api/src/main/java/com/alibaba/nacos/api/naming/pojo/ServiceInfo.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,17 @@ public String getKey() {
215215

216216
@JsonIgnore
217217
public static String getKey(String name, String clusters) {
218-
219218
if (!isEmpty(clusters)) {
220219
return name + Constants.SERVICE_INFO_SPLITER + clusters;
221220
}
222-
223221
return name;
224222
}
225-
223+
224+
@JsonIgnore
225+
public String getKeyWithoutClusters() {
226+
return getGroupedServiceName();
227+
}
228+
226229
@JsonIgnore
227230
public String getKeyEncoded() {
228231
String serviceName = getGroupedServiceName();

client/pom.xml

-5
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@
7676
<artifactId>nacos-log4j2-adapter</artifactId>
7777
</dependency>
7878

79-
<dependency>
80-
<artifactId>commons-codec</artifactId>
81-
<groupId>commons-codec</groupId>
82-
</dependency>
83-
8479
<dependency>
8580
<groupId>com.fasterxml.jackson.core</groupId>
8681
<artifactId>jackson-core</artifactId>

client/src/main/java/com/alibaba/nacos/client/auth/impl/NacosClientAuthServiceImpl.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.alibaba.nacos.api.PropertyKeyConst;
2020
import com.alibaba.nacos.api.exception.NacosException;
2121
import com.alibaba.nacos.client.auth.impl.process.HttpLoginProcessor;
22+
import com.alibaba.nacos.common.utils.RandomUtils;
2223
import com.alibaba.nacos.common.utils.StringUtils;
2324
import com.alibaba.nacos.plugin.auth.api.LoginIdentityContext;
2425
import com.alibaba.nacos.plugin.auth.api.RequestResource;
@@ -35,6 +36,7 @@
3536
* @author wuyfee
3637
*/
3738

39+
@SuppressWarnings("checkstyle:SummaryJavadoc")
3840
public class NacosClientAuthServiceImpl extends AbstractClientAuthService {
3941

4042
private static final Logger SECURITY_LOGGER = LoggerFactory.getLogger(NacosClientAuthServiceImpl.class);
@@ -97,7 +99,7 @@ public Boolean login(Properties properties) {
9799
if (identityContext != null) {
98100
if (identityContext.getAllKey().contains(NacosAuthLoginConstant.ACCESSTOKEN)) {
99101
tokenTtl = Long.parseLong(identityContext.getParameter(NacosAuthLoginConstant.TOKENTTL));
100-
tokenRefreshWindow = tokenTtl / 10;
102+
tokenRefreshWindow = generateTokenRefreshWindow(tokenTtl);
101103
lastRefreshTime = System.currentTimeMillis();
102104

103105
LoginIdentityContext newCtx = new LoginIdentityContext();
@@ -124,4 +126,15 @@ public LoginIdentityContext getLoginIdentityContext(RequestResource resource) {
124126
public void shutdown() throws NacosException {
125127

126128
}
129+
130+
/**
131+
* Randomly generate TokenRefreshWindow, Avoid a large number of logins causing pressure on the Nacos server.
132+
* @param tokenTtl TTL of token in seconds.
133+
* @return tokenRefreshWindow, numerical range [tokenTtl/15 ~ tokenTtl/10]
134+
*/
135+
public long generateTokenRefreshWindow(long tokenTtl) {
136+
long startNumber = tokenTtl / 15;
137+
long endNumber = tokenTtl / 10;
138+
return RandomUtils.nextLong(startNumber, endNumber);
139+
}
127140
}

client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@
5959
import com.alibaba.nacos.common.remote.client.Connection;
6060
import com.alibaba.nacos.common.remote.client.ConnectionEventListener;
6161
import com.alibaba.nacos.common.remote.client.RpcClient;
62+
import com.alibaba.nacos.common.remote.client.RpcClientConfigFactory;
6263
import com.alibaba.nacos.common.remote.client.RpcClientFactory;
63-
import com.alibaba.nacos.common.remote.client.RpcClientTlsConfig;
64-
import com.alibaba.nacos.common.remote.client.RpcClientTlsConfigFactory;
6564
import com.alibaba.nacos.common.remote.client.ServerListFactory;
65+
import com.alibaba.nacos.common.remote.client.grpc.GrpcClientConfig;
6666
import com.alibaba.nacos.common.utils.ConnLabelsUtils;
6767
import com.alibaba.nacos.common.utils.ConvertUtils;
6868
import com.alibaba.nacos.common.utils.JacksonUtils;
@@ -1093,10 +1093,9 @@ private RpcClient ensureRpcClient(String taskId) throws NacosException {
10931093
Map<String, String> labels = getLabels();
10941094
Map<String, String> newLabels = new HashMap<>(labels);
10951095
newLabels.put("taskId", taskId);
1096-
RpcClientTlsConfig clientTlsConfig = RpcClientTlsConfigFactory.getInstance()
1097-
.createSdkConfig(properties);
1098-
RpcClient rpcClient = RpcClientFactory.createClient(uuid + "_config-" + taskId, getConnectionType(),
1099-
newLabels, clientTlsConfig);
1096+
GrpcClientConfig grpcClientConfig = RpcClientConfigFactory.getInstance()
1097+
.createGrpcClientConfig(properties, newLabels);
1098+
RpcClient rpcClient = RpcClientFactory.createClient(uuid + "_config-" + taskId, getConnectionType(), grpcClientConfig);
11001099
if (rpcClient.isWaitInitiated()) {
11011100
initRpcClientHandler(rpcClient);
11021101
rpcClient.setTenant(getTenant());

0 commit comments

Comments
 (0)