Skip to content

Commit

Permalink
Fix Blockstorage Quotas (#61)
Browse files Browse the repository at this point in the history
Beacuse like anything openstack, smaller is better.  Like she never
said...
  • Loading branch information
spjmurray authored Oct 1, 2024
1 parent 3fc5d07 commit dbd69e5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 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.41
appVersion: v0.1.41
version: v0.1.42
appVersion: v0.1.42

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

Expand Down
16 changes: 16 additions & 0 deletions pkg/providers/openstack/blockstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import (
"github.com/gophercloud/gophercloud/v2"
"github.com/gophercloud/gophercloud/v2/openstack"
"github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/availabilityzones"
"github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/quotasets"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"

"github.com/unikorn-cloud/core/pkg/util"
"github.com/unikorn-cloud/region/pkg/constants"
)

Expand Down Expand Up @@ -84,3 +86,17 @@ func (c *BlockStorageClient) AvailabilityZones(ctx context.Context) ([]availabil

return filtered, nil
}

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

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

opts := &quotasets.UpdateOpts{
Volumes: util.ToPointer(-1),
Gigabytes: util.ToPointer(-1),
}

return quotasets.Update(ctx, c.client, projectID, opts).Err
}
9 changes: 9 additions & 0 deletions pkg/providers/openstack/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,19 @@ func (p *Provider) provisionQuotas(ctx context.Context, identity *unikornv1.Open
return err
}

blockstorage, err := NewBlockStorageClient(ctx, providerClient)
if err != nil {
return err
}

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

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

return nil
}

Expand Down

0 comments on commit dbd69e5

Please sign in to comment.