fix(quota): 回收的服务器保留资源规格,认领时按集群里的真实规格过配额并写回缓存
This commit is contained in:
6 files changed
+171
-19
No files matched your search
@@ -79,12 +79,13 @@ func (s *PGStore) InsertBackup(ctx context.Context, rec BackupRecord) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// ReleaseWorld releases ownership, zeros the resource cache, and resets the
|
||||
// activity clock and warnings — without deleting the row (red line ②).
|
||||
// ReleaseWorld releases ownership and resets the activity clock and warnings —
|
||||
// without deleting the row (red line ②). The resource cache stays: the server
|
||||
// keeps its spec, an ownerless row is in nobody's quota sum, and the next claim is
|
||||
// gated on that size and counts it.
|
||||
func (s *PGStore) ReleaseWorld(ctx context.Context, name string, at time.Time) error {
|
||||
const q = `UPDATE servers
|
||||
SET owner_id = NULL, cached_cpu_milli = 0, cached_memory_mb = 0, cached_storage_mb = 0,
|
||||
last_active_at = $2, warned_3d_at = NULL, warned_1d_at = NULL
|
||||
SET owner_id = NULL, last_active_at = $2, warned_3d_at = NULL, warned_1d_at = NULL
|
||||
WHERE name = $1 AND deleted_at IS NULL`
|
||||
_, err := s.db.ExecContext(ctx, q, name, at)
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user