Skip to content

Commit

Permalink
Update Compute Quota Defaults (#56)
Browse files Browse the repository at this point in the history
Cores and RAM are all good, but you also need instances to be set to
allow large cluster sizes.
  • Loading branch information
spjmurray authored Sep 3, 2024
1 parent 61180cc commit 09197d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions charts/region/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: A Helm chart for deploying Unikorn's Region Controller

type: application

version: v0.1.38
appVersion: v0.1.38
version: v0.1.39
appVersion: v0.1.39

icon: https://raw.githubusercontent.com/unikorn-cloud/assets/main/images/logos/dark-on-light/icon.png

Expand Down
11 changes: 6 additions & 5 deletions pkg/providers/openstack/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"

"github.com/unikorn-cloud/core/pkg/util"
"github.com/unikorn-cloud/core/pkg/util/cache"
unikornv1 "github.com/unikorn-cloud/region/pkg/apis/unikorn/v1alpha1"
"github.com/unikorn-cloud/region/pkg/constants"
Expand Down Expand Up @@ -258,17 +259,17 @@ func (c *ComputeClient) DeleteServerGroup(ctx context.Context, id string) error
return servergroups.Delete(ctx, c.client, id).ExtractErr()
}

func (c *ComputeClient) TweakQuotas(ctx context.Context, projectID string) error {
func (c *ComputeClient) UpdateQuotas(ctx context.Context, projectID string) error {
tracer := otel.GetTracerProvider().Tracer(constants.Application)

_, span := tracer.Start(ctx, "PUT /compute/v2/os-quota-sets")
defer span.End()

all := -1

opts := &quotasets.UpdateOpts{
Cores: &all,
RAM: &all,
// TODO: instances, cores and ram need to be driven by client input.
Instances: util.ToPointer(-1),
Cores: util.ToPointer(-1),
RAM: util.ToPointer(-1),
}

return quotasets.Update(ctx, c.client, projectID, opts).Err
Expand Down
6 changes: 5 additions & 1 deletion pkg/providers/openstack/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,11 @@ func (p *Provider) provisionQuotas(ctx context.Context, identity *unikornv1.Open
return err
}

return compute.TweakQuotas(ctx, *identity.Spec.ProjectID)
if err := compute.UpdateQuotas(ctx, *identity.Spec.ProjectID); err != nil {
return err
}

return nil
}

func (p *Provider) createClientConfig(identity *unikornv1.OpenstackIdentity) error {
Expand Down

0 comments on commit 09197d3

Please sign in to comment.