mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-25 07:09:04 +01:00
Fix: MetricReceiver uses uninitialized values, when initialization fails
This commit is contained in:
parent
f911ff802c
commit
2f044f4b58
@ -30,11 +30,13 @@ type ReceiveManager interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rm *receiveManager) Init(wg *sync.WaitGroup, receiverConfigFile string) error {
|
func (rm *receiveManager) Init(wg *sync.WaitGroup, receiverConfigFile string) error {
|
||||||
|
// Initialize struct fields
|
||||||
rm.inputs = make([]Receiver, 0)
|
rm.inputs = make([]Receiver, 0)
|
||||||
rm.output = nil
|
rm.output = nil
|
||||||
rm.done = make(chan bool)
|
rm.done = make(chan bool)
|
||||||
rm.wg = wg
|
rm.wg = wg
|
||||||
rm.config = make([]json.RawMessage, 0)
|
rm.config = make([]json.RawMessage, 0)
|
||||||
|
|
||||||
configFile, err := os.Open(receiverConfigFile)
|
configFile, err := os.Open(receiverConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError("ReceiveManager", err.Error())
|
cclog.ComponentError("ReceiveManager", err.Error())
|
||||||
@ -51,6 +53,7 @@ func (rm *receiveManager) Init(wg *sync.WaitGroup, receiverConfigFile string) er
|
|||||||
for name, raw := range rawConfigs {
|
for name, raw := range rawConfigs {
|
||||||
rm.AddInput(name, raw)
|
rm.AddInput(name, raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +80,7 @@ func (rm *receiveManager) AddInput(name string, rawConfig json.RawMessage) error
|
|||||||
}
|
}
|
||||||
r, err := AvailableReceivers[config.Type](name, rawConfig)
|
r, err := AvailableReceivers[config.Type](name, rawConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError("ReceiveManager", "SKIP", r.Name(), "initialization failed:", err.Error())
|
cclog.ComponentError("ReceiveManager", "SKIP", name, "initialization failed:", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
rm.inputs = append(rm.inputs, r)
|
rm.inputs = append(rm.inputs, r)
|
||||||
|
Loading…
Reference in New Issue
Block a user