Coverage for /builds/BuildGrid/buildgrid/buildgrid/settings.py: 100.00%

42 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-04-15 14:01 +0000

1# Copyright (C) 2018 Bloomberg LP 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# <http://www.apache.org/licenses/LICENSE-2.0> 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14 

15import hashlib 

16 

17from buildgrid._version import __version__ 

18 

19# Latest REAPI version supported: 

20HIGH_REAPI_VERSION = "2.2.0" 

21 

22# Earliest non-deprecated REAPI version supported: 

23LOW_REAPI_VERSION = "2.0.0" 

24 

25# Hash function used for computing digests: 

26HASH = hashlib.sha256 

27 

28# Length in bytes of a hash string returned by HASH: 

29HASH_LENGTH = HASH().digest_size * 2 

30 

31# Minimum required size for the gRPC handlers thread pool, ie. 

32# min. value for the 'thread-pool-size' configuration key. 

33MIN_THREAD_POOL_SIZE = 5 

34 

35# Maximum number of client auth. credentials to cache: 

36AUTH_CACHE_SIZE = 200 

37 

38# Period, in seconds, for the monitoring cycle: 

39MONITORING_PERIOD = 5.0 

40 

41# Maximum size for a single gRPC request, minus a small delta: 

42MAX_REQUEST_SIZE = 4 * 1024 * 1024 - 1024 

43 

44# Maximum number of elements per gRPC request: 

45MAX_REQUEST_COUNT = 500 

46 

47# Value that establishes an upper bound on the size of a file that can 

48# be queued into a batch request. Expressed as a percentage of the 

49# batch size limit: 

50BATCH_REQUEST_SIZE_THRESHOLD = 0.25 

51 

52# Maximum size that a blob can have to be stored completely in-memory 

53# for reading/writing. 

54# Blobs that exceed this limit will be written to a temporary file and 

55# read from disk. 

56MAX_IN_MEMORY_BLOB_SIZE_BYTES = 4 * 1024 * 1024 

57 

58# Maximum time a worker can wait for work whilst connected to the Bots 

59# service, in seconds. Unset request-timeouts may be represented as 

60# max uint64 depending on the client, so capping it is important. 

61MAX_WORKER_TTL = 300 

62 

63# Time to wait between retries caused by gRPC streaming issues 

64STREAM_ERROR_RETRY_PERIOD = 60 

65 

66# String format for log records: 

67LOG_RECORD_FORMAT = "%(asctime)s:[%(request_id)s][%(name)36.36s][%(levelname)5.5s][%(threadName)s]: %(message)s" 

68# The different log record attributes are documented here: 

69# https://docs.python.org/3/library/logging.html#logrecord-attributes 

70 

71# URL scheme for the CAS content browser: 

72BROWSER_URL_FORMAT = "%(type)s/%(hash)s/%(sizebytes)s/" 

73# The string markers that are substituted are: 

74# instance - CAS instance's name (unused as bgd_browser does not use it) 

75# type - Type of CAS object, eg. 'action_result', 'command'... 

76# hash - Object's digest hash. 

77# sizebytes - Object's digest size in bytes. 

78 

79 

80# Name of the header key to attach optional `RequestMetadata`values. 

81# (This is defined in the REAPI specification.) 

82REQUEST_METADATA_HEADER_NAME = "build.bazel.remote.execution.v2.requestmetadata-bin" 

83 

84# 'RequestMetadata' header values. These values will be used when 

85# attaching optional metadata to a gRPC request's header: 

86REQUEST_METADATA_TOOL_NAME = "buildgrid" 

87REQUEST_METADATA_TOOL_VERSION = __version__ 

88 

89S3_USERAGENT_NAME = f"{REQUEST_METADATA_TOOL_NAME}/{REQUEST_METADATA_TOOL_VERSION}" 

90S3_MAX_RETRIES = 4 

91S3_MAX_UPLOAD_SIZE = 8 * 1024 * 1024 

92S3_TIMEOUT_CONNECT = 120 

93S3_TIMEOUT_READ = 120 

94S3_MULTIPART_PART_SIZE = 8 * 1024 * 1024 

95S3_MULTIPART_MAX_CONCURRENT_PARTS = 10 

96 

97# Minimum deadline in seconds that workers can set during work assignment. 

98# Requests with a deadline less than this value will never get work 

99NETWORK_TIMEOUT = 3 

100 

101# Default Maximum execution timeout; lazily checked upon request of job status, 

102# directly or when doing de-duplication checks. 

103# If the job has been executing for longer than this amount of time (in seconds) 

104# it will be marked as cancelled (existing operations will be cancelled, and the job 

105# will not be de-duplicated) 

106DEFAULT_MAX_EXECUTION_TIMEOUT = 7200 

107 

108# Default timeout to acquire locks or give up 

109DEFAULT_LOCK_ACQUIRE_TIMEOUT = 60 

110 

111# Default platform property keys 

112DEFAULT_PLATFORM_PROPERTY_KEYS = {"OSFamily", "ISA"} 

113 

114# Maximum size of a ListOperations request. 

115# In-memory schedulers do not have paging, so this does not apply there. 

116DEFAULT_MAX_LIST_OPERATION_PAGE_SIZE = 1000 

117 

118# Default interval to refresh the JWKs. 

119DEFAULT_JWKS_REFETCH_INTERVAL_MINUTES = 60 

120 

121# SQL Scheduler and IndexedCAS 

122# Least time between automated pool disposals when detecting errors 

123MIN_TIME_BETWEEN_SQL_POOL_DISPOSE_MINUTES = 15 

124 

125# Amount of time between when the pool is disposed 

126# and when clients should retry requests 

127COOLDOWN_TIME_AFTER_POOL_DISPOSE_SECONDS = 30 

128 

129# Number of seconds used as bounds for how many seconds 

130# to add/remove when asking clients to retry 

131COOLDOWN_TIME_JITTER_BASE = 5 

132 

133# SQL Scheduler 

134SQL_SCHEDULER_METRICS_PUBLISH_INTERVAL_SECONDS = 300 

135 

136# bgd browser-backend settings 

137# ---------------------------- 

138# 

139# Time to live for the in-memory ActionResult cache entries 

140BROWSER_RESULT_CACHE_TTL = 300 

141 

142# Time-to-live for the in-memory generic blob cache entries 

143BROWSER_BLOB_CACHE_TTL = 300 

144 

145# Maximum blob size to cache in the browser backend 

146BROWSER_MAX_CACHE_ENTRY_SIZE = 4 * 1024 * 1024 

147 

148# Maximum number of entries in the ActionResult cache 

149BROWSER_RESULT_CACHE_MAX_LENGTH = 256 

150 

151# Maximum number of entries in the blob cache 

152BROWSER_BLOB_CACHE_MAX_LENGTH = 256