From 11dc0d46a2302139a73d725748ae0e6f4cff55ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Wed, 26 Nov 2025 16:57:01 +0800 Subject: [PATCH] fix(region): vendor update (#23844) --- go.mod | 2 +- go.sum | 4 +- pkg/cloudmon/misc/alerts.go | 6 ++ vendor/modules.txt | 2 +- .../pkg/multicloud/volcengine/instance.go | 79 +++++++++++++++++++ 5 files changed, 89 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 16a9eb36a3..c3bbe24102 100644 --- a/go.mod +++ b/go.mod @@ -97,7 +97,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.20251125082612-fe4c7619db15 + yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20251125125826-86ba3f3b2538 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 2731b8a910..e81c9370e4 100644 --- a/go.sum +++ b/go.sum @@ -1672,8 +1672,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.20251125082612-fe4c7619db15 h1:T2C5B/ivpWmc0EpcH0PbUGFoZkq5gNG7erTtJdjyJXo= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20251125082612-fe4c7619db15/go.mod h1:JlmQ8iuGdaAlUkivFVcUAJgi6QYr5jz1vKv7pQ5m7p8= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20251125125826-86ba3f3b2538 h1:EAQ0YtCUwX9tsyEDrSfvQ023YulkFwEGm0NrLPGmc2g= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20251125125826-86ba3f3b2538/go.mod h1:JlmQ8iuGdaAlUkivFVcUAJgi6QYr5jz1vKv7pQ5m7p8= 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/cloudmon/misc/alerts.go b/pkg/cloudmon/misc/alerts.go index 6a5f687655..2fa6f302fc 100644 --- a/pkg/cloudmon/misc/alerts.go +++ b/pkg/cloudmon/misc/alerts.go @@ -50,6 +50,12 @@ func AlertHistoryReport(ctx context.Context, userCred mcclient.TokenCredential, } metrics := []influxdb.SMetricData{} for _, alert := range alerts.Data { + if alert.ResType == "host" && len(alert.DomainId) == 0 { + continue + } + if alert.ResType == "guest" && len(alert.ProjectId) == 0 { + continue + } metric := influxdb.SMetricData{} metric.Name = ALERT_RECORD_HISTORY_MEASUREMENT metric.Timestamp = time.Now() diff --git a/vendor/modules.txt b/vendor/modules.txt index bf13ccbbaf..5ce6c7997a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -2264,7 +2264,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.20251125082612-fe4c7619db15 +# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20251125125826-86ba3f3b2538 ## 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/volcengine/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/volcengine/instance.go index 1f16ae231f..634f3df1fb 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/volcengine/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/volcengine/instance.go @@ -249,6 +249,85 @@ func (instance *SInstance) GetInstanceType() string { return instance.InstanceTypeId } +func (instance *SInstance) SetTags(tags map[string]string, replace bool) error { + _tags, err := instance.GetTags() + if err != nil { + return errors.Wrapf(err, "GetTags") + } + keys, upperKeys := []string{}, []string{} + for k := range tags { + keys = append(keys, k) + upperKeys = append(upperKeys, strings.ToUpper(k)) + } + if replace { + if len(tags) > 0 { + removeKeys := []string{} + for k := range _tags { + if !utils.IsInStringArray(k, keys) { + removeKeys = append(removeKeys, k) + } + } + if len(removeKeys) > 0 { + err := instance.host.zone.region.UntagResources(instance.InstanceId, "instance", removeKeys) + if err != nil { + return errors.Wrapf(err, "UntagResource") + } + } + } + } else { + removeKeys := []string{} + for k := range _tags { + if !utils.IsInStringArray(k, keys) && utils.IsInStringArray(strings.ToUpper(k), upperKeys) { + removeKeys = append(removeKeys, k) + } + } + if len(removeKeys) > 0 { + err := instance.host.zone.region.UntagResources(instance.InstanceId, "instance", removeKeys) + if err != nil { + return errors.Wrapf(err, "UntagResource") + } + } + } + return instance.host.zone.region.TagResources(instance.InstanceId, "instance", tags) +} + +func (region *SRegion) TagResources(resId, resType string, tags map[string]string) error { + params := map[string]string{ + "ResourceIds.1": resId, + "ResourceType": resType, + } + idx := 1 + for k, v := range tags { + params[fmt.Sprintf("Tags.%d.Key", idx)] = k + params[fmt.Sprintf("Tags.%d.Value", idx)] = v + idx++ + } + + _, err := region.ecsRequest("TagResources", params) + if err != nil { + return errors.Wrapf(err, "TagResources") + } + return nil +} + +func (region *SRegion) UntagResources(resId, resType string, tags []string) error { + params := map[string]string{ + "ResourceIds.1": resId, + "ResourceType": resType, + } + idx := 1 + for _, tag := range tags { + params[fmt.Sprintf("TagKeys.%d", idx)] = tag + idx++ + } + + _, err := region.ecsRequest("UntagResources", params) + if err != nil { + return errors.Wrapf(err, "UntagResources") + } + return nil +} + func (instance *SInstance) GetSecurityGroupIds() ([]string, error) { nics, err := instance.host.zone.region.GetNetworkInterfaces("", instance.InstanceId) if err != nil {