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
« 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.
15import hashlib
17from buildgrid.server.version import __version__
19# Latest REAPI version supported:
20HIGH_REAPI_VERSION = "2.2.0"
22# Earliest non-deprecated REAPI version supported:
23LOW_REAPI_VERSION = "2.0.0"
25# Hash function used for computing digests:
26HASH = hashlib.sha256
28# Length in bytes of a hash string returned by HASH:
29HASH_LENGTH = HASH().digest_size * 2
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
35# Maximum number of client auth. credentials to cache:
36AUTH_CACHE_SIZE = 200
38# Period, in seconds, for the monitoring cycle:
39MONITORING_PERIOD = 5.0
41# Maximum size for a single gRPC request, minus a small delta:
42MAX_REQUEST_SIZE = 4 * 1024 * 1024 - 1024
44# Maximum number of elements per gRPC request:
45MAX_REQUEST_COUNT = 500
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
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
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
63# Time to wait between retries caused by gRPC streaming issues
64STREAM_ERROR_RETRY_PERIOD = 60
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
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"
75# Name of the header key to attach client identity information.
76CLIENT_IDENTITY_HEADER_NAME = "buildgrid.v2.clientidentity-bin"
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__
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
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
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
102# Default timeout to acquire locks or give up
103DEFAULT_LOCK_ACQUIRE_TIMEOUT = 60
105# Default platform property keys
106DEFAULT_PLATFORM_PROPERTY_KEYS = {"OSFamily", "ISA"}
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
112# Default interval to refresh the JWKs.
113DEFAULT_JWKS_REFETCH_INTERVAL_MINUTES = 60
115# SQL Scheduler and IndexedCAS
116# Least time between automated pool disposals when detecting errors
117MIN_TIME_BETWEEN_SQL_POOL_DISPOSE_MINUTES = 15
119# Amount of time between when the pool is disposed
120# and when clients should retry requests
121COOLDOWN_TIME_AFTER_POOL_DISPOSE_SECONDS = 30
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
127# SQL Scheduler
128SQL_SCHEDULER_METRICS_PUBLISH_INTERVAL_SECONDS = 300
130# Time (seconds) to allow for shutdown before outputting running thread info
131SHUTDOWN_ALARM_DELAY = 20
133# bgd browser-backend settings
134# ----------------------------
135#
136# Time to live for the in-memory ActionResult cache entries
137BROWSER_RESULT_CACHE_TTL = 300
139# Time-to-live for the in-memory generic blob cache entries
140BROWSER_BLOB_CACHE_TTL = 300
142# Maximum blob size to cache in the browser backend
143BROWSER_MAX_CACHE_ENTRY_SIZE = 4 * 1024 * 1024
145# Maximum number of entries in the ActionResult cache
146BROWSER_RESULT_CACHE_MAX_LENGTH = 256
148# Maximum number of entries in the blob cache
149BROWSER_BLOB_CACHE_MAX_LENGTH = 256
152SECURE_URI_SCHEMES = ["https", "grpcs"]
153INSECURE_URI_SCHEMES = ["http", "grpc"]
155# Maximum page size for paged list APIs
156MAX_LIST_PAGE_SIZE = 100