From 27cd73a76268deb5186c5cad0d80fa72454ede6e Mon Sep 17 00:00:00 2001 From: dove0012 Date: Sat, 11 Oct 2025 15:09:34 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=B0=B7=E6=AD=8C=E4=BA=91=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E8=8A=82=E7=82=B9=E7=9A=84=E6=97=B6=E5=80=99=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=88=A0=E9=99=A4cmdb=E6=95=B0=E6=8D=AE=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bcs-services/bcs-cluster-manager/go.mod | 260 -------------- .../internal/cloudprovider/common/module.go | 251 +++++++++++++ .../internal/cloudprovider/common/task.go | 1 + .../internal/cloudprovider/google/taskmgr.go | 5 +- .../internal/cloudprovider/utils.go | 2 + .../internal/remote/cmdb/client.go | 333 ++++++++++++++++++ .../internal/remote/cmdb/types.go | 246 +++++++++++++ 7 files changed, 837 insertions(+), 261 deletions(-) delete mode 100644 bcs-services/bcs-cluster-manager/go.mod diff --git a/bcs-services/bcs-cluster-manager/go.mod b/bcs-services/bcs-cluster-manager/go.mod deleted file mode 100644 index 0b007f1e59..0000000000 --- a/bcs-services/bcs-cluster-manager/go.mod +++ /dev/null @@ -1,260 +0,0 @@ -module github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager - -go 1.21 - -replace ( - k8s.io/api => k8s.io/api v0.26.1 - k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.26.1 - k8s.io/apimachinery => k8s.io/apimachinery v0.26.1 - k8s.io/client-go => k8s.io/client-go v0.26.1 - k8s.io/kubectl => k8s.io/kubectl v0.26.1 -) - -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork v1.1.0 - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions v1.3.0 - github.com/GehirnInc/crypt v0.0.0-20230320061759-8cc1b52080c5 - github.com/RichardKnop/machinery/v2 v2.0.11 - github.com/Tencent/bk-bcs/bcs-common v0.0.0-20250521083331-e37404b7dd2a - github.com/Tencent/bk-bcs/bcs-common/common/encryptv2 v0.0.0-20230908045126-c9d09981a9c5 - github.com/Tencent/bk-bcs/bcs-services/pkg v0.0.0-20250728085520-0a1d3fa13c6b - github.com/apparentlymart/go-cidr v1.1.0 - github.com/avast/retry-go v2.7.0+incompatible - github.com/aws/aws-sdk-go v1.55.5 - github.com/envoyproxy/protoc-gen-validate v1.0.4 - github.com/ghodss/yaml v1.0.0 - github.com/go-micro/plugins/v4/registry/etcd v1.1.0 - github.com/go-micro/plugins/v4/server/grpc v1.2.0 - github.com/golang/glog v1.2.0 - github.com/golang/protobuf v1.5.4 - github.com/google/uuid v1.6.0 - github.com/gorilla/mux v1.8.0 - github.com/gorilla/websocket v1.4.2 - github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.154 - github.com/kirito41dd/xslice v0.0.1 - github.com/leodido/go-urn v1.4.0 // indirect - github.com/parnurzeal/gorequest v0.2.16 - github.com/patrickmn/go-cache v2.1.0+incompatible - github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.19.0 - github.com/robfig/cron/v3 v3.0.1 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.398 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.1.13 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.376 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tag v1.0.768 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1133 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.714 - go-micro.dev/v4 v4.9.0 - go.etcd.io/etcd/client/v3 v3.5.5 - go.mongodb.org/mongo-driver v1.13.1 - golang.org/x/oauth2 v0.18.0 - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d - google.golang.org/api v0.155.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 - google.golang.org/grpc v1.62.1 - google.golang.org/protobuf v1.33.0 - gopkg.in/go-playground/validator.v9 v9.31.0 - gopkg.in/yaml.v2 v2.4.0 - gorm.io/driver/mysql v1.5.6 - gorm.io/gorm v1.25.9 - k8s.io/api v0.26.1 - k8s.io/apiextensions-apiserver v0.23.1 - k8s.io/apimachinery v0.26.1 - k8s.io/client-go v11.0.0+incompatible - k8s.io/kubectl v0.0.0-00010101000000-000000000000 - sigs.k8s.io/aws-iam-authenticator v0.6.17 -) - -require github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.1052 - -require ( - github.com/Azure/azure-sdk-for-go/profile/p20200901 v0.1.1 - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v3 v3.0.0 - github.com/emicklei/go-restful/v3 v3.9.0 -) - -require ( - cloud.google.com/go v0.112.0 // indirect - cloud.google.com/go/compute v1.23.3 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.1.5 // indirect - cloud.google.com/go/pubsub v1.34.0 // indirect - dario.cat/mergo v1.0.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect - github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect - github.com/MakeNowJust/heredoc v1.0.0 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v1.1.3 // indirect - github.com/RichardKnop/logging v0.0.0-20190827224416-1a693bdd4fae // indirect - github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/kubernetes/common v0.0.0-20220330120237-0bbed74dcf6d // indirect - github.com/TencentBlueKing/bk-audit-go-sdk v0.0.6 // indirect - github.com/TencentBlueKing/crypto-golang-sdk v1.0.0 // indirect - github.com/TencentBlueKing/gopkg v1.1.0 // indirect - github.com/TencentBlueKing/iam-go-sdk v0.1.6 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/bitly/go-simplejson v0.5.0 // indirect - github.com/cenkalti/backoff/v4 v4.2.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/chai2010/gettext-go v1.0.2 // indirect - github.com/cloudflare/circl v1.3.7 // indirect - github.com/coreos/go-semver v0.3.0 // indirect - github.com/coreos/go-systemd/v22 v22.3.2 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect - github.com/cyphar/filepath-securejoin v0.2.5 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dustin/go-humanize v1.0.0 // indirect - github.com/emirpasic/gods v1.18.1 // indirect - github.com/evanphx/json-patch v4.12.0+incompatible // indirect - github.com/evanphx/json-patch/v5 v5.5.0 // indirect - github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.3 // indirect - github.com/go-acme/lego/v4 v4.4.0 // indirect - github.com/go-errors/errors v1.0.1 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.6.0 // indirect - github.com/go-git/go-git/v5 v5.13.0 // indirect - github.com/go-logr/logr v1.4.1 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-openapi/jsonpointer v0.19.5 // indirect - github.com/go-openapi/jsonreference v0.20.0 // indirect - github.com/go-openapi/swag v0.19.14 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.19.0 // indirect - github.com/go-resty/resty/v2 v2.12.0 // indirect - github.com/go-sql-driver/mysql v1.7.1 // indirect - github.com/gobwas/httphead v0.1.0 // indirect - github.com/gobwas/pool v0.2.1 // indirect - github.com/gobwas/ws v1.0.4 // indirect - github.com/gofrs/flock v0.8.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/golang-jwt/jwt/v5 v5.0.0 // indirect - github.com/golang-migrate/migrate/v4 v4.17.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/snappy v0.0.4 // indirect - github.com/gomodule/redigo v2.0.0+incompatible // indirect - github.com/google/btree v1.0.1 // indirect - github.com/google/gnostic v0.5.7-v3refs // indirect - github.com/google/go-cmp v0.6.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/s2a-go v0.1.7 // indirect - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect - github.com/googleapis/gax-go/v2 v2.12.0 // indirect - github.com/gorilla/handlers v1.5.1 // indirect - github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/imdario/mergo v0.3.13 // indirect - github.com/inconshreveable/mousetrap v1.0.1 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/jinzhu/inflection v1.0.0 // indirect - github.com/jinzhu/now v1.1.5 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/juju/ratelimit v1.0.1 // indirect - github.com/kelseyhightower/envconfig v1.4.0 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.15.11 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect - github.com/mailru/easyjson v0.7.6 // indirect - github.com/mattbaird/jsonpatch v0.0.0-20200820163806-098863c1fc24 // indirect - github.com/miekg/dns v1.1.50 // indirect - github.com/mitchellh/go-wordwrap v1.0.0 // indirect - github.com/mitchellh/hashstructure v1.1.0 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/moby/spdystream v0.2.0 // indirect - github.com/moby/term v0.5.0 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect - github.com/montanaflynn/stats v0.7.0 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect - github.com/nxadm/tail v1.4.8 // indirect - github.com/opentracing/opentracing-go v1.2.0 // indirect - github.com/openzipkin/zipkin-go v0.3.0 // indirect - github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect - github.com/peterbourgon/diskv v2.0.1+incompatible // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - github.com/prometheus/client_model v0.5.0 // indirect - github.com/prometheus/common v0.48.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect - github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414 // indirect - github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect - github.com/skeema/knownhosts v1.3.0 // indirect - github.com/spf13/cobra v1.6.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/streadway/amqp v1.0.0 // indirect - github.com/tjfoc/gmsm v1.4.1 // indirect - github.com/ugorji/go/codec v1.2.11 // indirect - github.com/urfave/cli/v2 v2.3.0 // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/xdg-go/pbkdf2 v1.0.0 // indirect - github.com/xdg-go/scram v1.1.2 // indirect - github.com/xdg-go/stringprep v1.0.4 // indirect - github.com/xlab/treeprint v1.1.0 // indirect - github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect - go.etcd.io/etcd/api/v3 v3.5.5 // indirect - go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect - go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect - go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/exporters/jaeger v1.3.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.17.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.17.0 // indirect - go.opentelemetry.io/otel/exporters/zipkin v1.3.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/sdk v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect - go.opentelemetry.io/proto/otlp v1.0.0 // indirect - go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect - go.uber.org/atomic v1.7.0 // indirect - go.uber.org/multierr v1.6.0 // indirect - go.uber.org/zap v1.19.0 // indirect - golang.org/x/crypto v0.31.0 // indirect - golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.33.0 // indirect - golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.28.0 // indirect - golang.org/x/term v0.27.0 // indirect - golang.org/x/text v0.21.0 // indirect - golang.org/x/time v0.5.0 // indirect - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect - gopkg.in/go-playground/assert.v1 v1.2.1 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/cli-runtime v0.26.1 // indirect - k8s.io/component-base v0.26.1 // indirect - k8s.io/klog v1.0.0 // indirect - k8s.io/klog/v2 v2.100.1 // indirect - k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect - k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect - moul.io/http2curl v1.0.0 // indirect - sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect - sigs.k8s.io/kustomize/api v0.12.1 // indirect - sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect -) diff --git a/bcs-services/bcs-cluster-manager/internal/cloudprovider/common/module.go b/bcs-services/bcs-cluster-manager/internal/cloudprovider/common/module.go index 488223f9c9..39452ddc54 100644 --- a/bcs-services/bcs-cluster-manager/internal/cloudprovider/common/module.go +++ b/bcs-services/bcs-cluster-manager/internal/cloudprovider/common/module.go @@ -43,6 +43,12 @@ var ( StepName: "转移主机模块", } + // removeDataFromCmdbStep remove data from cmdb step + removeDataFromCmdbStep = cloudprovider.StepInfo{ + StepMethod: cloudprovider.RemoveDataFromCmdbAction, + StepName: "移除主机数据", + } + // removeHostFromCmdbStep remove host from cmdb step removeHostFromCmdbStep = cloudprovider.StepInfo{ StepMethod: cloudprovider.RemoveHostFromCmdbAction, @@ -68,6 +74,18 @@ func BuildTransferHostModuleStep(task *proto.Task, businessID string, moduleID s task.StepSequence = append(task.StepSequence, transferHostModuleStep.StepMethod) } +// BuildRemoveCmdbDataStep build common remove data from cmdb step +func BuildRemoveCmdbDataStep(task *proto.Task, bizID string, clusterID string, nodeNames []string) { + removeStep := cloudprovider.InitTaskStep(removeDataFromCmdbStep, cloudprovider.WithStepSkipFailed(true)) + + removeStep.Params[cloudprovider.BKBizIDKey.String()] = bizID + removeStep.Params[cloudprovider.ClusterIDKey.String()] = clusterID + removeStep.Params[cloudprovider.NodeNamesKey.String()] = strings.Join(nodeNames, ",") + + task.Steps[removeDataFromCmdbStep.StepMethod] = removeStep + task.StepSequence = append(task.StepSequence, removeDataFromCmdbStep.StepMethod) +} + // BuildRemoveHostStep build common remove host from cmdb step func BuildRemoveHostStep(task *proto.Task, bizID string, nodeIPs []string) { removeStep := cloudprovider.InitTaskStep(removeHostFromCmdbStep, cloudprovider.WithStepSkipFailed(true)) @@ -717,3 +735,236 @@ func handleNotInCmdbNodeIps(ctx context.Context, notInCmdbIps []HostInfo) error return nil } + +// RemoveDataFromCMDBTask remove data from cmdb task +func RemoveDataFromCMDBTask(taskID string, stepName string) error { // nolint + cloudprovider.GetStorageModel().CreateTaskStepLogInfo(context.Background(), taskID, stepName, + "remove cmdb data from cmdb") + start := time.Now() + // get task information and validate + state, step, err := cloudprovider.GetTaskStateAndCurrentStep(taskID, stepName) + if err != nil { + return err + } + if step == nil { + return nil + } + + // get bkBizID + bkBizIDString := step.Params[cloudprovider.BKBizIDKey.String()] + // get nodeIPs + clusterID := step.Params[cloudprovider.ClusterIDKey.String()] + nodeNamesString := step.Params[cloudprovider.NodeNamesKey.String()] + + nodeNames := strings.Split(nodeNamesString, ",") + if len(nodeNames) == 0 { + blog.Errorf("RemoveDataFromCMDBTask %s failed, nodeNames empty", taskID) + _ = state.SkipFailure(start, stepName, fmt.Errorf("nodeNames empty")) + return nil + } + + bkBizID, err := strconv.ParseInt(bkBizIDString, 10, 64) + if err != nil { + blog.Errorf("RemoveDataFromCMDBTask %s failed, invalid bkBizID, err %s", taskID, err.Error()) + _ = state.SkipFailure(start, stepName, fmt.Errorf("invalid bkBizID, err %s", err.Error())) + return nil + } + + bkNodeIDs := make([]int64, 0) + err = retry.Do(func() error { + var errLocal error + if bkNodeIDs, errLocal = getAllNodeID(bkBizID, clusterID, nodeNames); errLocal != nil { + return errLocal + } + + return nil + }, retry.Attempts(3), retry.DelayType(retry.FixedDelay), retry.Delay(time.Millisecond*500)) + if err != nil { + cloudprovider.GetStorageModel().CreateTaskStepLogError(context.Background(), taskID, stepName, + fmt.Sprintf("getAllNodeID failed [%s]", err)) + blog.Errorf("RemoveDataFromCMDBTask[%s] failed: %v", taskID, err) + _ = state.SkipFailure(start, stepName, err) + return nil + } + + if len(bkNodeIDs) > 0 { + err = retry.Do(func() error { + if errLocal := deleteAll2IDPod(bkBizID, bkNodeIDs); errLocal != nil { + return errLocal + } + + return nil + }, retry.Attempts(3), retry.DelayType(retry.FixedDelay), retry.Delay(time.Millisecond*500)) + if err != nil { + cloudprovider.GetStorageModel().CreateTaskStepLogError(context.Background(), taskID, stepName, + fmt.Sprintf("deleteAll2IDPod failed [%s]", err)) + blog.Errorf("RemoveDataFromCMDBTask[%s] failed: %v", taskID, err) + _ = state.SkipFailure(start, stepName, err) + return nil + } + + err = retry.Do(func() error { + if errLocal := deleteAll2IDIDNode(bkBizID, bkNodeIDs); errLocal != nil { + return errLocal + } + + return nil + }, retry.Attempts(3), retry.DelayType(retry.FixedDelay), retry.Delay(time.Millisecond*500)) + if err != nil { + cloudprovider.GetStorageModel().CreateTaskStepLogError(context.Background(), taskID, stepName, + fmt.Sprintf("deleteAll2IDIDNode failed [%s]", err)) + blog.Errorf("RemoveDataFromCMDBTask[%s] failed: %v", taskID, err) + _ = state.SkipFailure(start, stepName, err) + return nil + } + } + + blog.Infof("RemoveDataFromCMDBTask %s successful", taskID) + + cloudprovider.GetStorageModel().CreateTaskStepLogInfo(context.Background(), taskID, stepName, + "remove cmdb data from cmdb successful") + + // update step + _ = state.UpdateStepSucc(start, stepName) + + return nil +} + +func deleteAll2IDPod(bkBizID int64, bkNodeID []int64) error { + blog.Info("start delete all pod") + + cmdbClient := cmdb.GetCmdbClient() + if cmdbClient == nil { + return fmt.Errorf("cmdb client is not init") + } + + for { + got, err := cmdbClient.GetBcsPod(&cmdb.GetBcsPodReq{ + BKBizID: bkBizID, + Fields: []string{"id"}, + Page: cmdb.Page{ + Start: 0, + Limit: 200, + }, + Filter: &cmdb.HostPropertyFilter{ + Condition: "AND", + Rules: []cmdb.Rule{ + { + Field: "bk_node_id", + Operator: "in", + Value: bkNodeID, + }, + }, + }, + }) + if err != nil { + return err + } + + podToDelete := make([]int64, 0) + for _, pod := range *got { + podToDelete = append(podToDelete, pod.ID) + } + + if len(podToDelete) == 0 { + break + } + + blog.Info("delete pod %v", podToDelete) + err = cmdbClient.DeleteBcsPod(&cmdb.DeleteBcsPodReq{ + Data: &[]cmdb.DeleteBcsPodReqData{ + { + BKBizID: &bkBizID, + IDs: &podToDelete, + }, + }, + }) + if err != nil { + blog.Errorf("DeleteBcsPod err: %v", err) + return err + } + } + + blog.Info("delete all pod success") + + return nil +} + +func deleteAll2IDIDNode(bkBizID int64, bkNodeID []int64) error { + blog.Info("start delete all node") + + cmdbClient := cmdb.GetCmdbClient() + if cmdbClient == nil { + return fmt.Errorf("cmdb client is not init") + } + + blog.Infof("delete node: %v", bkNodeID) + err := cmdbClient.DeleteBcsNode(&cmdb.DeleteBcsNodeReq{ + BKBizID: &bkBizID, + IDs: &bkNodeID, + }) + if err != nil { + blog.Errorf("DeleteBcsNode err: %v", err) + return err + } + + blog.Info("delete all node success") + + return nil +} + +func getAllNodeID(bkBizID int64, bcsClusterID string, bcsNodeNames []string) ([]int64, error) { + blog.Info("start get all node ID") + + cmdbClient := cmdb.GetCmdbClient() + if cmdbClient == nil { + return nil, fmt.Errorf("cmdb client is not init") + } + + start := 0 + limit := 100 + nodeIDs := make([]int64, 0) + for { + got, err := cmdbClient.GetBcsNode(&cmdb.GetBcsNodeReq{ + BKBizID: bkBizID, + Page: cmdb.Page{ + Limit: limit, + Start: start, + }, + Filter: &cmdb.HostPropertyFilter{ + Condition: "AND", + Rules: []cmdb.Rule{ + { + Field: "cluster_uid", + Operator: "in", + Value: []string{bcsClusterID}, + }, + { + Field: "name", + Operator: "in", + Value: bcsNodeNames, + }, + }, + }, + }) + if err != nil { + blog.Errorf("GetBcsNode err: %v", err) + return nil, err + } + nodeToDelete := make([]int64, 0) + for _, node := range *got { + nodeToDelete = append(nodeToDelete, node.ID) + nodeIDs = append(nodeIDs, node.ID) + } + + if len(nodeToDelete) == 0 { + break + } + + start += limit + } + + blog.Info("get all node ID success") + + return nodeIDs, nil +} diff --git a/bcs-services/bcs-cluster-manager/internal/cloudprovider/common/task.go b/bcs-services/bcs-cluster-manager/internal/cloudprovider/common/task.go index a97b4f359e..6fc270f199 100644 --- a/bcs-services/bcs-cluster-manager/internal/cloudprovider/common/task.go +++ b/bcs-services/bcs-cluster-manager/internal/cloudprovider/common/task.go @@ -38,6 +38,7 @@ func RegisterCommonActions() map[string]interface{} { cloudprovider.InstallImagePullSecretAddonAction: EnsureInstallImageSecretTask, cloudprovider.InstallGseAgentAction: InstallGSEAgentTask, cloudprovider.TransferHostModuleAction: TransferHostModuleTask, + cloudprovider.RemoveDataFromCmdbAction: RemoveDataFromCMDBTask, cloudprovider.RemoveHostFromCmdbAction: RemoveHostFromCMDBTask, cloudprovider.JobFastExecuteScriptAction: JobExecuteScriptTask, cloudprovider.EnsureAutoScalerAction: EnsureAutoScalerTask, diff --git a/bcs-services/bcs-cluster-manager/internal/cloudprovider/google/taskmgr.go b/bcs-services/bcs-cluster-manager/internal/cloudprovider/google/taskmgr.go index 81288923a9..39bbf2a7d8 100644 --- a/bcs-services/bcs-cluster-manager/internal/cloudprovider/google/taskmgr.go +++ b/bcs-services/bcs-cluster-manager/internal/cloudprovider/google/taskmgr.go @@ -526,7 +526,10 @@ func (t *Task) BuildCleanNodesInGroupTask(nodes []*proto.Node, group *proto.Node // step3: check cluster delete nodes common.BuildCheckClusterCleanNodesTaskStep(task, group.Provider, opt.Cluster.ClusterID, nodeIDs) - // step5: remove host from cmdb + // step5: remove data from cmdb + common.BuildRemoveCmdbDataStep(task, opt.Cluster.BusinessID, opt.Cluster.ClusterID, nodeIDs) + + // step6: remove host from cmdb common.BuildRemoveHostStep(task, opt.Cluster.BusinessID, nodeIPs) // set current step diff --git a/bcs-services/bcs-cluster-manager/internal/cloudprovider/utils.go b/bcs-services/bcs-cluster-manager/internal/cloudprovider/utils.go index 8e86a963f1..c86e400562 100644 --- a/bcs-services/bcs-cluster-manager/internal/cloudprovider/utils.go +++ b/bcs-services/bcs-cluster-manager/internal/cloudprovider/utils.go @@ -57,6 +57,8 @@ const ( WatchTask = "watchjob" // InstallImagePullSecretAddonAction imagePull component common job InstallImagePullSecretAddonAction = "installImagePullSecret" + // RemoveDataFromCmdbAction remove cmdb data action + RemoveDataFromCmdbAction = "removeDataFromCmdb" // RemoveHostFromCmdbAction remove host action RemoveHostFromCmdbAction = "removeHostFromCmdb" // CheckNodeIpsInCmdbAction check node if in cmdb diff --git a/bcs-services/bcs-cluster-manager/internal/remote/cmdb/client.go b/bcs-services/bcs-cluster-manager/internal/remote/cmdb/client.go index ea9c6f62e1..4ca389721b 100644 --- a/bcs-services/bcs-cluster-manager/internal/remote/cmdb/client.go +++ b/bcs-services/bcs-cluster-manager/internal/remote/cmdb/client.go @@ -1147,3 +1147,336 @@ func (c *Client) SyncHostInfoFromCmpy(bkCloudId int, bkHostIds []int64) error { return nil } + +// GetBcsPod get pod +func (c *Client) GetBcsPod(req *GetBcsPodReq) (*[]Pod, error) { + reqURL := fmt.Sprintf("%s/api/bk-cmdb/prod/api/v3/findmany/kube/pod", c.server) + respData := &GetBcsPodResp{} + + resp, _, errs := gorequest.New(). + Timeout(defaultTimeOut). + Post(reqURL). + Set("Content-Type", "application/json"). + Set("Accept", "application/json"). + Set("X-Bkapi-Authorization", c.userAuth). + SetDebug(c.serverDebug). + Send(req). + Retry(3, 3*time.Second, 429). + EndStruct(&respData) + if len(errs) > 0 { + blog.Errorf("call api list_pod failed: %v", errs[0]) + return nil, errs[0] + } + + if !respData.Result { + blog.Errorf("call api list_pod failed: %v, rid: %s", + respData.Message, resp.Header.Get("X-Request-Id")) + return nil, fmt.Errorf(respData.Message) + } + + blog.Infof("call api list_pod with url(%s) (%v) successfully, X-Request-Id: %s", + reqURL, req, resp.Header.Get("X-Request-Id")) + + return respData.Data.Info, nil +} + +// DeleteBcsPod delete pod +func (c *Client) DeleteBcsPod(req *DeleteBcsPodReq) error { + reqURL := fmt.Sprintf("%s/api/bk-cmdb/prod/api/v3/deletemany/kube/pod", c.server) + respData := &DeleteBcsPodResp{} + + resp, _, errs := gorequest.New(). + Timeout(defaultTimeOut). + Delete(reqURL). + Set("Content-Type", "application/json"). + Set("Accept", "application/json"). + Set("X-Bkapi-Authorization", c.userAuth). + SetDebug(c.serverDebug). + Send(req). + Retry(3, 3*time.Second, 429). + EndStruct(&respData) + if len(errs) > 0 { + blog.Errorf("call api batch_delete_kube_pod failed: %v", errs[0]) + return errs[0] + } + + if !respData.Result { + blog.Errorf("call api batch_delete_kube_pod failed: %v, rid: %s", + respData.Message, resp.Header.Get("X-Request-Id")) + return fmt.Errorf(respData.Message) + } + + blog.Infof("call api batch_delete_kube_pod with url(%s) (%v) successfully, X-Request-Id: %s", + reqURL, req, resp.Header.Get("X-Request-Id")) + + return nil +} + +// GetBcsWorkload get workload +func (c *Client) GetBcsWorkload(req *GetBcsWorkloadReq) (*[]interface{}, error) { + reqURL := fmt.Sprintf("%s/api/bk-cmdb/prod/api/v3/findmany/kube/workload/%s", c.server, req.Kind) + respData := &GetBcsWorkloadResp{} + + resp, _, errs := gorequest.New(). + Timeout(defaultTimeOut). + Post(reqURL). + Set("Content-Type", "application/json"). + Set("Accept", "application/json"). + Set("X-Bkapi-Authorization", c.userAuth). + SetDebug(c.serverDebug). + Send(req). + Retry(3, 3*time.Second, 429). + EndStruct(&respData) + if len(errs) > 0 { + blog.Errorf("call api list_workload failed: %v, rid: %s", errs[0], respData.RequestID) + return nil, errs[0] + } + + if !respData.Result { + blog.Errorf("call api list_workload failed: %v, rid: %s", + respData.Message, resp.Header.Get("X-Request-Id")) + return nil, fmt.Errorf(respData.Message) + } + + blog.Infof("call api list_workload with url(%s) (%v) successfully, X-Request-Id: %s", + reqURL, req, resp.Header.Get("X-Request-Id")) + + return &respData.Data.Info, nil +} + +// DeleteBcsWorkload delete workload +func (c *Client) DeleteBcsWorkload(req *DeleteBcsWorkloadReq) error { + reqURL := fmt.Sprintf("%s/api/bk-cmdb/prod/api/v3/deletemany/kube/workload/%s", c.server, *req.Kind) + respData := &DeleteBcsWorkloadResp{} + + resp, _, errs := gorequest.New(). + Timeout(defaultTimeOut). + Delete(reqURL). + Set("Content-Type", "application/json"). + Set("Accept", "application/json"). + Set("X-Bkapi-Authorization", c.userAuth). + SetDebug(c.serverDebug). + Send(req). + Retry(3, 3*time.Second, 429). + EndStruct(&respData) + if len(errs) > 0 { + blog.Errorf("call api batch_delete_workload failed: %v", errs[0]) + return errs[0] + } + + if !respData.Result { + blog.Errorf( + "call api batch_delete_workload failed: %v, rid: %s, request: bkbizid: %d, kind: %s, ids: %v", + respData.Message, resp.Header.Get("X-Request-Id"), *req.BKBizID, *req.Kind, *req.IDs) + return fmt.Errorf(respData.Message) + } + + blog.Infof("call api batch_delete_workload with url(%s) (%v) successfully, X-Request-Id: %s", + reqURL, req, resp.Header.Get("X-Request-Id")) + + return nil +} + +// GetBcsNamespace get namespace +func (c *Client) GetBcsNamespace(req *GetBcsNamespaceReq) (*[]Namespace, error) { + reqURL := fmt.Sprintf("%s/api/bk-cmdb/prod/api/v3/findmany/kube/namespace", c.server) + respData := &GetBcsNamespaceResp{} + + resp, _, errs := gorequest.New(). + Timeout(defaultTimeOut). + Post(reqURL). + Set("Content-Type", "application/json"). + Set("Accept", "application/json"). + Set("X-Bkapi-Authorization", c.userAuth). + SetDebug(c.serverDebug). + Send(req). + Retry(3, 3*time.Second, 429). + EndStruct(&respData) + if len(errs) > 0 { + blog.Errorf("call api list_namespace failed: %v", errs[0]) + return nil, errs[0] + } + + if !respData.Result { + blog.Errorf("call api list_namespace failed: %v, rid: %s", + respData.Message, resp.Header.Get("X-Request-Id")) + return nil, fmt.Errorf(respData.Message) + } + + blog.Infof("call api list_namespace with url(%s) (%v) successfully, X-Request-Id: %s", + reqURL, req, resp.Header.Get("X-Request-Id")) + + return respData.Data.Info, nil +} + +// DeleteBcsNamespace delete namespace +func (c *Client) DeleteBcsNamespace(req *DeleteBcsNamespaceReq) error { + reqURL := fmt.Sprintf("%s/api/bk-cmdb/prod/api/v3/deletemany/kube/namespace", c.server) + respData := &DeleteBcsNamespaceResp{} + + resp, _, errs := gorequest.New(). + Timeout(defaultTimeOut). + Delete(reqURL). + Set("Content-Type", "application/json"). + Set("Accept", "application/json"). + Set("X-Bkapi-Authorization", c.userAuth). + SetDebug(c.serverDebug). + Send(req). + Retry(3, 3*time.Second, 429). + EndStruct(&respData) + if len(errs) > 0 { + blog.Errorf("call api batch_delete_namespace failed: %v", errs[0]) + return errs[0] + } + + if !respData.Result { + blog.Errorf("call api batch_delete_namespace failed: %v, rid: %s", + respData.Message, resp.Header.Get("X-Request-Id")) + return fmt.Errorf(respData.Message) + } + + blog.Infof("call api batch_delete_namespace with url(%s) (%v) successfully, X-Request-Id: %s", + reqURL, req, resp.Header.Get("X-Request-Id")) + + return nil +} + +// GetBcsNode get node +func (c *Client) GetBcsNode(req *GetBcsNodeReq) (*[]Node, error) { + reqURL := fmt.Sprintf("%s/api/bk-cmdb/prod/api/v3/findmany/kube/node", c.server) + respData := &GetBcsNodeResp{} + + resp, _, errs := gorequest.New(). + Timeout(defaultTimeOut). + Post(reqURL). + Set("Content-Type", "application/json"). + Set("Accept", "application/json"). + Set("X-Bkapi-Authorization", c.userAuth). + SetDebug(c.serverDebug). + Send(req). + Retry(3, 3*time.Second, 429). + EndStruct(&respData) + if len(errs) > 0 { + blog.Errorf("call api list_kube_node failed: %v", errs[0]) + return nil, errs[0] + } + + if !respData.Result { + blog.Errorf("call api list_kube_node failed: %v, rid: %s", + respData.Message, resp.Header.Get("X-Request-Id")) + return nil, fmt.Errorf(respData.Message) + } + + blog.Infof("call api list_kube_node with url(%s) (%v) successfully, X-Request-Id: %s", + reqURL, req, resp.Header.Get("X-Request-Id")) + + return respData.Data.Info, nil +} + +// DeleteBcsNode delete node +func (c *Client) DeleteBcsNode(req *DeleteBcsNodeReq) error { + reqURL := fmt.Sprintf("%s/api/bk-cmdb/prod/api/v3/deletemany/kube/node", c.server) + respData := &DeleteBcsNodeResp{} + + resp, _, errs := gorequest.New(). + Timeout(defaultTimeOut). + Delete(reqURL). + Set("Content-Type", "application/json"). + Set("Accept", "application/json"). + Set("X-Bkapi-Authorization", c.userAuth). + SetDebug(c.serverDebug). + Send(req). + Retry(3, 3*time.Second, 429). + EndStruct(&respData) + if len(errs) > 0 { + blog.Errorf("call api batch_delete_kube_node failed: %v", errs[0]) + return errs[0] + } + + if !respData.Result { + blog.Errorf("call api batch_delete_kube_node failed: %v, rid: %s", + respData.Message, resp.Header.Get("X-Request-Id")) + return fmt.Errorf(respData.Message) + } + + blog.Infof("call api batch_delete_kube_node with url(%s) (%v) successfully, X-Request-Id: %s", + reqURL, req, resp.Header.Get("X-Request-Id")) + + return nil +} + +// GetBcsCluster get cluster +func (c *Client) GetBcsCluster(req *GetBcsClusterReq) (*[]Cluster, error) { + // 如果没有通过数据库查询,则通过API调用获取集群信息 + reqURL := fmt.Sprintf("%s/api/bk-cmdb/prod/api/v3/findmany/kube/cluster", c.server) + respData := &GetBcsClusterResp{} + // 使用gorequest库发送POST请求,并处理响应 + resp, _, errs := gorequest.New(). + Timeout(defaultTimeOut). + Post(reqURL). + Set("Content-Type", "application/json"). + Set("Accept", "application/json"). + Set("X-Bkapi-Authorization", c.userAuth). + SetDebug(c.serverDebug). + Send(req). + Retry(3, 3*time.Second, 429). + EndStruct(&respData) + // 检查是否有错误发生 + if len(errs) > 0 { + blog.Errorf("call api list_kube_cluster failed: %v", errs[0]) + return nil, errs[0] + } + + // 检查API响应是否成功 + if !respData.Result { + blog.Errorf("call api list_kube_cluster failed: %v, rid: %s", + respData.Message, resp.Header.Get("X-Request-Id")) + return nil, fmt.Errorf(respData.Message) + } + + blog.Infof("call api list_kube_cluster with url(%s) (%v) successfully, X-Request-Id: %s", + reqURL, req, resp.Header.Get("X-Request-Id")) + + return &respData.Data.Info, nil +} + +// DeleteBcsCluster delete bcs cluster +func (c *Client) DeleteBcsCluster(req *DeleteBcsClusterReq) error { + // 构造请求的 URL + reqURL := fmt.Sprintf("%s/api/bk-cmdb/prod/api/v3/delete/kube/cluster", c.server) + // 初始化响应数据结构 + respData := &DeleteBcsClusterResp{} + + // 使用 gorequest 库发送 HTTP DELETE 请求 + // 设置请求超时时间、内容类型、接受类型、授权头等信息 + // 发送请求体并尝试重试,最多重试3次,每次间隔3秒,如果遇到429状态码也会重试 + resp, _, errs := gorequest.New(). + Timeout(defaultTimeOut). + Delete(reqURL). + Set("Content-Type", "application/json"). + Set("Accept", "application/json"). + Set("X-Bkapi-Authorization", c.userAuth). + SetDebug(c.serverDebug). + Send(req). + Retry(3, 3*time.Second, 429). + EndStruct(&respData) + + // 如果请求过程中出现错误,则记录错误并返回 + if len(errs) > 0 { + blog.Errorf("call api batch_delete_kube_cluster failed: %v", errs[0]) + return errs[0] + } + + // 如果响应结果指示操作失败,则记录错误信息并返回错误 + if !respData.Result { + blog.Errorf("call api batch_delete_kube_cluster failed: %v, rid: %s", + respData.Message, resp.Header.Get("X-Request-Id")) + return fmt.Errorf(respData.Message) + } + + // 如果操作成功,则记录成功的日志信息 + blog.Infof("call api batch_delete_kube_cluster with url(%s) (%v) successfully, X-Request-Id: %s", + reqURL, req, resp.Header.Get("X-Request-Id")) + + return nil +} diff --git a/bcs-services/bcs-cluster-manager/internal/remote/cmdb/types.go b/bcs-services/bcs-cluster-manager/internal/remote/cmdb/types.go index e3b9c03ccf..2e58252ce6 100644 --- a/bcs-services/bcs-cluster-manager/internal/remote/cmdb/types.go +++ b/bcs-services/bcs-cluster-manager/internal/remote/cmdb/types.go @@ -518,3 +518,249 @@ type SyncHostInfoFromCmpyReq struct { type SyncHostInfoFromCmpyResp struct { BaseResponse } + +// GetBcsPodReq defines the structure of the request for getting BCS pods. +type GetBcsPodReq struct { + BKBizID int64 `json:"bk_biz_id"` + Page Page `json:"page"` + Fields []string `json:"fields"` + Filter *HostPropertyFilter `json:"filter"` +} + +// GetBcsPodResp defines the structure of the response for getting BCS pods. +type GetBcsPodResp struct { + BaseResponse + Data *GetBcsPodRespData `json:"data"` +} + +// GetBcsPodRespData defines the structure of the response data for getting BCS pods. +type GetBcsPodRespData struct { + Count int `json:"count"` + Info *[]Pod `json:"info"` +} + +// Pod pod details +type Pod struct { + // cc的自增主键 + ID int64 `json:"id"` + Name *string `json:"name"` + Priority *int32 `json:"priority"` + Labels *map[string]string `json:"labels"` + IP *string `json:"ip"` + NodeSelectors *map[string]string `json:"node_selectors"` + Operator *[]string `json:"operator"` +} + +// DeleteBcsPodReq defines the request structure for deleting a BCS pod. +type DeleteBcsPodReq struct { + Data *[]DeleteBcsPodReqData `json:"data"` +} + +// DeleteBcsPodReqData defines the data structure in the DeleteBcsPodRequest. +type DeleteBcsPodReqData struct { + BKBizID *int64 `json:"bk_biz_id"` + IDs *[]int64 `json:"ids"` +} + +// DeleteBcsPodResp defines the response structure for deleting a BCS pod. +type DeleteBcsPodResp struct { + BaseResponse + Data interface{} `json:"data"` +} + +// GetBcsWorkloadReq represents a request for getting BCS workload +type GetBcsWorkloadReq struct { + BKBizID int64 `json:"bk_biz_id"` + Page Page `json:"page"` + Fields []string `json:"fields"` + Filter *HostPropertyFilter `json:"filter"` + Kind string `json:"kind"` +} + +// GetBcsWorkloadResp represents a response for getting BCS workload +type GetBcsWorkloadResp struct { + BaseResponse + Data *GetBcsWorkloadRespData `json:"data"` +} + +// GetBcsWorkloadRespData represents the data structure of the response for getting BCS workload +type GetBcsWorkloadRespData struct { + Count int64 `json:"count"` + Info []interface{} `json:"info"` +} + +// DeleteBcsWorkloadReq defines the structure of the request for deleting a BCS workload. +type DeleteBcsWorkloadReq struct { + BKBizID *int64 `json:"bk_biz_id"` + Kind *string `json:"kind"` + IDs *[]int64 `json:"ids"` +} + +// DeleteBcsWorkloadResp defines the structure of the response for deleting a BCS workload. +type DeleteBcsWorkloadResp struct { + BaseResponse + Data interface{} `json:"data"` +} + +// GetBcsNamespaceReq represents the request for getting a BCS namespace +type GetBcsNamespaceReq struct { + BKBizID int64 `json:"bk_biz_id"` + Page Page `json:"page"` + Fields []string `json:"fields"` + Filter *HostPropertyFilter `json:"filter"` +} + +// Namespace define the namespace struct. +type Namespace struct { + ID int64 `json:"id"` + Name string `json:"name"` + Labels *map[string]string `json:"labels"` + SupplierAccount string `json:"bk_supplier_account"` +} + +// GetBcsNamespaceResp represents the response for getting a BCS namespace +type GetBcsNamespaceResp struct { + BaseResponse + Data *GetBcsNamespaceRespData `json:"data"` +} + +// GetBcsNamespaceRespData represents the data for getting a BCS namespace +type GetBcsNamespaceRespData struct { + Count int64 `json:"count"` + Info *[]Namespace `json:"info"` +} + +// DeleteBcsNamespaceReq represents the request for deleting a BCS namespace +type DeleteBcsNamespaceReq struct { + BKBizID *int64 `json:"bk_biz_id"` + IDs *[]int64 `json:"ids"` +} + +// DeleteBcsNamespaceResp represents the response for deleting a BCS namespace +type DeleteBcsNamespaceResp struct { + BaseResponse + Data interface{} `json:"data"` +} + +// GetBcsNodeReq defines the structure of the request for getting BCS nodes. +type GetBcsNodeReq struct { + BKBizID int64 `json:"bk_biz_id"` + Page Page `json:"page"` + Fields []string `json:"fields"` + Filter *HostPropertyFilter `json:"filter"` +} + +// Node node structural description. +type Node struct { + // ID cluster auto-increment ID in cc + ID int64 `json:"id,omitempty" bson:"id"` + // BizID the business ID to which the cluster belongs + BizID int64 `json:"bk_biz_id,omitempty" bson:"bk_biz_id"` + // SupplierAccount the supplier account that this resource belongs to. + SupplierAccount string `json:"bk_supplier_account,omitempty" bson:"bk_supplier_account"` + // HostID the node ID to which the host belongs + HostID int64 `json:"bk_host_id,omitempty" bson:"bk_host_id"` + // ClusterID the node ID to which the cluster belongs + ClusterID int64 `json:"bk_cluster_id,omitempty" bson:"bk_cluster_id"` + // ClusterUID the node ID to which the cluster belongs + ClusterUID string `json:"cluster_uid,omitempty" bson:"cluster_uid"` + // HasPod this field indicates whether there is a pod in the node. + // if there is a pod, this field is true. If there is no pod, this + // field is false. this field is false when node is created by default. + HasPod *bool `json:"has_pod,omitempty" bson:"has_pod"` + Name *string `json:"name,omitempty" bson:"name"` + Roles *string `json:"roles,omitempty" bson:"roles"` + Unschedulable *bool `json:"unschedulable,omitempty" bson:"unschedulable"` + InternalIP *[]string `json:"internal_ip,omitempty" bson:"internal_ip"` + ExternalIP *[]string `json:"external_ip,omitempty" bson:"external_ip"` + HostName *string `json:"hostname,omitempty" bson:"hostname"` + RuntimeComponent *string `json:"runtime_component,omitempty" bson:"runtime_component"` + KubeProxyMode *string `json:"kube_proxy_mode,omitempty" bson:"kube_proxy_mode"` + PodCidr *string `json:"pod_cidr,omitempty" bson:"pod_cidr"` +} + +// GetBcsNodeResp defines the structure of the response for getting BCS nodes. +type GetBcsNodeResp struct { + BaseResponse + Data *GetBcsNodeRespData `json:"data"` +} + +// GetBcsNodeRespData defines the structure of the response data for getting BCS nodes. +type GetBcsNodeRespData struct { + Count int64 `json:"count"` + Info *[]Node `json:"info"` +} + +// DeleteBcsNodeReq defines the structure of the request for deleting BCS nodes. +type DeleteBcsNodeReq struct { + BKBizID *int64 `json:"bk_biz_id"` + IDs *[]int64 `json:"ids"` +} + +// DeleteBcsNodeResp defines the structure of the response for deleting BCS nodes. +type DeleteBcsNodeResp struct { + BaseResponse + Data interface{} `json:"data"` +} + +// GetBcsClusterReq defines the request structure for getting BCS cluster information. +type GetBcsClusterReq struct { + BKBizID int64 `json:"bk_biz_id"` + Page Page `json:"page"` + Fields []string `json:"fields"` + Filter *HostPropertyFilter `json:"filter"` +} + +// Cluster container cluster table structure +type Cluster struct { + // ID cluster auto-increment ID in cc + ID int64 `json:"id" bson:"id"` + // BizID the business ID to which the cluster belongs + BizID int64 `json:"bk_biz_id" bson:"bk_biz_id"` + // SupplierAccount the supplier account that this resource belongs to. + SupplierAccount string `json:"bk_supplier_account" bson:"bk_supplier_account"` + // Name cluster name. + Name *string `json:"name,omitempty" bson:"name"` + // SchedulingEngine scheduling engines, such as k8s, tke, etc. + SchedulingEngine *string `json:"scheduling_engine,omitempty" bson:"scheduling_engine"` + // Uid ID of the cluster itself + Uid *string `json:"uid,omitempty" bson:"uid"` + // Xid The underlying cluster ID it depends on + Xid *string `json:"xid,omitempty" bson:"xid"` + // Version cluster version + Version *string `json:"version,omitempty" bson:"version"` + // NetworkType network type, such as overlay or underlay + NetworkType *string `json:"network_type,omitempty" bson:"network_type"` + // Region the region where the cluster is located + Region *string `json:"region,omitempty" bson:"region"` + // Vpc vpc network + Vpc *string `json:"vpc,omitempty" bson:"vpc"` + // Environment cluster environment + Environment *string `json:"environment,omitempty" bson:"environment"` + // NetWork global routing network address (container overlay network) For example: ["1.1.1.0/21"] + NetWork *[]string `json:"network,omitempty" bson:"network"` +} + +// GetBcsClusterResp defines the response structure for getting BCS cluster information. +type GetBcsClusterResp struct { + BaseResponse + Data GetBcsClusterRespData `json:"data"` +} + +// GetBcsClusterRespData defines the data structure for getting BCS cluster information. +type GetBcsClusterRespData struct { + Count int64 `json:"count"` + Info []Cluster `json:"info"` +} + +// DeleteBcsClusterReq represents the request for deleting a BCS cluster +type DeleteBcsClusterReq struct { + BKBizID *int64 `json:"bk_biz_id"` + IDs *[]int64 `json:"ids"` +} + +// DeleteBcsClusterResp represents the response for deleting a BCS cluster +type DeleteBcsClusterResp struct { + BaseResponse + Data interface{} `json:"data"` +} From 53b9682ca6ecb91911f644df20d60d2cc81ab603 Mon Sep 17 00:00:00 2001 From: dove0012 Date: Sat, 11 Oct 2025 15:13:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E8=AF=AF=E5=88=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bcs-services/bcs-cluster-manager/go.mod | 260 ++++++++++++++++++++++++ 1 file changed, 260 insertions(+) create mode 100644 bcs-services/bcs-cluster-manager/go.mod diff --git a/bcs-services/bcs-cluster-manager/go.mod b/bcs-services/bcs-cluster-manager/go.mod new file mode 100644 index 0000000000..0b007f1e59 --- /dev/null +++ b/bcs-services/bcs-cluster-manager/go.mod @@ -0,0 +1,260 @@ +module github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager + +go 1.21 + +replace ( + k8s.io/api => k8s.io/api v0.26.1 + k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.26.1 + k8s.io/apimachinery => k8s.io/apimachinery v0.26.1 + k8s.io/client-go => k8s.io/client-go v0.26.1 + k8s.io/kubectl => k8s.io/kubectl v0.26.1 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork v1.1.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions v1.3.0 + github.com/GehirnInc/crypt v0.0.0-20230320061759-8cc1b52080c5 + github.com/RichardKnop/machinery/v2 v2.0.11 + github.com/Tencent/bk-bcs/bcs-common v0.0.0-20250521083331-e37404b7dd2a + github.com/Tencent/bk-bcs/bcs-common/common/encryptv2 v0.0.0-20230908045126-c9d09981a9c5 + github.com/Tencent/bk-bcs/bcs-services/pkg v0.0.0-20250728085520-0a1d3fa13c6b + github.com/apparentlymart/go-cidr v1.1.0 + github.com/avast/retry-go v2.7.0+incompatible + github.com/aws/aws-sdk-go v1.55.5 + github.com/envoyproxy/protoc-gen-validate v1.0.4 + github.com/ghodss/yaml v1.0.0 + github.com/go-micro/plugins/v4/registry/etcd v1.1.0 + github.com/go-micro/plugins/v4/server/grpc v1.2.0 + github.com/golang/glog v1.2.0 + github.com/golang/protobuf v1.5.4 + github.com/google/uuid v1.6.0 + github.com/gorilla/mux v1.8.0 + github.com/gorilla/websocket v1.4.2 + github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.154 + github.com/kirito41dd/xslice v0.0.1 + github.com/leodido/go-urn v1.4.0 // indirect + github.com/parnurzeal/gorequest v0.2.16 + github.com/patrickmn/go-cache v2.1.0+incompatible + github.com/pkg/errors v0.9.1 + github.com/prometheus/client_golang v1.19.0 + github.com/robfig/cron/v3 v3.0.1 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.398 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.1.13 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.376 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tag v1.0.768 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1133 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.714 + go-micro.dev/v4 v4.9.0 + go.etcd.io/etcd/client/v3 v3.5.5 + go.mongodb.org/mongo-driver v1.13.1 + golang.org/x/oauth2 v0.18.0 + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d + google.golang.org/api v0.155.0 + google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 + google.golang.org/grpc v1.62.1 + google.golang.org/protobuf v1.33.0 + gopkg.in/go-playground/validator.v9 v9.31.0 + gopkg.in/yaml.v2 v2.4.0 + gorm.io/driver/mysql v1.5.6 + gorm.io/gorm v1.25.9 + k8s.io/api v0.26.1 + k8s.io/apiextensions-apiserver v0.23.1 + k8s.io/apimachinery v0.26.1 + k8s.io/client-go v11.0.0+incompatible + k8s.io/kubectl v0.0.0-00010101000000-000000000000 + sigs.k8s.io/aws-iam-authenticator v0.6.17 +) + +require github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.1052 + +require ( + github.com/Azure/azure-sdk-for-go/profile/p20200901 v0.1.1 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v3 v3.0.0 + github.com/emicklei/go-restful/v3 v3.9.0 +) + +require ( + cloud.google.com/go v0.112.0 // indirect + cloud.google.com/go/compute v1.23.3 // indirect + cloud.google.com/go/compute/metadata v0.2.3 // indirect + cloud.google.com/go/iam v1.1.5 // indirect + cloud.google.com/go/pubsub v1.34.0 // indirect + dario.cat/mergo v1.0.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect + github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect + github.com/MakeNowJust/heredoc v1.0.0 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/ProtonMail/go-crypto v1.1.3 // indirect + github.com/RichardKnop/logging v0.0.0-20190827224416-1a693bdd4fae // indirect + github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/kubernetes/common v0.0.0-20220330120237-0bbed74dcf6d // indirect + github.com/TencentBlueKing/bk-audit-go-sdk v0.0.6 // indirect + github.com/TencentBlueKing/crypto-golang-sdk v1.0.0 // indirect + github.com/TencentBlueKing/gopkg v1.1.0 // indirect + github.com/TencentBlueKing/iam-go-sdk v0.1.6 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/bitly/go-simplejson v0.5.0 // indirect + github.com/cenkalti/backoff/v4 v4.2.1 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/chai2010/gettext-go v1.0.2 // indirect + github.com/cloudflare/circl v1.3.7 // indirect + github.com/coreos/go-semver v0.3.0 // indirect + github.com/coreos/go-systemd/v22 v22.3.2 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/cyphar/filepath-securejoin v0.2.5 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dustin/go-humanize v1.0.0 // indirect + github.com/emirpasic/gods v1.18.1 // indirect + github.com/evanphx/json-patch v4.12.0+incompatible // indirect + github.com/evanphx/json-patch/v5 v5.5.0 // indirect + github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.3 // indirect + github.com/go-acme/lego/v4 v4.4.0 // indirect + github.com/go-errors/errors v1.0.1 // indirect + github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-git/go-billy/v5 v5.6.0 // indirect + github.com/go-git/go-git/v5 v5.13.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonreference v0.20.0 // indirect + github.com/go-openapi/swag v0.19.14 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.19.0 // indirect + github.com/go-resty/resty/v2 v2.12.0 // indirect + github.com/go-sql-driver/mysql v1.7.1 // indirect + github.com/gobwas/httphead v0.1.0 // indirect + github.com/gobwas/pool v0.2.1 // indirect + github.com/gobwas/ws v1.0.4 // indirect + github.com/gofrs/flock v0.8.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/golang-migrate/migrate/v4 v4.17.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/snappy v0.0.4 // indirect + github.com/gomodule/redigo v2.0.0+incompatible // indirect + github.com/google/btree v1.0.1 // indirect + github.com/google/gnostic v0.5.7-v3refs // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/google/s2a-go v0.1.7 // indirect + github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect + github.com/googleapis/gax-go/v2 v2.12.0 // indirect + github.com/gorilla/handlers v1.5.1 // indirect + github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/imdario/mergo v0.3.13 // indirect + github.com/inconshreveable/mousetrap v1.0.1 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/juju/ratelimit v1.0.1 // indirect + github.com/kelseyhightower/envconfig v1.4.0 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect + github.com/klauspost/compress v1.15.11 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect + github.com/mailru/easyjson v0.7.6 // indirect + github.com/mattbaird/jsonpatch v0.0.0-20200820163806-098863c1fc24 // indirect + github.com/miekg/dns v1.1.50 // indirect + github.com/mitchellh/go-wordwrap v1.0.0 // indirect + github.com/mitchellh/hashstructure v1.1.0 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/moby/spdystream v0.2.0 // indirect + github.com/moby/term v0.5.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect + github.com/montanaflynn/stats v0.7.0 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect + github.com/nxadm/tail v1.4.8 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/openzipkin/zipkin-go v0.3.0 // indirect + github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect + github.com/peterbourgon/diskv v2.0.1+incompatible // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.48.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414 // indirect + github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/skeema/knownhosts v1.3.0 // indirect + github.com/spf13/cobra v1.6.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/streadway/amqp v1.0.0 // indirect + github.com/tjfoc/gmsm v1.4.1 // indirect + github.com/ugorji/go/codec v1.2.11 // indirect + github.com/urfave/cli/v2 v2.3.0 // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect + github.com/xdg-go/pbkdf2 v1.0.0 // indirect + github.com/xdg-go/scram v1.1.2 // indirect + github.com/xdg-go/stringprep v1.0.4 // indirect + github.com/xlab/treeprint v1.1.0 // indirect + github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect + go.etcd.io/etcd/api/v3 v3.5.5 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect + go.opencensus.io v0.24.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect + go.opentelemetry.io/otel v1.21.0 // indirect + go.opentelemetry.io/otel/exporters/jaeger v1.3.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.17.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.17.0 // indirect + go.opentelemetry.io/otel/exporters/zipkin v1.3.0 // indirect + go.opentelemetry.io/otel/metric v1.21.0 // indirect + go.opentelemetry.io/otel/sdk v1.21.0 // indirect + go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.opentelemetry.io/proto/otlp v1.0.0 // indirect + go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect + go.uber.org/atomic v1.7.0 // indirect + go.uber.org/multierr v1.6.0 // indirect + go.uber.org/zap v1.19.0 // indirect + golang.org/x/crypto v0.31.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.33.0 // indirect + golang.org/x/sync v0.10.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/term v0.27.0 // indirect + golang.org/x/text v0.21.0 // indirect + golang.org/x/time v0.5.0 // indirect + google.golang.org/appengine v1.6.8 // indirect + google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect + gopkg.in/go-playground/assert.v1 v1.2.1 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/cli-runtime v0.26.1 // indirect + k8s.io/component-base v0.26.1 // indirect + k8s.io/klog v1.0.0 // indirect + k8s.io/klog/v2 v2.100.1 // indirect + k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect + k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect + moul.io/http2curl v1.0.0 // indirect + sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect + sigs.k8s.io/kustomize/api v0.12.1 // indirect + sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect + sigs.k8s.io/yaml v1.3.0 // indirect +) From be6ce2010df17f4847bc1a8c8425139e167e64a2 Mon Sep 17 00:00:00 2001 From: dove0012 Date: Sat, 11 Oct 2025 15:32:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dgolangci-lint=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/cloudprovider/common/component.go | 2 +- .../bcs-cluster-manager/internal/cloudprovider/utils.go | 2 +- .../bcs-cluster-manager/internal/remote/log/bklog/bk_log.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bcs-services/bcs-cluster-manager/internal/cloudprovider/common/component.go b/bcs-services/bcs-cluster-manager/internal/cloudprovider/common/component.go index fed30e0aa3..1669308d3d 100644 --- a/bcs-services/bcs-cluster-manager/internal/cloudprovider/common/component.go +++ b/bcs-services/bcs-cluster-manager/internal/cloudprovider/common/component.go @@ -16,7 +16,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/remote/install" "time" "github.com/Tencent/bk-bcs/bcs-common/common/blog" @@ -30,6 +29,7 @@ import ( "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/cloudprovider/component/watch" "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/common" ioptions "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/options" + "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/remote/install" "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/remote/log/bklog" "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/remote/loop" "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/store/options" diff --git a/bcs-services/bcs-cluster-manager/internal/cloudprovider/utils.go b/bcs-services/bcs-cluster-manager/internal/cloudprovider/utils.go index c86e400562..b473e0674a 100644 --- a/bcs-services/bcs-cluster-manager/internal/cloudprovider/utils.go +++ b/bcs-services/bcs-cluster-manager/internal/cloudprovider/utils.go @@ -108,7 +108,7 @@ const ( // NodeDrainPodAction 节点驱逐pod NodeDrainPodAction = "nodeDrainPod" // InstallLogCollectorAddonAction 安装日志采集组件 - InstallLogCollectorAddonAction = "installLogCollectorAddon" + InstallLogCollectorAddonAction = "installLogCollectorAddon" // nolint ) var ( diff --git a/bcs-services/bcs-cluster-manager/internal/remote/log/bklog/bk_log.go b/bcs-services/bcs-cluster-manager/internal/remote/log/bklog/bk_log.go index c8ad4b4522..afb48f0c31 100644 --- a/bcs-services/bcs-cluster-manager/internal/remote/log/bklog/bk_log.go +++ b/bcs-services/bcs-cluster-manager/internal/remote/log/bklog/bk_log.go @@ -80,7 +80,7 @@ func EnableMonitorAudit(projectID, clusterID string) error { // nolint if err := json.Unmarshal([]byte(body), respData); err != nil { metrics.ReportLibRequestMetric("bklog", "EnableMonitorAudit", "http", metrics.LibCallStatusErr, start) - errMsg := fmt.Errorf("parse EnableMonitorAudit response failed: %v, raw body: %s", err, string(body)) + errMsg := fmt.Errorf("parse EnableMonitorAudit response failed: %v, raw body: %s", err, body) blog.Errorf("EnableMonitorAudit failed: %v", errMsg) return errMsg }