Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data ComputeResourcesResponse = ComputeResourcesResponse {}
- data ResourceCheckerError
- getServerResources :: MonadIO m => m ComputeResourcesResponse
- getServerResources_ :: MonadIO m => FilePath -> m ComputeResourcesResponse
- getPhysicalCpuResource :: MonadIO m => m Int
- getMaxPhysicalMemory :: MonadIO m => m (Maybe Int64)
- getPhysicalResources :: MonadIO m => Maybe ResourceCheckerError -> m ComputeResourcesResponse
- getCGroupV1Resources :: MonadIO m => FilePath -> m ComputeResourcesResponse
- getCGroupV2Resources :: MonadIO m => FilePath -> m ComputeResourcesResponse
Documentation
data ComputeResourcesResponse Source #
The response data of cpu and memory resources
Instances
data ResourceCheckerError Source #
Instances
ToJSON ResourceCheckerError Source # | |
Defined in Hasura.Server.ResourceChecker toJSON :: ResourceCheckerError -> Value Source # toEncoding :: ResourceCheckerError -> Encoding Source # toJSONList :: [ResourceCheckerError] -> Value Source # toEncodingList :: [ResourceCheckerError] -> Encoding Source # | |
Show ResourceCheckerError Source # | |
Defined in Hasura.Server.ResourceChecker showsPrec :: Int -> ResourceCheckerError -> ShowS # show :: ResourceCheckerError -> String # showList :: [ResourceCheckerError] -> ShowS # | |
Eq ResourceCheckerError Source # | |
Defined in Hasura.Server.ResourceChecker (==) :: ResourceCheckerError -> ResourceCheckerError -> Bool # (/=) :: ResourceCheckerError -> ResourceCheckerError -> Bool # |
getServerResources :: MonadIO m => m ComputeResourcesResponse Source #
Determine allocated cpu and memory resources of the host server or Container Runtime. because HGE mainly runs in the container runtime we need to determine the max cpu and memory limit constraints that are managed by cgroups or fallback to physical cpu and memory information of the server https://hasurahq.atlassian.net/browse/INFRA-772
Those information are stored in many files of cgroup folders, the logic is simply to read them and parse number values
In cgroup v1 systems there are several ways in which the amount of allocated cpu resources could be presented. We first try reading requests (quota & period); if that fails, we fallback to reading limits (shares); if that fails, we fallback to reading the physical cpu count, which should always succeed.
getServerResources_ :: MonadIO m => FilePath -> m ComputeResourcesResponse Source #
getPhysicalCpuResource :: MonadIO m => m Int Source #
Compute the cpu share allocations from the number of physical CPU cores
getMaxPhysicalMemory :: MonadIO m => m (Maybe Int64) Source #
Compute the max physical memory size of the server
getPhysicalResources :: MonadIO m => Maybe ResourceCheckerError -> m ComputeResourcesResponse Source #
getCGroupV1Resources :: MonadIO m => FilePath -> m ComputeResourcesResponse Source #
Determine cpu and memory resource allocations if the OCI Container Runtime supports cgroup v1
getCGroupV2Resources :: MonadIO m => FilePath -> m ComputeResourcesResponse Source #
Determine cpu and memory resource allocations if the OCI Container Runtime supports cgroup v2