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

42 statements  

« prev     ^ index     » next       coverage.py v6.4.1, created at 2022-06-22 21:04 +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# Maximum logstream chunk size 

48MAX_LOGSTREAM_CHUNK_SIZE = 1024 * 1024 

49 

50# Maximum logstream streams in memory 

51MAX_LOGSTREAMS_BEFORE_CLEANUP = 1000 

52 

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

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

55# batch size limit: 

56BATCH_REQUEST_SIZE_THRESHOLD = 0.25 

57 

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

59# for reading/writing. 

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

61# read from disk. 

62MAX_IN_MEMORY_BLOB_SIZE_BYTES = 4 * 1024 * 1024 

63 

64# String format for log records: 

65LOG_RECORD_FORMAT = '%(asctime)s:[%(name)36.36s][%(levelname)5.5s][%(threadName)s]: %(message)s' 

66# The different log record attributes are documented here: 

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

68 

69# URL scheme for the CAS content browser: 

70BROWSER_URL_FORMAT = '%(type)s/%(instance)s/%(hash)s/%(sizebytes)s/' 

71# The string markers that are substituted are: 

72# instance - CAS instance's name. 

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

74# hash - Object's digest hash. 

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

76 

77 

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

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

80REQUEST_METADATA_HEADER_NAME = 'build.bazel.remote.execution.v2.requestmetadata-bin' 

81 

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

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

84REQUEST_METADATA_TOOL_NAME = 'buildgrid' 

85REQUEST_METADATA_TOOL_VERSION = __version__ 

86 

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

88S3_MAX_RETRIES = 4 

89S3_TIMEOUT_CONNECT = 120 

90S3_TIMEOUT_READ = 120 

91 

92# Time in seconds to pad timeouts 

93NETWORK_TIMEOUT = 1 

94 

95# Hard limit for waiting on jobs, avoids grpc timeouts not being set defaulting 

96# the interval to the max int64 value 

97MAX_JOB_BLOCK_TIME = 300 

98 

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

100# directly or when doing de-duplication checks. 

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

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

103# will not be de-duplicated) 

104DEFAULT_MAX_EXECUTION_TIMEOUT = 7200 

105 

106# Default timeout to acquire locks or give up 

107DEFAULT_LOCK_ACQUIRE_TIMEOUT = 60 

108 

109# Default platform property keys 

110DEFAULT_PLATFORM_PROPERTY_KEYS = {'OSFamily', 'ISA'} 

111 

112# Maximum size of a ListOperations request. 

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

114DEFAULT_MAX_LIST_OPERATION_PAGE_SIZE = 1000 

115 

116# Default interval to refresh the JWKs. 

117DEFAULT_JWKS_REFETCH_INTERVAL_MINUTES = 60 

118 

119# SQL Scheduler and IndexedCAS 

120# Least time between automated pool disposals when detecting errors 

121MIN_TIME_BETWEEN_SQL_POOL_DISPOSE_MINUTES = 15 

122COOLDOWN_TIME_AFTER_POOL_DISPOSE_SECONDS = 75 

123 

124# SQL Scheduler 

125SQL_SCHEDULER_METRICS_PUBLISH_INTERVAL_SECONDS = 300 

126 

127# Number of times to retry creation of a Pika publisher 

128RABBITMQ_PUBLISHER_CREATION_RETRIES = 5 

129 

130# bgd browser-backend settings 

131# ---------------------------- 

132# 

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

134BROWSER_RESULT_CACHE_TTL = 300 

135 

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

137BROWSER_BLOB_CACHE_TTL = 300 

138 

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

140BROWSER_OPERATION_CACHE_TTL = 300 

141 

142# Maximum blob size to cache in the browser backend 

143BROWSER_MAX_CACHE_ENTRY_SIZE = 4 * 1024 * 1024 

144 

145# Maximum number of entries in the ActionResult cache 

146BROWSER_RESULT_CACHE_MAX_LENGTH = 256 

147 

148# Maximum number of entries in the blob cache 

149BROWSER_BLOB_CACHE_MAX_LENGTH = 256 

150 

151# Maximum number of entries in the Operations cache 

152BROWSER_OPERATION_CACHE_MAX_LENGTH = 256