Skip to content

Commit

Permalink
Fix service group name when upgrading. (#5674)
Browse files Browse the repository at this point in the history
* [ISSUE #5671] Prefer serviceV2.groupName using groupName in serviceV1.name

* [ISSUE #5671] Add groupName to service when creating by v1 operator
  • Loading branch information
pixystone authored May 11, 2021
1 parent 6afcb05 commit b6d96b6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void create(String namespaceId, String serviceName, ServiceMetadata metad
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private void dispatchInstanceTask(Service service, boolean ephemeral) {

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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void checkService(String namespace, String fullServiceName, Service serv
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);
Expand Down

0 comments on commit b6d96b6

Please sign in to comment.