Skip to content

Commit

Permalink
Merge pull request #204 from openinfradev/main
Browse files Browse the repository at this point in the history
231113 main to develop back merge ( v3.1.2 )
  • Loading branch information
ktkfree authored Nov 13, 2023
2 parents 98abc83 + b9462b4 commit 9fbf5b0
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 8 deletions.
3 changes: 3 additions & 0 deletions internal/mail/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func (s *SmtpMailer) SendMail() error {
s.client.SetBody("text/html", s.message.Body)

d := gomail.NewDialer(s.Host, s.Port, s.Username, s.Password)
if s.Port == 25 || s.Port == 587 || s.Port == 2587 {
d.SSL = false
}

if err := d.DialAndSend(s.client); err != nil {
log.Errorf("failed to send email, %v", err)
Expand Down
2 changes: 1 addition & 1 deletion internal/repository/stack-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *StackTemplateRepository) Fetch(pg *pagination.Pagination) (out []domain

pg.TotalPages = int(math.Ceil(float64(pg.TotalRows) / float64(pg.Limit)))
orderQuery := fmt.Sprintf("%s %s", pg.SortColumn, pg.SortOrder)
res := db.Offset(pg.GetOffset()).Limit(pg.GetLimit()).Order(orderQuery).Find(&stackTemplates)
res := db.Offset(pg.GetOffset()).Limit(pg.GetLimit()).Order("kube_type DESC,template_type ASC").Order(orderQuery).Find(&stackTemplates)
if res.Error != nil {
return nil, res.Error
}
Expand Down
5 changes: 5 additions & 0 deletions internal/usecase/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ func (u *ClusterUsecase) GetClusterSiteValues(ctx context.Context, clusterId dom
log.ErrorWithContext(ctx, err)
}

if cluster.StackTemplate.CloudService == "AWS" && cluster.StackTemplate.KubeType == "AWS" {
out.TksUserNode = cluster.Conf.TksUserNode / domain.MAX_AZ_NUM
out.TksUserNodeMax = cluster.Conf.TksUserNodeMax / domain.MAX_AZ_NUM
}

if err := serializer.Map(cluster, &out); err != nil {
log.ErrorWithContext(ctx, err)
}
Expand Down
16 changes: 16 additions & 0 deletions internal/usecase/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ func (u *StackUsecase) Create(ctx context.Context, dto domain.Stack) (stackId do
if stackConf.TksCpNode == 0 {
stackConf.TksCpNode = 3
stackConf.TksCpNodeMax = 3
stackConf.TksInfraNode = 3
stackConf.TksInfraNodeMax = 3
}

// user 노드는 MAX_AZ_NUM의 배수로 요청한다.
if stackConf.TksUserNode%domain.MAX_AZ_NUM != 0 {
return "", httpErrors.NewInternalServerError(errors.Wrap(err, "Invalid node count"), "", "")
}
}

Expand Down Expand Up @@ -234,11 +240,21 @@ func (u *StackUsecase) Get(ctx context.Context, stackId domain.StackId) (out dom
return out, err
}

stackResources, _ := u.dashbordUsecase.GetStacks(ctx, cluster.OrganizationId)
out = reflectClusterToStack(cluster, appGroups)

if organization.PrimaryClusterId == cluster.ID.String() {
out.PrimaryCluster = true
}

for _, resource := range stackResources {
if resource.ID == domain.StackId(cluster.ID) {
if err := serializer.Map(resource, &out.Resource); err != nil {
log.Error(err)
}
}
}

appGroupsInPrimaryCluster, err := u.appGroupRepo.Fetch(domain.ClusterId(organization.PrimaryClusterId), nil)
if err != nil {
return out, err
Expand Down
1 change: 1 addition & 0 deletions pkg/domain/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
const NODE_TYPE_TKS_CP_NODE = "TKS_CP_NODE"
const NODE_TYPE_TKS_INFRA_NODE = "TKS_INFRA_NODE"
const NODE_TYPE_TKS_USER_NODE = "TKS_USER_NODE"
const MAX_AZ_NUM = 3

type ClusterId string

Expand Down
10 changes: 5 additions & 5 deletions pkg/domain/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ func (m StackStatus) FromString(s string) StackStatus {
return StackStatus_PENDING
}

const MAX_STEP_CLUSTER_CREATE = 15
const MAX_STEP_CLUSTER_REMOVE = 11
const MAX_STEP_LMA_CREATE_PRIMARY = 42
const MAX_STEP_LMA_CREATE_MEMBER = 27
const MAX_STEP_LMA_REMOVE = 11
const MAX_STEP_CLUSTER_CREATE = 24
const MAX_STEP_CLUSTER_REMOVE = 14
const MAX_STEP_LMA_CREATE_PRIMARY = 39
const MAX_STEP_LMA_CREATE_MEMBER = 29
const MAX_STEP_LMA_REMOVE = 12
const MAX_STEP_SM_CREATE = 22
const MAX_STEP_SM_REMOVE = 4

Expand Down
8 changes: 6 additions & 2 deletions scripts/init_postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ values ( '5678bf11-256f-4d2c-a673-f2fedb82de5b', 'master', 'BYOH Standard', 'inc
insert into stack_templates ( id, organization_id, name, description, version, cloud_service, platform, template, template_type, kube_version, kube_type, created_at, updated_at, services )
values ( '92f5e5ce-7ffd-4c3e-aff6-9b7fb03dd881', 'master', 'BYOH MSA Standard', 'included LMA, SERVICE MESH', 'v1', 'AWS', 'x86', 'eks-msa-reference', 'MSA', 'v1.25', 'AWS', now(), now(), '[{"name":"Logging,Monitoring,Alerting","type":"LMA","applications":[{"name":"thanos","version":"0.30.2","description":"다중클러스터의 모니터링 데이터 통합 질의처리"},{"name":"prometheus-stack","version":"v0.66.0","description":"모니터링 데이터 수집/저장 및 질의처리"},{"name":"alertmanager","version":"v0.25.0","description":"알람 처리를 위한 노티피케이션 서비스"},{"name":"loki","version":"2.6.1","description":"로그데이터 저장 및 질의처리"},{"name":"grafana","version":"8.3.3","description":"모니터링/로그 통합대시보드"}]},{"name":"MSA","type":"SERVICE_MESH","applications":[{"name":"istio","version":"v1.17.2","description":"MSA 플랫폼"},{"name":"jagger","version":"1.35.0","description":"분산 서비스간 트랜잭션 추적을 위한 플랫폼"},{"name":"kiali","version":"v1.63.0","description":"MSA 구조 및 성능을 볼 수 있는 Dashboard"},{"name":"k8ssandra","version":"1.6.0","description":"분산 서비스간 호출 로그를 저장하는 스토리지"}]}]' );

# BTV
insert into stack_templates ( id, organization_id, name, description, version, cloud_service, platform, template, template_type, kube_version, kube_type, created_at, updated_at, services )
values ( 'f4c74dec-3444-481b-9597-bacb7596e7e7', 'master', 'BYOH MSA Standard (BTV STG)', 'included LMA', 'v1', 'BYOH', 'x86', 'byoh-stage-reference', 'MSA', 'v1.25', 'BYOH', now(), now(), '[{"name":"Logging,Monitoring,Alerting","type":"LMA","applications":[{"name":"thanos","version":"0.30.2","description":"다중클러스터의 모니터링 데이터 통합 질의처리"},{"name":"prometheus-stack","version":"v0.66.0","description":"모니터링 데이터 수집/저장 및 질의처리"},{"name":"alertmanager","version":"v0.25.0","description":"알람 처리를 위한 노티피케이션 서비스"},{"name":"loki","version":"2.6.1","description":"로그데이터 저장 및 질의처리"},{"name":"grafana","version":"8.3.3","description":"모니터링/로그 통합대시보드"}]}]' );

values ( '2526ec49-28a2-4be9-8d18-2c39fc0993fd', 'master', 'BYOH Admin Standard (BTV)', 'included LMA', 'v1', 'BYOH', 'x86', 'tks-admin', 'STANDARD', 'v1.25', 'BYOH', now(), now(), '[{"name":"Logging,Monitoring,Alerting","type":"LMA","applications":[{"name":"thanos","version":"0.30.2","description":"다중클러스터의 모니터링 데이터 통합 질의처리"},{"name":"prometheus-stack","version":"v0.66.0","description":"모니터링 데이터 수집/저장 및 질의처리"},{"name":"alertmanager","version":"v0.25.0","description":"알람 처리를 위한 노티피케이션 서비스"},{"name":"loki","version":"2.6.1","description":"로그데이터 저장 및 질의처리"},{"name":"grafana","version":"8.3.3","description":"모니터링/로그 통합대시보드"}]}]' );
insert into stack_templates ( id, organization_id, name, description, version, cloud_service, platform, template, template_type, kube_version, kube_type, created_at, updated_at, services )
values ( 'a76b5c97-7d55-46d8-9248-9952bfaff62c', 'master', 'BYOH Standard (BTV SSU)', 'included LMA', 'v1', 'BYOH', 'x86', 'byoh-ssu-reference', 'MSA', 'v1.25', 'BYOH', now(), now(), '[{"name":"Logging,Monitoring,Alerting","type":"LMA","applications":[{"name":"thanos","version":"0.30.2","description":"다중클러스터의 모니터링 데이터 통합 질의처리"},{"name":"prometheus-stack","version":"v0.66.0","description":"모니터링 데이터 수집/저장 및 질의처리"},{"name":"alertmanager","version":"v0.25.0","description":"알람 처리를 위한 노티피케이션 서비스"},{"name":"loki","version":"2.6.1","description":"로그데이터 저장 및 질의처리"},{"name":"grafana","version":"8.3.3","description":"모니터링/로그 통합대시보드"}]}]' );
insert into stack_templates ( id, organization_id, name, description, version, cloud_service, platform, template, template_type, kube_version, kube_type, created_at, updated_at, services )
values ( 'b5bbd6ea-5bf3-4d88-bb06-4a4c64c73c15', 'master', 'BYOH Standard (BTV SUY)', 'included LMA', 'v1', 'BYOH', 'x86', 'byoh-suy-reference', 'MSA', 'v1.25', 'BYOH', now(), now(), '[{"name":"Logging,Monitoring,Alerting","type":"LMA","applications":[{"name":"thanos","version":"0.30.2","description":"다중클러스터의 모니터링 데이터 통합 질의처리"},{"name":"prometheus-stack","version":"v0.66.0","description":"모니터링 데이터 수집/저장 및 질의처리"},{"name":"alertmanager","version":"v0.25.0","description":"알람 처리를 위한 노티피케이션 서비스"},{"name":"loki","version":"2.6.1","description":"로그데이터 저장 및 질의처리"},{"name":"grafana","version":"8.3.3","description":"모니터링/로그 통합대시보드"}]}]' );

0 comments on commit 9fbf5b0

Please sign in to comment.