Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aws:cluster] apply to convert csp's status to own status #1323

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ type AwsClusterHandler struct {

const (
NODEGROUP_TAG string = "nodegroup"

clusterStatusCreating = "CREATING"
clusterStatusActive = "ACTIVE"
clusterStatusDeleting = "DELETING"
clusterStatusFailed = "FAILED"
clusterStatusUpdating = "UPDATING"
clusterStatusPending = "PENDING"

nodeGroupStatusCreating = "CREATING"
nodeGroupStatusActive = "ACTIVE"
nodeGroupStatusUpdating = "UPDATING"
nodeGroupStatusDeleting = "DELETING"
nodeGroupStatusCreateFailed = "CREATE_FAILED"
nodeGroupStatusDeleteFailed = "DELETE_FAILED"
nodeGroupStatusDegraded = "DEGRADED"
)

//------ Cluster Management
Expand Down Expand Up @@ -341,7 +356,7 @@ func (ClusterHandler *AwsClusterHandler) GetCluster(clusterIID irs.IID) (irs.Clu
IId: irs.IID{NameId: "", SystemId: *result.Cluster.Name},
Version: *result.Cluster.Version,
CreatedTime: *result.Cluster.CreatedAt,
Status: irs.ClusterStatus(*result.Cluster.Status),
Status: convertClusterStatusToClusterInfoStatus(aws.StringValue(result.Cluster.Status)),
//AccessInfo: irs.AccessInfo{Endpoint: *result.Cluster.Endpoint},
AccessInfo: irs.AccessInfo{},
}
Expand Down Expand Up @@ -917,7 +932,7 @@ func (NodeGroupHandler *AwsClusterHandler) convertNodeGroup(nodeGroupOutput *eks

//subnetList := nodeGroup.Subnets
//nodeGroupStatus := nodeGroup.Status
nodeGroupInfo.Status = irs.NodeGroupStatus(*nodeGroup.Status)
nodeGroupInfo.Status = convertNodeGroupStatusToNodeGroupInfoStatus(aws.StringValue(nodeGroup.Status))
instanceTypeList := nodeGroup.InstanceTypes // spec

//nodes := nodeGroup.Health.Issues[0].ResourceIds // 문제 있는 node들만 있는것이 아닌지..
Expand Down Expand Up @@ -1059,3 +1074,43 @@ func (NodeGroupHandler *AwsClusterHandler) convertNodeGroup(nodeGroupOutput *eks
//return irs.NodeGroupInfo{}, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "추출 오류", nil)
return nodeGroupInfo, nil
}

func convertNodeGroupStatusToNodeGroupInfoStatus(nodeGroupStatus string) irs.NodeGroupStatus {
status := irs.NodeGroupInactive
if strings.EqualFold(nodeGroupStatus, nodeGroupStatusCreating) {
status = irs.NodeGroupCreating
} else if strings.EqualFold(nodeGroupStatus, nodeGroupStatusUpdating) {
status = irs.NodeGroupUpdating
} else if strings.EqualFold(nodeGroupStatus, nodeGroupStatusCreateFailed) {
status = irs.NodeGroupInactive
} else if strings.EqualFold(nodeGroupStatus, nodeGroupStatusDeleteFailed) {
status = irs.NodeGroupInactive
} else if strings.EqualFold(nodeGroupStatus, nodeGroupStatusDegraded) {
status = irs.NodeGroupInactive
} else if strings.EqualFold(nodeGroupStatus, nodeGroupStatusDeleting) {
status = irs.NodeGroupDeleting
} else if strings.EqualFold(nodeGroupStatus, nodeGroupStatusActive) {
status = irs.NodeGroupActive
}

return status
}

func convertClusterStatusToClusterInfoStatus(clusterStatus string) irs.ClusterStatus {
status := irs.ClusterInactive
if strings.EqualFold(clusterStatus, clusterStatusCreating) {
status = irs.ClusterCreating
} else if strings.EqualFold(clusterStatus, clusterStatusUpdating) {
status = irs.ClusterUpdating
} else if strings.EqualFold(clusterStatus, clusterStatusFailed) {
status = irs.ClusterInactive
} else if strings.EqualFold(clusterStatus, clusterStatusPending) {
status = irs.ClusterInactive
} else if strings.EqualFold(clusterStatus, clusterStatusDeleting) {
status = irs.ClusterDeleting
} else if strings.EqualFold(clusterStatus, clusterStatusActive) {
status = irs.ClusterActive
}

return status
}