mirror of
https://github.com/goharbor/harbor
synced 2024-09-20 17:25:32 +00:00
fix issue7637: /api/systeminfo cannot return 500 when DB is down (#7650)
Signed-off-by: stonezdj <stonezdj@gmail.com>
This commit is contained in:
parent
0988a38e84
commit
86bfd7a733
|
@ -168,7 +168,11 @@ func Upload(cfg map[string]interface{}) error {
|
|||
|
||||
// GetSystemCfg returns the system configurations
|
||||
func GetSystemCfg() (map[string]interface{}, error) {
|
||||
return cfgMgr.GetAll(), nil
|
||||
sysCfg := cfgMgr.GetAll()
|
||||
if len(sysCfg) == 0 {
|
||||
return nil, errors.New("can not load system config, the database might be down")
|
||||
}
|
||||
return sysCfg, nil
|
||||
}
|
||||
|
||||
// AuthMode ...
|
||||
|
@ -176,6 +180,7 @@ func AuthMode() (string, error) {
|
|||
err := cfgMgr.Load()
|
||||
if err != nil {
|
||||
log.Errorf("failed to load config, error %v", err)
|
||||
return "db_auth", err
|
||||
}
|
||||
return cfgMgr.Get(common.AUTHMode).GetString(), nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user