mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-26 15:29:04 +01:00
Fix kernel panic for receiver config with missing receiver type
This commit is contained in:
parent
7bb80780e0
commit
234ad3c54e
@ -2,6 +2,7 @@ package receivers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -71,9 +72,13 @@ func (rm *receiveManager) AddInput(name string, rawConfig json.RawMessage) error
|
|||||||
cclog.ComponentError("ReceiveManager", "SKIP", config.Type, "JSON config error:", err.Error())
|
cclog.ComponentError("ReceiveManager", "SKIP", config.Type, "JSON config error:", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if config.Type == "" {
|
||||||
|
cclog.ComponentError("ReceiveManager", "SKIP", "JSON config for receiver", name, "does not contain a receiver type")
|
||||||
|
return fmt.Errorf("JSON config for receiver %s does not contain a receiver type", name)
|
||||||
|
}
|
||||||
if _, found := AvailableReceivers[config.Type]; !found {
|
if _, found := AvailableReceivers[config.Type]; !found {
|
||||||
cclog.ComponentError("ReceiveManager", "SKIP", config.Type, "unknown receiver:", err.Error())
|
cclog.ComponentError("ReceiveManager", "SKIP", "unknown receiver type:", config.Type)
|
||||||
return err
|
return fmt.Errorf("unknown receiver type: %s", config.Type)
|
||||||
}
|
}
|
||||||
r, err := AvailableReceivers[config.Type](name, rawConfig)
|
r, err := AvailableReceivers[config.Type](name, rawConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user