Skip to content

Commit

Permalink
refactor(cluster): update the name of resourceQuota to the name of it…
Browse files Browse the repository at this point in the history
…s namespace
  • Loading branch information
Jian Zeng committed Dec 21, 2020
1 parent d096a55 commit 7415bd3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/server/biz/integration/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func Close(in *api.Integration, tenant string) (err error) {
}

// delete resource quota
quotaName := svrcommon.TenantResourceQuota(tenant)
quotaName := svrcommon.TenantResourceQuota(cluster.Namespace)
err = clusterClient.CoreV1().ResourceQuotas(cluster.Namespace).Delete(context.TODO(), quotaName, meta_v1.DeleteOptions{})
if err != nil {
if strings.Contains(err.Error(), "dial tcp") && strings.Contains(err.Error(), "connect: connection refused") {
Expand Down
8 changes: 4 additions & 4 deletions pkg/server/common/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func CreateResourceQuota(tenant *api.Tenant, namespace string, client *kubernete
nsname = namespace
}

quota, err := buildResourceQuota(tenant)
quota, err := buildResourceQuota(tenant, nsname)
if err != nil {
log.Warningf("Build resource quota for tenant %s error %v", tenant.Name, err)
return err
Expand All @@ -67,15 +67,15 @@ func CreateResourceQuota(tenant *api.Tenant, namespace string, client *kubernete
return nil
}

func buildResourceQuota(tenant *api.Tenant) (*core_v1.ResourceQuota, error) {
func buildResourceQuota(tenant *api.Tenant, namespace string) (*core_v1.ResourceQuota, error) {
// parse resource list
rl, err := ParseResourceList(tenant.Spec.ResourceQuota)
if err != nil {
log.Warningf("Parse resource quota for tenant %s error %v", tenant.Name, err)
return nil, err
}

quotaName := TenantResourceQuota(tenant.Name)
quotaName := TenantResourceQuota(namespace)
quota := &core_v1.ResourceQuota{
ObjectMeta: meta_v1.ObjectMeta{
Name: quotaName,
Expand Down Expand Up @@ -104,7 +104,7 @@ func UpdateResourceQuota(tenant *api.Tenant, namespace string, client *kubernete

return retry.RetryOnConflict(retry.DefaultRetry, func() error {
quota, err := client.CoreV1().ResourceQuotas(nsname).Get(
context.TODO(), TenantResourceQuota(tenant.Name), meta_v1.GetOptions{})
context.TODO(), TenantResourceQuota(nsname), meta_v1.GetOptions{})
if err != nil {
log.Errorf("Get ResourceQuota for tenant %s error %v", tenant.Name, err)
return err
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ func TenantPVC(tenant string) string {
}

// TenantResourceQuota returns resource quota name related the tenant
func TenantResourceQuota(tenant string) string {
return tenant
func TenantResourceQuota(namespace string) string {
return namespace
}

0 comments on commit 7415bd3

Please sign in to comment.