diff --git a/charts/region/Chart.yaml b/charts/region/Chart.yaml index 53791d0..c99fd3e 100644 --- a/charts/region/Chart.yaml +++ b/charts/region/Chart.yaml @@ -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 diff --git a/pkg/providers/openstack/compute.go b/pkg/providers/openstack/compute.go index e508bb0..3f5a709 100644 --- a/pkg/providers/openstack/compute.go +++ b/pkg/providers/openstack/compute.go @@ -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" @@ -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 := "asets.UpdateOpts{ + Cores: &all, + RAM: &all, + } + + return quotasets.Update(ctx, c.client, projectID, opts).Err +} diff --git a/pkg/providers/openstack/provider.go b/pkg/providers/openstack/provider.go index 62da9e3..74b49b7 100644 --- a/pkg/providers/openstack/provider.go +++ b/pkg/providers/openstack/provider.go @@ -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 @@ -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.