mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
* fix(region,host): host register with correct hostname * fix(region): guest migrate reuse create params schedtag
This commit is contained in:
@@ -542,7 +542,7 @@ func (self *SGuest) PerformMigrateForecast(ctx context.Context, userCred mcclien
|
||||
}
|
||||
}
|
||||
|
||||
schedParams := self.GetSchedMigrateParams(userCred, input)
|
||||
schedParams := self.GetSchedMigrateParams(ctx, userCred, input)
|
||||
if input.ConvertToKvm {
|
||||
schedParams.Hypervisor = api.HYPERVISOR_KVM
|
||||
}
|
||||
@@ -557,12 +557,19 @@ func (self *SGuest) PerformMigrateForecast(ctx context.Context, userCred mcclien
|
||||
}
|
||||
|
||||
func (self *SGuest) GetSchedMigrateParams(
|
||||
userCred mcclient.TokenCredential,
|
||||
ctx context.Context, userCred mcclient.TokenCredential,
|
||||
input *api.ServerMigrateForecastInput,
|
||||
) *schedapi.ScheduleInput {
|
||||
schedDesc := self.ToSchedDesc()
|
||||
if input.PreferHostId != "" {
|
||||
schedDesc.ServerConfig.PreferHost = input.PreferHostId
|
||||
} else {
|
||||
createParams, err := self.GetCreateParams(ctx, userCred)
|
||||
if err != nil {
|
||||
log.Errorf("GetSchedMigrateParams failed get create params: %s", err)
|
||||
} else {
|
||||
schedDesc.Schedtags = createParams.Schedtags
|
||||
}
|
||||
}
|
||||
|
||||
schedDesc.ResetCpuNumaPin = input.ResetCpuNumaPin
|
||||
|
||||
@@ -7402,6 +7402,10 @@ func (host *SHost) RemoteHealthStatus(ctx context.Context) string {
|
||||
}
|
||||
|
||||
func (host *SHost) GetHostnameByName() string {
|
||||
if host.Hostname != "" {
|
||||
return host.Hostname
|
||||
}
|
||||
|
||||
hostname := host.Name
|
||||
accessIp := strings.Replace(host.AccessIp, ".", "-", -1)
|
||||
if strings.HasSuffix(host.Name, "-"+accessIp) {
|
||||
|
||||
@@ -89,7 +89,7 @@ func (task *GuestMigrateTask) GetSchedParams() (*schedapi.ScheduleInput, error)
|
||||
input.SkipCpuCheck = skipCpuCheck
|
||||
input.SkipKernelCheck = skipKernelCheck
|
||||
}
|
||||
res := guest.GetSchedMigrateParams(task.GetUserCred(), input)
|
||||
res := guest.GetSchedMigrateParams(context.Background(), task.GetUserCred(), input)
|
||||
|
||||
if devs, _ := guest.GetGuestIsolatedDevices(); len(devs) > 0 {
|
||||
preferNumaNodesSet := cpuset.NewBuilder()
|
||||
|
||||
@@ -1568,12 +1568,13 @@ func (h *SHostInfo) ProbeSyncIsolatedDevices(hostId string, body jsonutils.JSONO
|
||||
return h.probeSyncIsolatedDevices()
|
||||
}
|
||||
|
||||
func (h *SHostInfo) setHostname(name string) {
|
||||
h.FullName = name
|
||||
err := sysutils.SetHostname(name)
|
||||
func (h *SHostInfo) fetchOsHostname() string {
|
||||
hn, err := os.Hostname()
|
||||
if err != nil {
|
||||
log.Errorf("Fail to set system hostname: %s", err)
|
||||
log.Fatalf("fail to get hostname %s", err)
|
||||
return ""
|
||||
}
|
||||
return hn
|
||||
}
|
||||
|
||||
func (h *SHostInfo) fetchHostname() string {
|
||||
@@ -1621,6 +1622,7 @@ func (h *SHostInfo) updateOrCreateHost(hostId string) (*api.HostDetails, error)
|
||||
if len(hostId) == 0 {
|
||||
input.GenerateName = h.fetchHostname()
|
||||
}
|
||||
input.Hostname = h.fetchOsHostname()
|
||||
input.AccessIp = masterIp
|
||||
input.AccessMac = h.GetMasterMac()
|
||||
var schema = "http"
|
||||
|
||||
Reference in New Issue
Block a user