Skip to content

Commit

Permalink
feature: cluster manager support ctyun deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Maclon9573 committed Oct 13, 2023
1 parent 751a215 commit 86131e0
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/cloudprovider"
"time"

"github.com/Tencent/bk-bcs/bcs-common/common/blog"
"github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/cloudprovider"

"github.com/google/uuid"
"github.com/parnurzeal/gorequest"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,14 @@ type ContainerRuntime struct {
Version string `json:"version"`
}

// CommonResponse common response
type CommonResponse struct {
StatusCode string `json:"statusCode,omitempty"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
}

// GetClusterResponse xxx
// GetClusterResponse response for GetCluster
type GetClusterResponse struct {
CommonResponse
ReturnObj *GetClusterReObj `json:"returnObj,omitempty"`
Expand Down Expand Up @@ -227,7 +228,7 @@ type KubeConfig struct {
ExpireTime string `json:"expireTime"`
}

// CreateClusterResponse xxx
// CreateClusterResponse response for CreateCluster
type CreateClusterResponse struct {
CommonResponse
ReturnObj *CreateClusterReObj `json:"returnObj,omitempty"`
Expand All @@ -240,34 +241,40 @@ type CreateClusterReObj struct {
TaskId string `json:"taskId"`
}

// DeleteClusterReq request info for DeleteCluster
type DeleteClusterReq struct {
ClusterId string `json:"clusterId"`
ReservedLbIds []string `json:"reservedLbIds"`
ReservedNatIds []string `json:"reservedNatIds"`
ReservedSgId string `json:"reservedSgId"`
}

// DeleteClusterResponse response for DeleteCluster
type DeleteClusterResponse struct {
CommonResponse
ReturnObj *DeleteClusterReObj `json:"returnObj,omitempty"`
}

// DeleteClusterReObj xxx
type DeleteClusterReObj struct {
RequestId string `json:"requestId"`
TaskId string `json:"taskId"`
}

// GetKubeConfigResponse response for GetKubeConfig
type GetKubeConfigResponse struct {
CommonResponse
ReturnObj *GetKubeConfigReObj `json:"returnObj,omitempty"`
}

// GetKubeConfigReObj xxx
type GetKubeConfigReObj struct {
RequestId string `json:"requestId"`
InternalKubeConfig *KubeConfig `json:"internalKubeConfig"`
ExternalKubeConfig *KubeConfig `json:"externalKubeConfig"`
}

// ListNodeReq request for ListNode
type ListNodeReq struct {
ClusterID string `json:"clusterID"`
NodeNames string `json:"nodeNames,omitempty"`
Expand All @@ -276,17 +283,20 @@ type ListNodeReq struct {
PerPage uint32 `json:"perPage,omitempty"`
}

// ListNodeResponse response for ListNode
type ListNodeResponse struct {
CommonResponse
ReturnObj *ListNodeReObj `json:"returnObj,omitempty"`
}

// ListNodeReObj xxx
type ListNodeReObj struct {
RequestId string `json:"requestId"`
Nodes []*Node `json:"nodes"`
Paging *Paging `json:"paging"`
}

// Node ECK node info
type Node struct {
NodePoolId string `json:"nodePoolId"`
NodeName string `json:"nodeName"`
Expand All @@ -301,16 +311,19 @@ type Node struct {
CreateTime string `json:"createTime"`
}

// GetNodePoolResponse response for GetNodePool
type GetNodePoolResponse struct {
CommonResponse
ReturnObj *GetNodePoolReObj `json:"returnObj"`
}

// GetNodePoolReObj xxx
type GetNodePoolReObj struct {
RequestId string `json:"requestId"`
NodePool *NodePool `json:"nodePool"`
}

// NodePool ECK GetNodePool info
type NodePool struct {
ClusterId string `json:"clusterId"`
NodePoolId string `json:"nodePoolId"`
Expand All @@ -323,6 +336,7 @@ type NodePool struct {
ContainerRuntime string `json:"containerRuntime"`
}

// NodePoolConf ECK nodepool config
type NodePoolConf struct {
NodeCode string `json:"nodeCode"`
ImageName string `json:"imageName"`
Expand All @@ -334,13 +348,15 @@ type NodePoolConf struct {
DataDisks []*Disk `json:"dataDisks"`
}

// Paging info for paging
type Paging struct {
TotalPage uint32 `json:"totalPage"`
Page uint32 `json:"page"`
PerPage uint32 `json:"perPage"`
TotalRecord uint32 `json:"totalRecord"`
}

// ListNodePoolReq request for ListNodePool
type ListNodePoolReq struct {
ClusterID string `json:"clusterID"`
EnableAutoScaling string `json:"enableAutoScaling,omitempty"`
Expand All @@ -350,18 +366,20 @@ type ListNodePoolReq struct {
RetainSystemNodePool bool `json:"retainSystemNodePool,omitempty"`
}

// ListNodePoolResponse response for ListNodePool
type ListNodePoolResponse struct {
CommonResponse
ReturnObj *ListNodePoolReObj `json:"returnObj"`
}

// ListNodePoolReObj xxx
type ListNodePoolReObj struct {
RequestId string `json:"requestId"`
Paging *Paging `json:"paging"`
NodePools []*NodePoolV2 `json:"nodePools"`
}

// NodePoolV2 List nodepool
// NodePoolV2 ECK ListNodePool info
type NodePoolV2 struct {
NodePoolId string `json:"nodePoolId"`
Name string `json:"name"`
Expand All @@ -382,34 +400,40 @@ type NodePoolV2 struct {
CycleType string `json:"cycleType"`
}

// VmInfo nodepool VM info
type VmInfo struct {
InstanceName string `json:"instanceName"`
Mem uint32 `json:"mem"`
VCpu uint32 `json:"vCpu"`
}

// NodeNum node num for different node states
type NodeNum struct {
All uint32 `json:"all"`
Normal uint32 `json:"normal"`
}

// ListVpcResponse response for ListVpc
type ListVpcResponse struct {
CommonResponse
ReturnObj *ListVpcReObj `json:"returnObj,omitempty"`
}

// ListVpcReObj xxx
type ListVpcReObj struct {
RequestId string `json:"requestId"`
Vpcs []*Vpc `json:"vpcs"`
}

// Vpc info for Vpc
type Vpc struct {
VpcId uint32 `json:"vpcId"`
Name string `json:"name"`
CidrBlock string `json:"cidrBlock"`
Subnets []*Subnet `json:"subnets"`
}

// Subnet info for Subnet
type Subnet struct {
SubnetId uint32 `json:"subnetId"`
Name string `json:"name"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ package eop

import (
"fmt"
"sync"

"github.com/Tencent/bk-bcs/bcs-common/common/blog"
cmproto "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/api/clustermanager"
"github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/cloudprovider"
putils "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/cloudprovider/utils"
"github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/common"
"sync"
)

var cloudInfoMgr sync.Once
Expand All @@ -36,6 +37,7 @@ func init() {
type CloudInfoManager struct {
}

// InitCloudClusterDefaultInfo init cloud cluster default configInfo
func (c *CloudInfoManager) InitCloudClusterDefaultInfo(cls *cmproto.Cluster, opt *cloudprovider.InitClusterConfigOption) error {
if c == nil || cls == nil {
return fmt.Errorf("%s InitCloudClusterDefaultInfo request is empty", cloudName)
Expand All @@ -61,6 +63,7 @@ func (c *CloudInfoManager) InitCloudClusterDefaultInfo(cls *cmproto.Cluster, opt
return nil
}

// SyncClusterCloudInfo sync cluster metadata
func (c *CloudInfoManager) SyncClusterCloudInfo(cls *cmproto.Cluster, opt *cloudprovider.SyncClusterCloudInfoOption) error {
return cloudprovider.ErrCloudNotImplemented
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ package eop

import (
"fmt"
"sync"

"github.com/Tencent/bk-bcs/bcs-common/common/blog"
cmproto "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/api/clustermanager"
"github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/cloudprovider"
"sync"
)

var clsMgr sync.Once
Expand Down
Loading

0 comments on commit 86131e0

Please sign in to comment.