Skip to content

Commit

Permalink
fix(BA-626): fix pants check failures (#3563)
Browse files Browse the repository at this point in the history
  • Loading branch information
MintCat98 committed Feb 3, 2025
1 parent 718fd80 commit 3d117cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
15 changes: 6 additions & 9 deletions src/ai/backend/storage/volumes/cephfs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ async def describe_quota_scope(self, quota_scope_id: QuotaScopeID) -> Optional[Q
loop = asyncio.get_running_loop()

def read_attrs() -> tuple[int, int]:

used_bytes = int(os.getxattr(qspath, "ceph.dir.rbytes").decode()) # type: ignore[attr-defined]
used_bytes = int(os.getxattr(qspath, "ceph.dir.rbytes").decode()) # type: ignore[attr-defined]
try:

limit_bytes = int(os.getxattr(qspath, "ceph.quota.max_bytes").decode()) # type: ignore[attr-defined]
limit_bytes = int(os.getxattr(qspath, "ceph.quota.max_bytes").decode()) # type: ignore[attr-defined]
except OSError as e:
match e.errno:
case 61:
Expand Down Expand Up @@ -90,8 +88,7 @@ async def unset_quota(self, quota_scope_id: QuotaScopeID) -> None:
None,
# without type: ignore mypy will raise error when trying to run on macOS
# because os.setxattr() exists only for linux

lambda: os.setxattr(qspath, "ceph.quota.max_bytes", b"0"), # type: ignore[attr-defined]
lambda: os.setxattr(qspath, "ceph.quota.max_bytes", b"0"), # type: ignore[attr-defined]
)


Expand All @@ -101,8 +98,8 @@ async def scan_tree_usage(self, path: Path) -> TreeUsage:
raw_reports = await loop.run_in_executor(
None,
lambda: (
os.getxattr(path, "ceph.dir.rentries"), # type: ignore[attr-defined]
os.getxattr(path, "ceph.dir.rbytes"), # type: ignore[attr-defined]
os.getxattr(path, "ceph.dir.rentries"), # type: ignore[attr-defined]
os.getxattr(path, "ceph.dir.rbytes"), # type: ignore[attr-defined]
),
)
file_count = int(raw_reports[0].strip().decode())
Expand All @@ -113,7 +110,7 @@ async def scan_tree_size(self, path: Path) -> BinarySize:
loop = asyncio.get_running_loop()
raw_report = await loop.run_in_executor(
None,
lambda: os.getxattr(path, "ceph.dir.rbytes"), # type: ignore[attr-defined]
lambda: os.getxattr(path, "ceph.dir.rbytes"), # type: ignore[attr-defined]
)
return BinarySize(raw_report.strip().decode())

Expand Down
15 changes: 5 additions & 10 deletions src/ai/backend/storage/volumes/vast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ async def _rm_vast_quota_id(self, quota_scope_id: QuotaScopeID) -> None:
try:
await aiofiles.os.remove(qs_path / VAST_QUOTA_ID_FILE_NAME)
except FileNotFoundError:
log.warning(
f"vast quota id file not found (qid: {quota_scope_id}). skip")
log.warning(f"vast quota id file not found (qid: {quota_scope_id}). skip")

async def _modify_quota_scope(
self,
Expand Down Expand Up @@ -245,10 +244,8 @@ async def get_hwinfo(self) -> HardwareMetadata:
"metadata": {},
}
if clsuter_info is None:
raise StorageProxyError(
f"vast cluster not found. (id: {cluster_id})")
healthy_status: Literal["healthy",
"degraded", "unavailable"] = "unavailable"
raise StorageProxyError(f"vast cluster not found. (id: {cluster_id})")
healthy_status: Literal["healthy", "degraded", "unavailable"] = "unavailable"
match clsuter_info.state.lower():
case "online" | "healthy":
healthy_status = "healthy"
Expand Down Expand Up @@ -280,8 +277,7 @@ async def get_performance_metric(self) -> FSPerfMetric:
io_usec_write=-1,
)
if clsuter_info is None:
raise StorageProxyError(
f"vast cluster not found. (id: {cluster_id})")
raise StorageProxyError(f"vast cluster not found. (id: {cluster_id})")
return FSPerfMetric(
iops_read=clsuter_info.rd_iops,
iops_write=clsuter_info.wr_iops,
Expand All @@ -301,8 +297,7 @@ async def get_fs_usage(self) -> CapacityUsage:
capacity_bytes=-1,
)
if clsuter_info is None:
raise StorageProxyError(
f"vast cluster not found. (id: {cluster_id})")
raise StorageProxyError(f"vast cluster not found. (id: {cluster_id})")
return CapacityUsage(
used_bytes=clsuter_info.physical_space_in_use,
capacity_bytes=clsuter_info.physical_space,
Expand Down

0 comments on commit 3d117cf

Please sign in to comment.