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

241015 main from release ( v3.2.1 ) #47

Merged
merged 37 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1864618
Merge pull request #28 from openinfradev/main
ktkfree Nov 13, 2023
314f7b1
feature. implementation applying systemNotificationRule
ktkfree Apr 4, 2024
45179c9
trivial. remove test code
ktkfree Apr 4, 2024
ab10b3b
trivial. resolve build error
ktkfree Apr 4, 2024
c54204c
feature. delete thanos-ruler pod when appling configmap
ktkfree Apr 4, 2024
f487860
Merge pull request #30 from openinfradev/alert
seungkyua Apr 8, 2024
6007e14
feature. add attribute type & id to systemNotification
ktkfree Apr 11, 2024
bb66cf1
Merge pull request #31 from openinfradev/alert
ktkfree Apr 11, 2024
93edb22
trivial. bugfix. change scheme to yaml from json
ktkfree Apr 11, 2024
40e5920
Merge pull request #32 from openinfradev/alert
ktkfree Apr 11, 2024
0fa2d5f
feature. seperate thanos-ruler-configmap file
ktkfree Apr 15, 2024
2a66801
Merge pull request #33 from openinfradev/snr_ruler_user
intelliguy Apr 15, 2024
8408adf
trivial. change ruler filename
ktkfree Apr 18, 2024
7375c83
Merge pull request #34 from openinfradev/fix_snr
ktkfree Apr 18, 2024
18aa85d
feature. fix check logic.
ktkfree Apr 24, 2024
9324332
Merge pull request #35 from openinfradev/fix_snr
ktkfree Apr 24, 2024
ca72921
feature. approve buz-logix for systemNotificationRules
ktkfree Apr 24, 2024
967c563
Merge pull request #36 from openinfradev/fix_snr
ktkfree Apr 24, 2024
4dfcd23
feature. change apply rule logic to reload
ktkfree Apr 25, 2024
ae1571f
feature. add cache feature
ktkfree Apr 26, 2024
9b057db
Merge pull request #37 from openinfradev/fix_snr
intelliguy Apr 26, 2024
ed3e967
feature. add policyName, policyTemplateName to policyNotifications
ktkfree May 9, 2024
12f028f
Merge pull request #38 from openinfradev/fix_snr
ktkfree May 9, 2024
0de2f89
trivial. add omitempty
ktkfree May 9, 2024
192acff
Merge pull request #39 from openinfradev/fix_snr
ktkfree May 9, 2024
a6d0d2f
trivial. update go.mod
ktkfree May 9, 2024
f538630
Merge pull request #40 from openinfradev/minor_fix
ktkfree May 9, 2024
b7917e7
Merge pull request #41 from openinfradev/develop
ktkfree May 17, 2024
8df3be6
Merge pull request #42 from openinfradev/release
ktkfree Jun 4, 2024
88f9646
feature. implementation resume scenario when byoh cluster installing
ktkfree Jun 25, 2024
bc7a891
trivial. fix build error
ktkfree Jun 26, 2024
0f254e1
Merge pull request #43 from openinfradev/resume
ktkfree Jun 26, 2024
4116410
feature. update cluster status when workflow paused
ktkfree Jul 2, 2024
6b4da18
Merge pull request #44 from openinfradev/resume
ktkfree Jul 4, 2024
5275ca5
trivial. add condition for pause installing
ktkfree Jul 22, 2024
66aec14
Merge pull request #45 from openinfradev/byok
ktkfree Jul 22, 2024
0584c49
Merge pull request #46 from openinfradev/develop
ktkfree Oct 2, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand Down
50 changes: 25 additions & 25 deletions .github/workflows/golangcic-lint.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
name: Lint
on:
push:
tags:
- v*
branches:
- main
- develop
- release
pull_request:

branches:
- main
- develop
- release
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
args: --timeout=5m

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
go-version: "1.21"
cache: false
- name: Install golangci-lint
# Install golangci-lint from source instead of using
# golangci-lint-action to ensure the golangci-lint binary is built with
# the same Go version we're targeting.
# Avoids incompatibility issues such as:
# - https://github.com/golangci/golangci-lint/issues/2922
# - https://github.com/golangci/golangci-lint/issues/2673
# - https://github.com/golangci/golangci-lint-action/issues/442
run: go install github.com/golangci/golangci-lint/cmd/[email protected]
- name: Run golangci-lint
run: golangci-lint run --verbose --out-format=github-actions
4 changes: 3 additions & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ jobs:
steps:
- name: Check out repository code
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.21

- name: Test
run: go test -v -cover ./...
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

# Dependency directories (remove the comment below to include it)
# vendor/

cmd/server/server
cmd/server/start_dev.sh
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 docker.io/library/golang:1.18-buster AS builder
FROM --platform=linux/amd64 docker.io/library/golang:1.21 AS builder

RUN mkdir -p /app
WORKDIR /app
Expand Down
13 changes: 7 additions & 6 deletions cmd/server/appgroup_status.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"fmt"

