mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
fix(region): disable sync schedtags (#23943)
This commit is contained in:
@@ -486,7 +486,7 @@ func (drv *SManagedVirtualizedGuestDriver) RequestStartOnHost(ctx context.Contex
|
||||
result := jsonutils.NewDict()
|
||||
if ivm.GetStatus() != api.VM_RUNNING {
|
||||
|
||||
if guest.BillingType == billing_api.BILLING_TYPE_POSTPAID && jsonutils.QueryBoolean(task.GetParams(), "auto_prepaid", false) {
|
||||
if guest.BillingType == billing_api.BILLING_TYPE_POSTPAID && guest.ShutdownMode != api.VM_SHUTDOWN_MODE_STOP_CHARGING && jsonutils.QueryBoolean(task.GetParams(), "auto_prepaid", false) {
|
||||
err = ivm.ChangeBillingType(billing_api.BILLING_TYPE_PREPAID)
|
||||
if err != nil && errors.Cause(err) != cloudprovider.ErrNotImplemented {
|
||||
logclient.AddSimpleActionLog(guest, logclient.ACT_CHANGE_BILLING_TYPE, errors.Wrapf(err, billing_api.BILLING_TYPE_PREPAID), userCred, false)
|
||||
@@ -501,6 +501,14 @@ func (drv *SManagedVirtualizedGuestDriver) RequestStartOnHost(ctx context.Contex
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "Wait vm running")
|
||||
}
|
||||
|
||||
if guest.BillingType == billing_api.BILLING_TYPE_POSTPAID && guest.ShutdownMode == api.VM_SHUTDOWN_MODE_STOP_CHARGING && jsonutils.QueryBoolean(task.GetParams(), "auto_prepaid", false) {
|
||||
err := ivm.ChangeBillingType(billing_api.BILLING_TYPE_PREPAID)
|
||||
if err != nil && errors.Cause(err) != cloudprovider.ErrNotImplemented {
|
||||
logclient.AddSimpleActionLog(guest, logclient.ACT_CHANGE_BILLING_TYPE, errors.Wrapf(err, billing_api.BILLING_TYPE_PREPAID), userCred, false)
|
||||
}
|
||||
}
|
||||
|
||||
// 虚拟机开机,公网ip自动生成
|
||||
guest.SyncAllWithCloudVM(ctx, userCred, host, ivm, true)
|
||||
return task.ScheduleRun(result)
|
||||
|
||||
@@ -2333,9 +2333,11 @@ func (hh *SHost) syncWithCloudHost(ctx context.Context, userCred mcclient.TokenC
|
||||
syncMetadata(ctx, userCred, hh, extHost, account.ReadOnly)
|
||||
}
|
||||
|
||||
err = hh.syncSchedtags(ctx, userCred, extHost)
|
||||
if err != nil && errors.Cause(err) != cloudprovider.ErrNotFound && errors.Cause(err) != errors.ErrNotImplemented {
|
||||
log.Errorf("syncSchedtags for %s fail: %v", hh.Name, err)
|
||||
if !options.Options.DisableSyncSchedtags {
|
||||
err = hh.syncSchedtags(ctx, userCred, extHost)
|
||||
if err != nil && errors.Cause(err) != cloudprovider.ErrNotFound && errors.Cause(err) != errors.ErrNotImplemented {
|
||||
log.Errorf("syncSchedtags for %s fail: %v", hh.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(diff) > 0 {
|
||||
|
||||
@@ -172,6 +172,8 @@ type ComputeOptions struct {
|
||||
AutoReconcileBackupServers bool `help:"auto reconcile backup servers" default:"false"`
|
||||
SetKVMServerAsDaemonOnCreate bool `help:"set kvm guest as daemon server on create" default:"false"`
|
||||
|
||||
DisableSyncSchedtags bool `help:"disable sync schedtags" default:"false"`
|
||||
|
||||
SCapabilityOptions
|
||||
SASControllerOptions
|
||||
common_options.CommonOptions
|
||||
|
||||
Reference in New Issue
Block a user