configurable data path concurrency: all in one json

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2023-11-08 11:00:35 +08:00
parent c638ca557e
commit db43200cc8
5 changed files with 61 additions and 49 deletions

View File

@@ -61,7 +61,7 @@ type RuledConfigs struct {
type Configs struct {
// DataPathConcurrency is the config for data path concurrency per node.
DataPathConcurrency *DataPathConcurrency
DataPathConcurrency *DataPathConcurrency `json:"dataPathConcurrency,omitempty"`
}
// IsRunning checks if the node agent daemonset is running properly. If not, return the error found
@@ -128,16 +128,16 @@ func GetConfigs(ctx context.Context, namespace string, kubeClient kubernetes.Int
return nil, errors.Errorf("data is not available in config map %s", configName)
}
jsonString, exist := cm.Data[dataPathConConfigName]
if !exist {
return nil, nil
jsonString := ""
for _, v := range cm.Data {
jsonString = v
}
concurrencyConfigs := &DataPathConcurrency{}
err = json.Unmarshal([]byte(jsonString), concurrencyConfigs)
configs := &Configs{}
err = json.Unmarshal([]byte(jsonString), configs)
if err != nil {
return nil, errors.Wrapf(err, "error to unmarshall data path concurrency configs from %s", configName)
return nil, errors.Wrapf(err, "error to unmarshall configs from %s", configName)
}
return &Configs{DataPathConcurrency: concurrencyConfigs}, nil
return configs, nil
}