"github.com/openinfradev/tks-api/pkg/domain"
Expand All @@ -17,7 +18,7 @@ func processAppGroupStatus() error {
if len(appGroups) == 0 {
return nil
}
log.Info("appGroups : ", appGroups)
log.Info(context.TODO(), "[processAppGroupStatus] appGroups : ", appGroups)

for i := range appGroups {
appGroup := appGroups[i]
Expand All @@ -32,13 +33,13 @@ func processAppGroupStatus() error {
var newMessage string

if workflowId != "" {
workflow, err := argowfClient.GetWorkflow("argo", workflowId)
workflow, err := argowfClient.GetWorkflow(context.TODO(), "argo", workflowId)
if err != nil {
log.Error("failed to get argo workflow. err : ", err)
log.Error(context.TODO(), "failed to get argo workflow. err : ", err)
continue
}
newMessage = fmt.Sprintf("(%s) %s", workflow.Status.Progress, workflow.Status.Message)
log.Debug(fmt.Sprintf("status [%s], newMessage [%s], phase [%s]", status, newMessage, workflow.Status.Phase))
log.Debug(context.TODO(), fmt.Sprintf("status [%s], newMessage [%s], phase [%s]", status, newMessage, workflow.Status.Phase))
if status == domain.AppGroupStatus_INSTALLING {
switch workflow.Status.Phase {
case "Running":
Expand Down Expand Up @@ -70,10 +71,10 @@ func processAppGroupStatus() error {
}

if status != newStatus || statusDesc != newMessage {
log.Debug(fmt.Sprintf("update status!! appGroupId [%s], newStatus [%s], newMessage [%s]", appGroupId, newStatus, newMessage))
log.Debug(context.TODO(), fmt.Sprintf("update status!! appGroupId [%s], newStatus [%s], newMessage [%s]", appGroupId, newStatus, newMessage))
err := applicationAccessor.UpdateAppGroupStatus(appGroupId, newStatus, newMessage, workflowId)
if err != nil {
log.Error("Failed to update appgroup status err : ", err)
log.Error(context.TODO(), "Failed to update appgroup status err : ", err)
continue
}
}
Expand Down
15 changes: 8 additions & 7 deletions cmd/server/cloud_account_status.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"fmt"

"github.com/openinfradev/tks-api/pkg/domain"
Expand All @@ -16,7 +17,7 @@ func processCloudAccountStatus() error {
if len(cloudAccounts) == 0 {
return nil
}
log.Info("cloudAccounts : ", cloudAccounts)
log.Info(context.TODO(), "[processCloudAccountStatus] cloudAccounts : ", cloudAccounts)

for i := range cloudAccounts {
cloudaccount := cloudAccounts[i]
Expand All @@ -31,14 +32,14 @@ func processCloudAccountStatus() error {
var newMessage string

if workflowId != "" {
workflow, err := argowfClient.GetWorkflow("argo", workflowId)
workflow, err := argowfClient.GetWorkflow(context.TODO(), "argo", workflowId)
if err != nil {
log.Error("failed to get argo workflow. err : ", err)
log.Error(context.TODO(), "failed to get argo workflow. err : ", err)
continue
}

newMessage = fmt.Sprintf("(%s) %s", workflow.Status.Progress, workflow.Status.Message)
log.Debug(fmt.Sprintf("status [%s], newMessage [%s], phase [%s]", status, newMessage, workflow.Status.Phase))
log.Debug(context.TODO(), fmt.Sprintf("status [%s], newMessage [%s], phase [%s]", status, newMessage, workflow.Status.Phase))

if status == domain.CloudAccountStatus_CREATING {
switch workflow.Status.Phase {
Expand Down Expand Up @@ -71,17 +72,17 @@ func processCloudAccountStatus() error {
}

if status != newStatus || statusDesc != newMessage {
log.Debug(fmt.Sprintf("update status!! cloudAccountId [%s], newStatus [%s], newMessage [%s]", cloudAccountId, newStatus, newMessage))
log.Debug(context.TODO(), fmt.Sprintf("update status!! cloudAccountId [%s], newStatus [%s], newMessage [%s]", cloudAccountId, newStatus, newMessage))
err := cloudAccountAccessor.UpdateCloudAccountStatus(cloudAccountId, newStatus, newMessage, workflowId)
if err != nil {
log.Error("Failed to update cloudaccount status err : ", err)
log.Error(context.TODO(), "Failed to update cloudaccount status err : ", err)
continue
}

if newStatus == domain.CloudAccountStatus_CREATED {
err = cloudAccountAccessor.UpdateCreatedIAM(cloudAccountId, true)
if err != nil {
log.Error("Failed to update cloudaccount createdIAM err : ", err)
log.Error(context.TODO(), "Failed to update cloudaccount createdIAM err : ", err)
continue
}

Expand Down
22 changes: 10 additions & 12 deletions cmd/server/cluster_byoh.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bytes"
"context"
"encoding/json"
"fmt"

Expand All @@ -21,7 +22,7 @@ func processClusterByoh() error {
if len(clusters) == 0 {
return nil
}
log.Info("byoh clusters : ", clusters)
log.Info(context.TODO(), "[processClusterByoh] byoh clusters : ", clusters)

token = getTksApiToken()
if token != "" {
Expand All @@ -34,7 +35,7 @@ func processClusterByoh() error {
url := fmt.Sprintf("clusters/%s/nodes", clusterId)
body, err := apiClient.Get(url)
if err != nil {
log.Error(err)
log.Error(context.TODO(), err)
continue
}

Expand All @@ -47,25 +48,25 @@ func processClusterByoh() error {
completed = false
}
}
log.Info(out.Nodes)
log.Info(context.TODO(), out.Nodes)

//completed = true // FOR TEST
if completed {
log.Info(fmt.Sprintf("all agents registered! starting stack creation. clusterId %s", clusterId))
log.Info(context.TODO(), fmt.Sprintf("all agents registered! starting stack creation. clusterId %s", clusterId))
// clusterId, newStatus, newMessage, workflowId
if err = clusterAccessor.UpdateClusterStatus(clusterId, domain.ClusterStatus_INSTALLING, "", ""); err != nil {
log.Error("Failed to update cluster status err : ", err)
log.Error(context.TODO(), "Failed to update cluster status err : ", err)
continue
}

if cluster.IsStack {
if _, err = apiClient.Post(fmt.Sprintf("organizations/%s/stacks/%s/install", cluster.OrganizationId, clusterId), nil); err != nil {
log.Error(err)
log.Error(context.TODO(), err)
continue
}
} else {
if _, err = apiClient.Post("clusters/"+clusterId+"/install", nil); err != nil {
log.Error(err)
log.Error(context.TODO(), err)
continue
}
}
Expand All @@ -88,10 +89,7 @@ func transcode(in, out interface{}) {
}

func getTksApiToken() string {
_, err := apiClient.Post("auth/ping", domain.PingTokenRequest{
Token: token,
OrganizationId: "master",
})
_, err := apiClient.Get("auth/verify-token")
if err != nil {
body, err := apiClient.Post("auth/login", domain.LoginRequest{
AccountId: viper.GetString("tks-api-account"),
Expand All @@ -105,7 +103,7 @@ func getTksApiToken() string {
var out domain.LoginResponse
transcode(body, &out)

log.Info(out.User.Token)
log.Info(context.TODO(), out.User.Token)
token = out.User.Token
}

Expand Down
20 changes: 14 additions & 6 deletions cmd/server/cluster_status.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"fmt"

"github.com/openinfradev/tks-api/pkg/domain"
Expand All @@ -16,7 +17,7 @@ func processClusterStatus() error {
if len(clusters) == 0 {
return nil
}
log.Info("clusters : ", clusters)
log.Info(context.TODO(), "[processClusterStatus] clusters : ", clusters)

for i := range clusters {
cluster := clusters[i]
Expand All @@ -31,19 +32,26 @@ func processClusterStatus() error {
var newMessage string

if workflowId != "" {
workflow, err := argowfClient.GetWorkflow("argo", workflowId)
workflow, err := argowfClient.GetWorkflow(context.TODO(), "argo", workflowId)
if err != nil {
log.Error("failed to get argo workflow. err : ", err)
log.Error(context.TODO(), "failed to get argo workflow. err : ", err)
continue
}

newMessage = fmt.Sprintf("(%s) %s", workflow.Status.Progress, workflow.Status.Message)
log.Debug(fmt.Sprintf("status [%s], newMessage [%s], phase [%s]", status, newMessage, workflow.Status.Phase))
log.Debug(context.TODO(), fmt.Sprintf("status [%s], newMessage [%s], phase [%s]", status, newMessage, workflow.Status.Phase))

if status == domain.ClusterStatus_INSTALLING {
switch workflow.Status.Phase {
case "Running":
newStatus = domain.ClusterStatus_INSTALLING

paused, err := argowfClient.IsPausedWorkflow(context.TODO(), "argo", workflowId)
if err == nil && paused {
newStatus = domain.ClusterStatus_STOPPED
}
case "Stopped":
newStatus = domain.ClusterStatus_STOPPED
case "Succeeded":
newStatus = domain.ClusterStatus_RUNNING
case "Failed":
Expand Down Expand Up @@ -82,10 +90,10 @@ func processClusterStatus() error {
}

if status != newStatus || statusDesc != newMessage {
log.Debug(fmt.Sprintf("update status!! clusterId [%s], newStatus [%s], newMessage [%s]", clusterId, newStatus, newMessage))
log.Debug(context.TODO(), fmt.Sprintf("update status!! clusterId [%s], newStatus [%s], newMessage [%s]", clusterId, newStatus, newMessage))
err := clusterAccessor.UpdateClusterStatus(clusterId, newStatus, newMessage, workflowId)
if err != nil {
log.Error("Failed to update cluster status err : ", err)
log.Error(context.TODO(), "Failed to update cluster status err : ", err)
continue
}
}
Expand Down
Loading
Loading