dynamic host volumes: CE side of quota tweaks (#24972)

* quota spec:
  if `region_limit.storage.host_volumes` is set,
  do not require that `variables` also be set,
  and vice versa.
* subtract from quota usage on volume delete
* stub CE quota subtraction method
This commit is contained in:
Daniel Bennett
2025-01-28 18:27:25 -05:00
committed by GitHub
parent 1b1ad896ec
commit dcf6201d2b
3 changed files with 11 additions and 0 deletions

View File

@@ -355,6 +355,8 @@ func parseQuotaMegabytes(raw any) (int, error) {
return int(b >> 20), nil
case int:
return val, nil
case nil:
return 0, nil
default:
return 0, fmt.Errorf("invalid type %T", raw)
}

View File

@@ -142,6 +142,11 @@ func (s *StateStore) DeleteHostVolume(index uint64, ns string, id string) error
}
}
err = s.subtractVolumeFromQuotaUsageTxn(txn, index, vol)
if err != nil {
return err
}
err = txn.Delete(TableHostVolumes, vol)
if err != nil {
return fmt.Errorf("host volume delete: %w", err)

View File

@@ -14,3 +14,7 @@ func (s *StateStore) EnforceHostVolumeQuota(_ *structs.HostVolume, _ *structs.Ho
func (s *StateStore) enforceHostVolumeQuotaTxn(_ Txn, _ uint64, _ *structs.HostVolume, _ *structs.HostVolume, _ bool) error {
return nil
}
func (s *StateStore) subtractVolumeFromQuotaUsageTxn(_ Txn, _ uint64, _ *structs.HostVolume) error {
return nil
}