xiaobaicai66695 commented on code in PR #1553:
URL: https://github.com/apache/dubbo-admin/pull/1553#discussion_r4302201382


##########
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:
   Thanks for the reproduction — I agree that the current implementation is 
unsafe. It accepts both paths and normalizes them to the same resource name, so 
an event from one path can overwrite or delete the state derived from the other.
   I traced the configuration-center contract and found that the flat leaf path 
is not a supported Dubbo-Go consumer key. In the Dubbo-Go ZooKeeper 
implementation, both AddListener and GetProperties prepend the configured 
namespace/default group (dubbo) to the rule key, yielding 
/dubbo/config/dubbo/<ruleName> 
([listener](https://github.com/apache/dubbo-go/blob/35ea886421f9/config_center/zookeeper/impl.go#L104-L109),
 
[read](https://github.com/apache/dubbo-go/blob/35ea886421f9/config_center/zookeeper/impl.go#L126-L138),
 [default 
group](https://github.com/apache/dubbo-go/blob/35ea886421f9/config_center/dynamic_configuration.go#L30)).
   This also matches the established Admin contract: the 2019 fix for Dubbo 
2.7.3 changed Admin from config to config/dubbo and changed condition/tag rules 
to the <key>.<rule-suffix> form because the previous layout did not take effect 
([bc57d858](https://github.com/apache/dubbo-admin/commit/bc57d85880113a523b3276d296fae46cbd886d4c)).
   Therefore, rather than assigning precedence between two live sources, I will 
make the grouped path the only Admin rule source:
   - discovery will recognize only /dubbo/config/dubbo/<ruleName>;
   - the ZooKeeper governor will create, update, and delete only that path for 
every rule kind;
   - /dubbo/config/<ruleName> will not be materialized as an Admin rule and 
will not be deleted as a fallback.
   This removes the collision entirely instead of retaining source-path state 
and precedence for a path that current consumers do not read. Existing flat 
nodes will be left untouched; any cleanup or migration should be explicit and 
outside normal rule CRUD.
   I will update the unit coverage to reject flat nodes and to assert grouped 
paths for existing rule kinds, in addition to the real ZooKeeper → Dubbo-Go 
RouterChain E2E coverage.



-- 
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]

Reply via email to