Fix service group name when upgrading. (#5674)

* [ISSUE #5671] Prefer serviceV2.groupName using groupName in serviceV1.name

* [ISSUE #5671] Add groupName to service when creating by v1 operator
This commit is contained in:
Pixy Yuan 2021-05-11 20:41:18 +08:00 committed by GitHub
parent 6afcb059e0
commit b6d96b69c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

View File

@ -61,6 +61,7 @@ public class ServiceOperatorV1Impl implements ServiceOperator {
service.setMetadata(metadata.getExtendData());
service.setSelector(metadata.getSelector());
service.setNamespaceId(namespaceId);
service.setGroupName(NamingUtils.getGroupName(serviceName));
// now valid the service. if failed, exception will be thrown
service.setLastModifiedMillis(System.currentTimeMillis());

View File

@ -151,7 +151,7 @@ public class ServiceChangeV1Task extends AbstractDelayTask {
private com.alibaba.nacos.naming.core.v2.pojo.Service transfer(Service service, boolean ephemeral) {
return com.alibaba.nacos.naming.core.v2.pojo.Service
.newService(service.getNamespaceId(), service.getGroupName(),
.newService(service.getNamespaceId(), NamingUtils.getGroupName(service.getName()),
NamingUtils.getServiceName(service.getName()), ephemeral);
}

View File

@ -71,7 +71,7 @@ public class AsyncServicesCheckTask extends AbstractExecuteTask {
if (upgradeJudgement.isUseGrpcFeatures()) {
return;
}
String groupName = serviceV1.getGroupName();
String groupName = NamingUtils.getGroupName(serviceV1.getName());
String serviceName = NamingUtils.getServiceName(fullServiceName);
com.alibaba.nacos.naming.core.v2.pojo.Service serviceV2 = com.alibaba.nacos.naming.core.v2.pojo.Service
.newService(namespace, groupName, serviceName);