Skip to content

Commit

Permalink
Use filesystem.statfs for retrieving available space
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicaj committed Sep 6, 2024
1 parent 8f34ec0 commit ce5356a
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions src/middlewared/middlewared/plugins/apps/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from .ix_apps.utils import ContainerState
from .resources_utils import get_normalized_gpu_choices
from .utils import IX_APPS_MOUNT_PATH


class AppService(Service):
Expand Down Expand Up @@ -113,27 +114,13 @@ async def ip_choices(self):
}

@accepts(roles=['CATALOG_READ'])
@returns(Dict(
'available_space',
additional_attrs=True,
example={
'parsed': 21289574400,
'rawvalue': '21289574400',
'value': '19.8G',
'source': 'NONE',
'source_info': None,
}
))
@returns(Int())
async def available_space(self):
"""
Returns space available in the configured apps pool which apps can consume
Returns space available in bytes in the configured apps pool which apps can consume
"""
await self.middleware.call('docker.state.validate')
return (await self.middleware.call(
'zfs.dataset.get_instance', (await self.middleware.call('docker.config'))['dataset'], {
'extra': {'retrieve_children': False, 'properties': ['available']},
}
))['properties']['available']
return (await self.middleware.call('filesystem.statfs', IX_APPS_MOUNT_PATH))['free_bytes']

@accepts(roles=['APPS_READ'])
@returns(Dict('gpu_choices', additional_attrs=True))
Expand Down

0 comments on commit ce5356a

Please sign in to comment.