Copilot commented on code in PR #961:
URL: https://github.com/apache/dubbo-go-pixiu/pull/961#discussion_r3367018494
##########
pkg/server/cluster_manager.go:
##########
@@ -356,23 +356,39 @@ func (s *ClusterStore) AddCluster(c *model.ClusterConfig)
{
stopClusters([]*cluster.Cluster{s.replaceClusterRuntime(c.Name, c)})
}
-// prepareClusterConfig rebuilds endpoint defaults and hash from current
endpoints.
+// prepareClusterConfig clones operator-supplied endpoints, then rebuilds
+// endpoint defaults and hash from current endpoints.
func (s *ClusterStore) prepareClusterConfig(c *model.ClusterConfig) {
+ if c == nil {
+ return
+ }
+ c.Endpoints = model.CloneEndpoints(c.Endpoints)
+ s.prepareOwnedClusterConfig(c)
+}
+
+// prepareOwnedClusterConfig rebuilds endpoint defaults and hash for endpoints
+// already owned by ClusterStore. Callers must not pass operator-owned endpoint
+// pointers here; use prepareClusterConfig at external input boundaries.
+func (s *ClusterStore) prepareOwnedClusterConfig(c *model.ClusterConfig) {
+ if c == nil {
+ return
+ }
s.assembleClusterEndpoints(c)
c.CreateConsistentHash()
}
// assembleClusterEndpoints assembles the cluster endpoints by formatting the
// ID, name and domains for each endpoint. If endpoint.LLMMeta is not nil, the
// assimilation of name and domain is based on the LLM provider denoted in the
-// endpoint LLMMeta. The store first deep-clones c.Endpoints, so ID/name
-// defaulting never mutates operator-supplied *model.Endpoint values.
+// endpoint LLMMeta. Callers choose the ownership boundary before invoking this
+// helper: external input paths clone endpoints in prepareClusterConfig, while
+// store-owned mutation paths call prepareOwnedClusterConfig to avoid a second
+// full endpoint clone before snapshot publication.
Review Comment:
The assembleClusterEndpoints doc comment still claims it formats endpoint
"domains" and performs name/domain "assimilation", but the function only
assigns default IDs and names. This mismatch is confusing and makes the
ownership-boundary guidance harder to follow; please update the comment to
reflect the actual behavior.
--
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]