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

46 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-10-04 17:48 +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.server.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# Name of the header key to attach optional `RequestMetadata`values. 

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

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

74 

75# Name of the header key to attach client identity information. 

76CLIENT_IDENTITY_HEADER_NAME = "buildgrid.v2.clientidentity-bin" 

77 

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

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

80REQUEST_METADATA_TOOL_NAME = "buildgrid" 

81REQUEST_METADATA_TOOL_VERSION = __version__ 

82 

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

84S3_MAX_RETRIES = 4 

85S3_MAX_UPLOAD_SIZE = 8 * 1024 * 1024 

86S3_TIMEOUT_CONNECT = 120 

87S3_TIMEOUT_READ = 120 

88S3_MULTIPART_PART_SIZE = 8 * 1024 * 1024 

89S3_MULTIPART_MAX_CONCURRENT_PARTS = 10 

90 

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

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

93NETWORK_TIMEOUT = 3 

94 

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

96# directly or when doing de-duplication checks. 

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

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

99# will not be de-duplicated) 

100DEFAULT_MAX_EXECUTION_TIMEOUT = 7200 

101 

102# Default timeout to acquire locks or give up 

103DEFAULT_LOCK_ACQUIRE_TIMEOUT = 60 

104 

105# Default platform property keys 

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

107 

108# Maximum size of a ListOperations request. 

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

110DEFAULT_MAX_LIST_OPERATION_PAGE_SIZE = 1000 

111 

112# Default interval to refresh the JWKs. 

113DEFAULT_JWKS_REFETCH_INTERVAL_MINUTES = 60 

114 

115# SQL Scheduler and IndexedCAS 

116# Least time between automated pool disposals when detecting errors 

117MIN_TIME_BETWEEN_SQL_POOL_DISPOSE_MINUTES = 15 

118 

119# Amount of time between when the pool is disposed 

120# and when clients should retry requests 

121COOLDOWN_TIME_AFTER_POOL_DISPOSE_SECONDS = 30 

122 

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

124# to add/remove when asking clients to retry 

125COOLDOWN_TIME_JITTER_BASE = 5 

126 

127# SQL Scheduler 

128SQL_SCHEDULER_METRICS_PUBLISH_INTERVAL_SECONDS = 300 

129 

130# Time (seconds) to allow for shutdown before outputting running thread info 

131SHUTDOWN_ALARM_DELAY = 20 

132 

133# bgd browser-backend settings 

134# ---------------------------- 

135# 

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

137BROWSER_RESULT_CACHE_TTL = 300 

138 

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

140BROWSER_BLOB_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 

152SECURE_URI_SCHEMES = ["https", "grpcs"] 

153INSECURE_URI_SCHEMES = ["http", "grpc"] 

154 

155# Maximum page size for paged list APIs 

156MAX_LIST_PAGE_SIZE = 100