fix(keystone): always upload&refresh service config whenever service restart

Always upload&refresh service config whenever service restart
This commit is contained in:
Qiu Jian
2020-12-19 00:49:32 +08:00
parent 0f2913b081
commit 80229fa1e0
3 changed files with 23 additions and 13 deletions
+4 -4
View File
@@ -124,10 +124,10 @@ func (manager *SOptionManager) DoSync(first bool) (time.Duration, error) {
appsrv.SetExitFlag()
}
copyOptions(manager.options, newOpts)
if first {
// upload config for the first time ONLY
manager.session.Upload()
}
// if first {
// upload config
manager.session.Upload()
// }
}
return manager.refreshInterval, nil
}
+11 -4
View File
@@ -66,6 +66,8 @@ type mcclientServiceConfigSession struct {
session *mcclient.ClientSession
serviceId string
config *jsonutils.JSONDict
commonServiceId string
}
func newServiceConfigSession() IServiceConfigSession {
@@ -88,12 +90,12 @@ func (s *mcclientServiceConfigSession) Merge(opts interface{}, serviceType strin
merged = true
} else {
// not initialized
s.Upload()
// s.Upload()
}
}
commonServiceId, _ := getServiceIdByType(s.session, consts.COMMON_SERVICE, "")
if len(commonServiceId) > 0 {
commonConf, err := getServiceConfig(s.session, commonServiceId)
s.commonServiceId, _ = getServiceIdByType(s.session, consts.COMMON_SERVICE, "")
if len(s.commonServiceId) > 0 {
commonConf, err := getServiceConfig(s.session, s.commonServiceId)
if err != nil {
log.Errorf("getServiceConfig for %s failed: %s", consts.COMMON_SERVICE, err)
} else if commonConf != nil {
@@ -123,6 +125,11 @@ func (s *mcclientServiceConfigSession) Upload() {
// ignore the error
log.Errorf("fail to save config: %s", err)
}
_, err = modules.ServicesV3.PerformAction(s.session, s.commonServiceId, "config", nconf)
if err != nil {
// ignore the error
log.Errorf("fail to save common config: %s", err)
}
}
}