Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per-pool project limits (from Incus) #14078

Merged
merged 11 commits into from
Sep 12, 2024
28 changes: 28 additions & 0 deletions lxd/api_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,34 @@ func projectValidateConfig(s *state.State, config map[string]string) error {
"restricted.snapshots": isEitherAllowOrBlock,
}

// Add the storage pool keys.
err := s.DB.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error {
var err error

// Load all the pools.
pools, err := tx.GetStoragePoolNames(ctx)
if err != nil {
return err
}

// Add the storage-pool specific config keys.
for _, poolName := range pools {
// lxdmeta:generate(entity=project, group=limits, key=limits.disk.pool.POOL_NAME)
MggMuggins marked this conversation as resolved.
Show resolved Hide resolved
// This value is the maximum value of the aggregate disk
// space used by all instance volumes, custom volumes, and images of the
// project on this specific storage pool.
// ---
// type: string
// shortdesc: Maximum disk space used by the project on this pool
projectConfigKeys[fmt.Sprintf("limits.disk.pool.%s", poolName)] = validate.Optional(validate.IsSize)
}

return nil
})
if err != nil {
return fmt.Errorf("Failed loading storage pool names: %w", err)
}

for k, v := range config {
key := k

Expand Down