AsperforMias commented on code in PR #1553:
URL: https://github.com/apache/dubbo-admin/pull/1553#discussion_r4245478403
##########
pkg/discovery/zk/factory.go:
##########
@@ -130,18 +132,37 @@ func toUpsertZKConfigResource(mesh, nodePath, nodeData
string) coremodel.Resourc
}
func toDeleteZKConfigResource(mesh, nodePath string) coremodel.Resource {
- paths := strings.Split(nodePath, constants.PathSeparator)
- if len(paths) != 4 {
+ configName, ok := zkConfigName(nodePath)
+ if !ok {
return nil
}
- configName := paths[3]
res := meshresource.NewZKConfigResourceWithAttributes(configName, mesh)
res.Spec = &meshproto.ZKConfig{
NodeName: configName,
}
return res
}
+// zkConfigName accepts the Dubbo 3 grouped config path
+// /dubbo/config/dubbo/<ruleName> and the legacy flat path
+// /dubbo/config/<ruleName>. Group/root nodes are not rules.
+func zkConfigName(nodePath string) (string, bool) {
+ paths := strings.Split(strings.Trim(nodePath, constants.PathSeparator),
constants.PathSeparator)
+ // Trim above removes the leading slash, therefore the grouped form has
+ // [dubbo config dubbo rule] and the legacy form [dubbo config rule].
+ switch len(paths) {
+ case 3:
+ if paths[2] != "" && paths[2] != constants.RuleConfigGroup {
+ return paths[2], true
+ }
+ case 4:
+ if paths[2] == constants.RuleConfigGroup && paths[3] != "" {
+ return paths[3], true
Review Comment:
[P1] Keep the source path when grouped and legacy rules coexist
Both `/dubbo/config/demo.affinity-router` and
`/dubbo/config/dubbo/demo.affinity-router` collapse to the same config/resource
name here. No source path or precedence survives for the subscriber to
distinguish them.
I reproduced the factory/subscriber event chain using an in-memory store:
add the legacy node, add the grouped node, then delete only the legacy node.
`processConfigDelete` removes the Affinity resource from Admin even though the
grouped node consumed by Go still exists. An update from the legacy path can
similarly overwrite the grouped rule's displayed state. This can leave Admin
showing no rule while the consumer continues executing one; the normal delete
API then cannot reliably revoke that live policy.
Please define grouped-versus-legacy precedence and retain enough source
identity for update/delete handling, or perform an explicit migration. Add a
regression covering coexistence and deletion of the non-authoritative node.
This reproduction exercised the event chain, not a live ZooKeeper server.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]