Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue of configuration modification failure #1544

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,14 @@ public boolean publishConfig(String key, Map<String, String> labels, String cont

@Override
public boolean publishConfig(String key, String group, String content) {
return this.publishConfig(key, LabelGroupUtils.resolveGroupLabels(group), content, true);
final Optional<String> keyIdOptional = this.getKeyId(key, group);
if (keyIdOptional.isPresent()) {
return this.doUpdateConfig(keyIdOptional.get(), content, true);
}

// If not exists, then publish
final Map<String, String> labels = LabelGroupUtils.resolveGroupLabels(group);
return this.publishConfig(key, labels, content, true);
}

/**
Expand Down Expand Up @@ -255,7 +262,7 @@ public boolean removeConfig(String key, String group) {
return false;
}
final HttpResult httpResult = this.httpClient.doDelete(buildKeyIdUrl(keyIdOptional.get()));
return httpResult.getCode() == HttpStatus.SC_OK;
return httpResult.getCode() == HttpStatus.SC_NO_CONTENT;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,7 @@ public boolean removeGroupListener(String group, DynamicConfigListener listener)
* @return publish result
*/
public boolean publishConfig(String key, String group, String content) {
final Optional<String> keyIdOptional = this.kieClient.getKeyId(key, group);
if (!keyIdOptional.isPresent()) {
// If not exists, then publish
final Map<String, String> labels = LabelGroupUtils.resolveGroupLabels(group);
return kieClient.publishConfig(key, labels, content, true);
} else {
return kieClient.doUpdateConfig(keyIdOptional.get(), content, true);
}
return kieClient.publishConfig(key, group, content);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ private Map<String, List<String>> fuzzyGetConfigListByGroupAndKey(String key, St
if (!child.contains(nodeName)) {
continue;
}
String childPath = parentNodePath + child;
String childPath;
if (parentNodePath.endsWith(String.valueOf(ZK_PATH_SEPARATOR))) {
childPath = parentNodePath + child;
} else {
childPath = parentNodePath + ZK_PATH_SEPARATOR + child;
}
lilai23 marked this conversation as resolved.
Show resolved Hide resolved
List<String> subChild = this.zkClient.getChildren(childPath, false);
if (subChild == null || subChild.isEmpty()) {
continue;
Expand Down
28 changes: 28 additions & 0 deletions sermant-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<aspectjweaver.version>1.8.4</aspectjweaver.version>
<tomcat-embed.version>9.0.86</tomcat-embed.version>
<spring-framework.version>5.3.33</spring-framework.version>
<nacos-client-version>2.2.1</nacos-client-version>
<webapp.path>${project.basedir}/src/main/webapp/frontend</webapp.path>
</properties>

Expand Down Expand Up @@ -250,8 +251,35 @@
<dependency>
<groupId>io.sermant</groupId>
<artifactId>sermant-agentcore-implement</artifactId>
<exclusions>
<exclusion>
<groupId>io.envoyproxy.controlplane</groupId>
<artifactId>api</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</exclusion>
<exclusion>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
</exclusion>
</exclusions>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${nacos-client-version}</version>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private ConfigClient getConfigClient(String namespace) {
return configClient;
}
ConfigClient client = CONFIG_CLIENT_MAP.get(namespace);
if (client == null || !client.isConnect()) {
if (client == null) {
return createNacosClient(namespace);
}
return client;
Expand Down Expand Up @@ -326,7 +326,7 @@ public void reConnection() {
}
if (ConfigCenterType.NACOS.name().equals(dynamicConfig.getDynamicConfigType()) && !configClient.isConnect()) {
for (Map.Entry<String, ConfigClient> entry : CONFIG_CLIENT_MAP.entrySet()) {
getConfigClient(entry.getKey());
createNacosClient(entry.getKey());
}
}
}
Expand Down
Loading