Skip to content

Commit

Permalink
Hack Quotas (#54)
Browse files Browse the repository at this point in the history
This unblocks wider testing, I've got a less stupid approach in the
works, but there's a few points I need to mull over.
  • Loading branch information
spjmurray authored Aug 30, 2024
1 parent c84ca03 commit f0675b6
Show file tree
Hide file tree
Showing 3 changed files with 35 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.36
appVersion: v0.1.36
version: v0.1.37
appVersion: v0.1.37

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

Expand Down
17 changes: 17 additions & 0 deletions pkg/providers/openstack/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones"
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors"
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs"
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/quotasets"
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -256,3 +257,19 @@ 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 {
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,
}

return quotasets.Update(ctx, c.client, projectID, opts).Err
}
16 changes: 16 additions & 0 deletions pkg/providers/openstack/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,17 @@ func (p *Provider) provisionApplicationCredential(ctx context.Context, identity
return nil
}

func (p *Provider) provisionQuotas(ctx context.Context, identity *unikornv1.OpenstackIdentity) error {
providerClient := NewPasswordProvider(p.region.Spec.Openstack.Endpoint, p.credentials.userID, p.credentials.password, *identity.Spec.ProjectID)

compute, err := NewComputeClient(ctx, providerClient, p.region.Spec.Openstack.Compute)
if err != nil {
return err
}

return compute.TweakQuotas(ctx, *identity.Spec.ProjectID)
}

func (p *Provider) createClientConfig(identity *unikornv1.OpenstackIdentity) error {
if identity.Spec.Cloud != nil {
return nil
Expand Down Expand Up @@ -703,6 +714,11 @@ func (p *Provider) CreateIdentity(ctx context.Context, identity *unikornv1.Ident
return err
}

// Try set quotas...
if err := p.provisionQuotas(ctx, openstackIdentity); err != nil {
return err
}

// You MUST provision a new user, if we rotate a password, any application credentials
// hanging off it will stop working, i.e. doing that to the unikorn management user
// will be pretty catastrophic for all clusters in the region.
Expand Down

0 comments on commit f0675b6

Please sign in to comment.