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

bugfix. fix error handling #353

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
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
23 changes: 13 additions & 10 deletions internal/keycloak/keycloak.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"crypto/tls"
"fmt"

"github.com/spf13/viper"

"time"
Expand Down Expand Up @@ -484,16 +483,20 @@ func (k *Keycloak) EnsureClientRoleWithClientName(ctx context.Context, organizat
Name: gocloak.StringP(roleName),
}

r, err := k.client.GetClientRole(context.Background(), token.AccessToken, organizationId, *targetClient.ID, roleName)
_, err = k.client.GetClientRole(context.Background(), token.AccessToken, organizationId, *targetClient.ID, roleName)
if err != nil {
log.Error(ctx, "Getting Client Role is failed", err)
return err
}

if r == nil {
_, err = k.client.CreateClientRole(context.Background(), token.AccessToken, organizationId, *targetClient.ID, role)
if err != nil {
log.Error(ctx, "Creating Client Role is failed", err)
if apiErr, ok := err.(*gocloak.APIError); ok {
if apiErr.Code == 404 {
_, err = k.client.CreateClientRole(context.Background(), token.AccessToken, organizationId, *targetClient.ID, role)
if err != nil {
log.Error(ctx, "Creating Client Role is failed", err)
return err
}
return nil
} else {
return err
}
} else {
return err
}
}
Expand Down
15 changes: 1 addition & 14 deletions internal/usecase/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,25 +444,12 @@ func (u *ProjectUsecase) GetAppCount(ctx context.Context, organizationId string,
}

func (u *ProjectUsecase) EnsureRequiredSetupForCluster(ctx context.Context, organizationId string, projectId string, stackId string) error {
pns, err := u.projectRepo.GetProjectNamespaces(ctx, organizationId, projectId, nil)
_, err := u.projectRepo.GetProjectNamespaces(ctx, organizationId, projectId, nil)
if err != nil {
log.Error(ctx, err)
return errors.Wrap(err, "Failed to get project namespace in database.")
}

var alreadySetUp bool
for _, pn := range pns {
if pn.StackId == stackId {
alreadySetUp = true
break
}
}

// if already set up, it means that required setup is already done
if alreadySetUp {
return nil
}

if err := u.createK8SInitialResource(ctx, organizationId, projectId, stackId); err != nil {
log.Error(ctx, err)
return err
Expand Down
4 changes: 2 additions & 2 deletions internal/usecase/system-notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ func (u *SystemNotificationUsecase) makeGrafanaUrl(ctx context.Context, primaryC
}
}

// check type
url = primaryGrafanaEndpoint
//// check type
//url = primaryGrafanaEndpoint
Copy link
Contributor Author

@cho4036 cho4036 Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ktkfree 님, 해당 라인 lint 에러 나서 주석처리 했습니다.


// tks_node_dashboard/tks-kubernetes-view-nodes?orgId=1&refresh=30s&var-datasource=default&var-taco_cluster=c19rjkn4j&var-job=prometheus-node-exporter&var-hostname=All&var-node=10.0.168.71:9100&var-device=All&var-maxmount=%2F&var-show_hostname=prometheus-node-exporter-xt4vb

Expand Down
Loading