graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hasura.Server.ResourceChecker

Synopsis

Documentation

data ComputeResourcesResponse Source #

The response data of cpu and memory resources

Instances

Instances details
ToJSON ComputeResourcesResponse Source # 
Instance details

Defined in Hasura.Server.ResourceChecker

Generic ComputeResourcesResponse Source # 
Instance details

Defined in Hasura.Server.ResourceChecker

Associated Types

type Rep ComputeResourcesResponse :: Type -> Type #

Show ComputeResourcesResponse Source # 
Instance details

Defined in Hasura.Server.ResourceChecker

Eq ComputeResourcesResponse Source # 
Instance details

Defined in Hasura.Server.ResourceChecker

type Rep ComputeResourcesResponse Source # 
Instance details

Defined in Hasura.Server.ResourceChecker

type Rep ComputeResourcesResponse = D1 ('MetaData "ComputeResourcesResponse" "Hasura.Server.ResourceChecker" "graphql-engine-1.0.0-inplace" 'False) (C1 ('MetaCons "ComputeResourcesResponse" 'PrefixI 'True) (S1 ('MetaSel ('Just "_rcrCpu") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Int)) :*: (S1 ('MetaSel ('Just "_rcrMemory") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Int64)) :*: S1 ('MetaSel ('Just "_rcrErrorCode") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe ResourceCheckerError)))))

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.

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

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