fix(region): disable sync schedtags (#23943)

This commit is contained in:
屈轩
2025-12-16 20:41:02 +08:00
committed by GitHub
parent 73076cfc19
commit c6f3e714ee
3 changed files with 16 additions and 4 deletions
+9 -1
View File
@@ -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)
+5 -3
View File
@@ -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 {
+2
View File
@@ -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