fix(baremetal): rebuild root calculate root disk partitions incorrect

This commit is contained in:
Zexi Li
2021-10-21 01:00:19 +08:00
parent a4be855896
commit 6be9f25d91
3 changed files with 14 additions and 4 deletions
+7
View File
@@ -185,6 +185,7 @@ func (m *SBaremetalManager) CleanBaremetal(bmId string) {
func (m *SBaremetalManager) updateBaremetal(session *mcclient.ClientSession, bmId string) (jsonutils.JSONObject, error) {
params := jsonutils.NewDict()
params.Add(jsonutils.JSONTrue, "is_baremetal")
params.Add(jsonutils.JSONTrue, "not_sync_config")
obj, err := modules.Hosts.Put(session, bmId, params)
if err != nil {
return nil, err
@@ -2658,7 +2659,13 @@ func (s *SBaremetalServer) DoRebuildRootDisk(term *ssh.Client) ([]*disktool.Part
func (s *SBaremetalServer) SyncPartitionSize(term *ssh.Client, parts []*disktool.Partition) ([]jsonutils.JSONObject, error) {
disks, _ := s.desc.GetArray("disks")
// calculate root partitions count
rootPartsCnt := len(parts) - len(disks) + 1
if len(parts) < len(disks) {
// HACK: rebuild root disk
rootPartsCnt = len(parts)
}
rootParts := parts[0:rootPartsCnt]
dataParts := parts[rootPartsCnt:]
idx := 0
+1 -2
View File
@@ -24,14 +24,13 @@ import (
"yunion.io/x/log"
"yunion.io/x/onecloud/pkg/appsrv"
"yunion.io/x/onecloud/pkg/baremetal/options"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var baremetalTaskWorkerMan *appsrv.SWorkerManager
func init() {
baremetalTaskWorkerMan = appsrv.NewWorkerManager("BaremetalTaskWorkerManager", options.Options.TaskWorkerCount, 1024, false)
baremetalTaskWorkerMan = appsrv.NewWorkerManager("BaremetalTaskWorkerManager", 4, 1024, false)
}
func GetWorkManager() *appsrv.SWorkerManager {
+6 -2
View File
@@ -3532,8 +3532,12 @@ func (self *SHost) PostUpdate(ctx context.Context, userCred mcclient.TokenCreden
}
}
if err := self.startSyncConfig(ctx, userCred, "", true); err != nil {
log.Errorf("start sync host %q config after updated", self.GetName())
notSyncConf, _ := data.Bool("not_sync_config")
if !notSyncConf {
if err := self.startSyncConfig(ctx, userCred, "", true); err != nil {
log.Errorf("start sync host %q config after updated", self.GetName())
}
}
}