Skip to content

Commit

Permalink
Merge 95a5d94 into 46853ba
Browse files Browse the repository at this point in the history
  • Loading branch information
knight42 committed Dec 21, 2020
2 parents 46853ba + 95a5d94 commit b9f7190
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
5 changes: 3 additions & 2 deletions manifests/cyclone/templates/server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ spec:
path: /etc/localtime
type: File
- name: cyclone-data
persistentVolumeClaim:
claimName: cyclone-server-cyclone-data
emptyDir: {}
#persistentVolumeClaim:
# claimName: cyclone-server-cyclone-data

---
kind: Service
Expand Down
13 changes: 6 additions & 7 deletions pkg/server/common/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,32 @@ 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
}

_, err = client.CoreV1().ResourceQuotas(nsname).Create(context.TODO(), quota, meta_v1.CreateOptions{})
if err != nil {
log.Errorf("Create ResourceQuota for tenant %s error %v", tenant.Name, err)
log.Errorf("Create ResourceQuota for tenant %s error %v", nsname, err)
return err
}

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)
quota := &core_v1.ResourceQuota{
ObjectMeta: meta_v1.ObjectMeta{
Name: quotaName,
Name: namespace,
},
Spec: core_v1.ResourceQuotaSpec{
Hard: rl,
Expand All @@ -104,9 +103,9 @@ 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(), nsname, meta_v1.GetOptions{})
if err != nil {
log.Errorf("Get ResourceQuota for tenant %s error %v", tenant.Name, err)
log.Errorf("Get ResourceQuota for tenant %s error %v", nsname, err)
return err
}

Expand Down

0 comments on commit b9f7190

Please sign in to comment.