Skip to content

Commit

Permalink
fix: network config issue due to reference (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudoyu authored Oct 31, 2024
1 parent d2c853b commit f36be1c
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions internal/node/component/info/handler_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func getNetworkConfigDetailForRSS(protocol network.Protocol) NetworkConfigDetail
worker := rss.Core
config := WorkerToConfigMap[protocol][worker]

workerConfig := config
workerConfig := deepCopyWorkerConfig(config)
workerConfig.ID.Value = n.String() + "-" + worker.Name()
workerConfig.Network.Value = n.String()
workerConfig.MinimumResource = calculateMinimumResources(n, worker)
Expand Down Expand Up @@ -119,7 +119,7 @@ func getWorkerConfigs(protocol network.Protocol, n network.Network) []workerConf

for w, config := range WorkerToConfigMap[protocol] {
if lo.Contains(NetworkToWorkersMap[n], w) {
workerConfig := createWorkerConfig(n, w, config)
workerConfig := createWorkerConfig(n, w, deepCopyWorkerConfig(config))
workerConfigs = append(workerConfigs, workerConfig)
}
}
Expand All @@ -128,17 +128,27 @@ func getWorkerConfigs(protocol network.Protocol, n network.Network) []workerConf
}

func createWorkerConfig(n network.Network, worker worker.Worker, config workerConfig) workerConfig {
workerConfig := config
workerConfig.ID.Value = n.String() + "-" + worker.Name()
workerConfig.Network.Value = n.String()
workerConfig.MinimumResource = calculateMinimumResources(n, worker)
config.ID.Value = n.String() + "-" + worker.Name()
config.Network.Value = n.String()
config.MinimumResource = calculateMinimumResources(n, worker)

if workerConfig.EndpointID != nil {
workerConfig.EndpointID.Type = StringType
workerConfig.EndpointID.Value = n.String()
if config.EndpointID != nil {
config.EndpointID.Type = StringType
config.EndpointID.Value = n.String()
}

return config
}

func deepCopyWorkerConfig(config workerConfig) workerConfig {
newConfig := config

if config.EndpointID != nil {
newEndpointID := *config.EndpointID
newConfig.EndpointID = &newEndpointID
}

return workerConfig
return newConfig
}

func sortWorkerConfigs(workerConfigs []workerConfig) {
Expand Down

0 comments on commit f36be1c

Please sign in to comment.