diff --git a/go.mod b/go.mod index bdcb218d13..c0e0846e95 100644 --- a/go.mod +++ b/go.mod @@ -99,7 +99,7 @@ require ( k8s.io/cri-api v0.28.15 k8s.io/klog/v2 v2.20.0 moul.io/http2curl/v2 v2.3.0 - yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260114022903-82083aed488f + yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260115031205-22d194eacc4c yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0 yunion.io/x/jsonutils v1.0.1-0.20250507052344-1abcf4f443b1 yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91 diff --git a/go.sum b/go.sum index 10e68efc72..f4a852d5b7 100644 --- a/go.sum +++ b/go.sum @@ -1661,8 +1661,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260114022903-82083aed488f h1:PcUdyuYbCqUNnGgUIwtXubVnP7k9NqlnyZd14Sw1ePE= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260114022903-82083aed488f/go.mod h1:aWRX5Phwz3nbHUNnIAm1oVogjguXPYDDgCOy/9Hnnvk= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260115031205-22d194eacc4c h1:hQ0NR7Zjwedj/46E1MstfF9TZYRRJikAgbDtzpvTBl4= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260115031205-22d194eacc4c/go.mod h1:aWRX5Phwz3nbHUNnIAm1oVogjguXPYDDgCOy/9Hnnvk= yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0 h1:msG4SiDSVU7CrXH06WuHlNEZXIooTcmNbfrIGHuIHBU= yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws= yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634= diff --git a/pkg/apis/notify/event.go b/pkg/apis/notify/event.go index b4ef8ab204..e88712899b 100644 --- a/pkg/apis/notify/event.go +++ b/pkg/apis/notify/event.go @@ -22,55 +22,95 @@ import ( var ( Event SNotifyEvent - ActionCreate SAction = "create" - ActionDelete SAction = "delete" - ActionPendingDelete SAction = "pending_delete" - ActionUpdate SAction = "update" - ActionRebuildRoot SAction = "rebuild_root" - ActionResetPassword SAction = "reset_password" - ActionChangeConfig SAction = "change_config" - ActionResize SAction = "resize" + // 创建 + ActionCreate SAction = "create" + // 删除 + ActionDelete SAction = "delete" + // 放入回收站 + ActionPendingDelete SAction = "pending_delete" + // 更新 + ActionUpdate SAction = "update" + // 重装系统 + ActionRebuildRoot SAction = "rebuild_root" + // 重置密码 + ActionResetPassword SAction = "reset_password" + // 配置变更 + ActionChangeConfig SAction = "change_config" + // 扩容 + ActionResize SAction = "resize" + // 到期释放 ActionExpiredRelease SAction = "expired_release" - ActionExecute SAction = "execute" - ActionChangeIpaddr SAction = "change_ipaddr" - ActionSyncStatus SAction = "sync_status" - ActionCleanData SAction = "clean_data" - ActionMigrate SAction = "migrate" + // 执行,例如自动快照策略执行创建快照、弹性伸缩策略执行扩容、定时任务执行等 + ActionExecute SAction = "execute" + // IP变更 + ActionChangeIpaddr SAction = "change_ipaddr" + // 同步状态 + ActionSyncStatus SAction = "sync_status" + // 清理数据 + ActionCleanData SAction = "clean_data" + // 迁移 + ActionMigrate SAction = "migrate" + // 添加备份服务器 ActionCreateBackupServer SAction = "add_backup_server" - ActionDelBackupServer SAction = "delete_backup_server" + // 删除备份服务器 + ActionDelBackupServer SAction = "delete_backup_server" - ActionSyncCreate SAction = "sync_create" - ActionSyncUpdate SAction = "sync_update" - ActionSyncDelete SAction = "sync_delete" + // 同步新建 + ActionSyncCreate SAction = "sync_create" + // 同步更新 + ActionSyncUpdate SAction = "sync_update" + // 同步删除 + ActionSyncDelete SAction = "sync_delete" + // 同步账号状态 ActionSyncAccountStatus SAction = "sync_account_status" - ActionOffline SAction = "offline" - ActionSystemPanic SAction = "panic" + // 下线 + ActionOffline SAction = "offline" + // 系统崩溃 + ActionSystemPanic SAction = "panic" + // 系统异常 ActionSystemException SAction = "exception" - - ActionChecksumTest SAction = "checksum_test" - + // 锁定,例如用户锁定 ActionLock SAction = "lock" - - ActionExceedCount SAction = "exceed_count" - ActionPasswordExpireSoon SAction = "password_expire_soon" - ActionWorkerBlock SAction = "woker_block" - ActionNetOutOfSync SAction = "net_out_of_sync" - ActionMysqlOutOfSync SAction = "mysql_out_of_sync" - ActionServiceAbnormal SAction = "service_abnormal" - ActionServerPanicked SAction = "server_panicked" - ActionAttach SAction = "attach" - ActionDetach SAction = "detach" + // 超出数量 + ActionExceedCount SAction = "exceed_count" + // 密码即将过期 + ActionPasswordExpireSoon SAction = "password_expire_soon" + // 一致性检查 + ActionChecksumTest SAction = "checksum_test" + // 任务队列阻塞 + ActionWorkerBlock SAction = "woker_block" + // 网络同步失败 + ActionNetOutOfSync SAction = "net_out_of_sync" + // MySQL同步失败 + ActionMysqlOutOfSync SAction = "mysql_out_of_sync" + // 服务异常 + ActionServiceAbnormal SAction = "service_abnormal" + // 服务器崩溃 + ActionServerPanicked SAction = "server_panicked" + // 挂载 + ActionAttach SAction = "attach" + // 卸载 + ActionDetach SAction = "detach" + // 透传设备创建 ActionIsolatedDeviceCreate SAction = "isolated_device_create" + // 透传设备更新 ActionIsolatedDeviceUpdate SAction = "isolated_device_update" + // 透传设备删除 ActionIsolatedDeviceDelete SAction = "isolated_device_delete" - ActionStatusChanged SAction = "status_changed" - ActionStart SAction = "start" - ActionStop SAction = "stop" - ActionReset SAction = "reset" - ActionRestart SAction = "restart" - ActionRunTask SAction = "run_task" + // 状态变更 + ActionStatusChanged SAction = "status_changed" + // 启动 + ActionStart SAction = "start" + // 停止 + ActionStop SAction = "stop" + // 重置 + ActionReset SAction = "reset" + // 重启 + ActionRestart SAction = "restart" + // 运行任务 + ActionRunTask SAction = "run_task" ResultFailed SResult = "failed" ResultSucceed SResult = "succeed" diff --git a/vendor/modules.txt b/vendor/modules.txt index c061e7bd4c..208b3426b0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -2243,7 +2243,7 @@ sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.2.0 ## explicit; go 1.12 sigs.k8s.io/yaml -# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260114022903-82083aed488f +# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260115031205-22d194eacc4c ## explicit; go 1.24 yunion.io/x/cloudmux/pkg/apis yunion.io/x/cloudmux/pkg/apis/billing diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ksyun/eip.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ksyun/eip.go index 444c599c41..ec5da68279 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ksyun/eip.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ksyun/eip.go @@ -20,6 +20,7 @@ import ( "time" "yunion.io/x/jsonutils" + "yunion.io/x/log" "yunion.io/x/pkg/errors" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" @@ -120,6 +121,10 @@ func (eip *SEip) GetTags() (map[string]string, error) { return tags.GetTags(), nil } +func (eip *SEip) SetTags(tags map[string]string, replace bool) error { + return eip.region.SetResourceTags("eip", eip.AllocationId, tags, replace) +} + func (eip *SEip) GetStatus() string { switch eip.State { case "associate": @@ -265,23 +270,45 @@ func (region *SRegion) CreateEip(opts *cloudprovider.SEip) (*SEip, error) { return nil, errors.Wrap(errors.ErrNotFound, "No bgp lines found") } params := map[string]interface{}{ - "LineId": lineId, - "BandWidth": fmt.Sprintf("%d", opts.BandwidthMbps), - "ChargeType": "TrafficMonthly", - } - if opts.ChargeType == api.EIP_CHARGE_TYPE_BY_BANDWIDTH { - params["ChargeType"] = "Monthlys" - params["PurchaseTime"] = "1" + "LineId": lineId, + "BandWidth": fmt.Sprintf("%d", opts.BandwidthMbps), } - body, err := region.eipRequest("AllocateAddress", params) + chargeTypes := []string{} + if opts.ChargeType == api.EIP_CHARGE_TYPE_BY_BANDWIDTH { + chargeTypes = append(chargeTypes, "Monthly") + params["PurchaseTime"] = "1" + } else { + chargeTypes = append(chargeTypes, "TrafficMonthly") + chargeTypes = append(chargeTypes, "DailyPaidByTransfer") + } + + ret := &SEip{region: region} + var body jsonutils.JSONObject + for _, chargeType := range chargeTypes { + params["ChargeType"] = chargeType + body, err = region.eipRequest("AllocateAddress", params) + if err != nil { + log.Debugf("not support charge type %s, error: %v", chargeType, err) + if e, ok := err.(*sKsyunError); ok && e.ErrorMsg.Code == "PackageNotExists" { + continue + } + return nil, errors.Wrap(err, "AllocateAddress") + } + err = body.Unmarshal(ret) + if err != nil { + return nil, errors.Wrap(err, "Unmarshal") + } + } if err != nil { return nil, errors.Wrap(err, "AllocateAddress") } - ret := &SEip{region: region} - err = body.Unmarshal(ret) - if err != nil { - return nil, errors.Wrap(err, "Unmarshal") + + if len(opts.Tags) > 0 { + err = region.CreateTags("eip", ret.AllocationId, opts.Tags) + if err != nil { + log.Errorf("set tags %s to eip %s failed: %v", opts.Tags, ret.AllocationId, err) + } } return ret, nil }