Coverage for /builds/BuildGrid/buildgrid/buildgrid/server/enums.py: 100.00%
57 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.
16from enum import Enum
17from typing import Tuple
19from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
20from buildgrid._protos.buildgrid.v2 import monitoring_pb2
21from buildgrid._protos.google.devtools.remoteworkers.v1test2 import bots_pb2
23# RWAPI enumerations
24# From google/devtools/remoteworkers/v1test2/bots.proto:
27class BotStatus(Enum):
28 # Initially unknown state.
29 UNSPECIFIED = bots_pb2.BotStatus.Value("BOT_STATUS_UNSPECIFIED")
30 # The bot is healthy, and will accept leases as normal.
31 OK = bots_pb2.BotStatus.Value("OK")
32 # The bot is unhealthy and will not accept new leases.
33 UNHEALTHY = bots_pb2.BotStatus.Value("UNHEALTHY")
34 # The bot has been asked to reboot the host.
35 HOST_REBOOTING = bots_pb2.BotStatus.Value("HOST_REBOOTING")
36 # The bot has been asked to shut down.
37 BOT_TERMINATING = bots_pb2.BotStatus.Value("BOT_TERMINATING")
40class LeaseState(Enum):
41 # Initially unknown state.
42 UNSPECIFIED = bots_pb2.LeaseState.Value("LEASE_STATE_UNSPECIFIED")
43 # The server expects the bot to accept this lease.
44 PENDING = bots_pb2.LeaseState.Value("PENDING")
45 # The bot has accepted this lease.
46 ACTIVE = bots_pb2.LeaseState.Value("ACTIVE")
47 # The bot is no longer leased.
48 COMPLETED = bots_pb2.LeaseState.Value("COMPLETED")
49 # The bot should immediately release all resources associated with the lease.
50 CANCELLED = bots_pb2.LeaseState.Value("CANCELLED")
53# REAPI enumerations
54# From build/bazel/remote/execution/v2/remote_execution.proto:
57class OperationStage(Enum):
58 # Initially unknown stage.
59 UNKNOWN = remote_execution_pb2.ExecutionStage.Value.Value("UNKNOWN")
60 # Checking the result against the cache.
61 CACHE_CHECK = remote_execution_pb2.ExecutionStage.Value.Value("CACHE_CHECK")
62 # Currently idle, awaiting a free machine to execute.
63 QUEUED = remote_execution_pb2.ExecutionStage.Value.Value("QUEUED")
64 # Currently being executed by a worker.
65 EXECUTING = remote_execution_pb2.ExecutionStage.Value.Value("EXECUTING")
66 # Finished execution.
67 COMPLETED = remote_execution_pb2.ExecutionStage.Value.Value("COMPLETED")
70# Internal enumerations
71# From buildgrid.v2/monitoring.proto:
74class LogRecordLevel(Enum):
75 # Initially unknown level.
76 NOTSET = monitoring_pb2.LogRecord.Level.Value("NOTSET")
77 # Debug message severity level.
78 DEBUG = monitoring_pb2.LogRecord.Level.Value("DEBUG")
79 # Information message severity level.
80 INFO = monitoring_pb2.LogRecord.Level.Value("INFO")
81 # Warning message severity level.
82 WARNING = monitoring_pb2.LogRecord.Level.Value("WARNING")
83 # Error message severity level.
84 ERROR = monitoring_pb2.LogRecord.Level.Value("ERROR")
85 # Critical message severity level.
86 CRITICAL = monitoring_pb2.LogRecord.Level.Value("CRITICAL")
89class MetricRecordType(Enum):
90 # Initially unknown type.
91 NONE = monitoring_pb2.MetricRecord.Type.Value("NONE")
92 # A metric for counting.
93 COUNTER = monitoring_pb2.MetricRecord.Type.Value("COUNTER")
94 # A metric for mesuring a duration.
95 TIMER = monitoring_pb2.MetricRecord.Type.Value("TIMER")
96 # A metric in arbitrary value.
97 GAUGE = monitoring_pb2.MetricRecord.Type.Value("GAUGE")
98 # A metric with distribution semantics
99 DISTRIBUTION = monitoring_pb2.MetricRecord.Type.Value("DISTRIBUTION")
102class JobEventType(Enum):
103 STOP = "stop"
104 CHANGE = "change"
107class MetricCategories(Enum):
108 LEASES = "leases"
109 JOBS = "jobs"
112class ServiceName(Enum):
113 EXECUTION = "execution"
114 OPERATIONS = "operations"
115 BOTS = "bots"
117 @classmethod
118 def default_services(cls) -> Tuple[str, str, str]:
119 return (cls.EXECUTION.value, cls.OPERATIONS.value, cls.BOTS.value)
122class ByteStreamResourceType(Enum):
123 CAS = "cas"
126class ActionCacheEntryType(Enum):
127 """Type of the value stored in an Action Cache entry."""
129 ACTION_RESULT_DIGEST = 0
130 ACTION_RESULT = 1
133class MeteringThrottleAction(Enum):
134 DEPRIORITIZE = "deprioritize"
135 REJECT = "reject"