Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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 

15 

16from enum import Enum 

17 

18from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 

19from buildgrid._protos.buildgrid.v2 import monitoring_pb2 

20from buildgrid._protos.google.devtools.remoteworkers.v1test2 import bots_pb2 

21 

22 

23# RWAPI enumerations 

24# From google/devtools/remoteworkers/v1test2/bots.proto: 

25 

26class BotStatus(Enum): 

27 # Initially unknown state. 

28 UNSPECIFIED = bots_pb2.BotStatus.Value('BOT_STATUS_UNSPECIFIED') 

29 # The bot is healthy, and will accept leases as normal. 

30 OK = bots_pb2.BotStatus.Value('OK') 

31 # The bot is unhealthy and will not accept new leases. 

32 UNHEALTHY = bots_pb2.BotStatus.Value('UNHEALTHY') 

33 # The bot has been asked to reboot the host. 

34 HOST_REBOOTING = bots_pb2.BotStatus.Value('HOST_REBOOTING') 

35 # The bot has been asked to shut down. 

36 BOT_TERMINATING = bots_pb2.BotStatus.Value('BOT_TERMINATING') 

37 

38 

39class LeaseState(Enum): 

40 # Initially unknown state. 

41 UNSPECIFIED = bots_pb2.LeaseState.Value('LEASE_STATE_UNSPECIFIED') 

42 # The server expects the bot to accept this lease. 

43 PENDING = bots_pb2.LeaseState.Value('PENDING') 

44 # The bot has accepted this lease. 

45 ACTIVE = bots_pb2.LeaseState.Value('ACTIVE') 

46 # The bot is no longer leased. 

47 COMPLETED = bots_pb2.LeaseState.Value('COMPLETED') 

48 # The bot should immediately release all resources associated with the lease. 

49 CANCELLED = bots_pb2.LeaseState.Value('CANCELLED') 

50 

51 

52# REAPI enumerations 

53# From build/bazel/remote/execution/v2/remote_execution.proto: 

54 

55class OperationStage(Enum): 

56 # Initially unknown stage. 

57 UNKNOWN = remote_execution_pb2.ExecutionStage.Value.Value('UNKNOWN') 

58 # Checking the result against the cache. 

59 CACHE_CHECK = remote_execution_pb2.ExecutionStage.Value.Value('CACHE_CHECK') 

60 # Currently idle, awaiting a free machine to execute. 

61 QUEUED = remote_execution_pb2.ExecutionStage.Value.Value('QUEUED') 

62 # Currently being executed by a worker. 

63 EXECUTING = remote_execution_pb2.ExecutionStage.Value.Value('EXECUTING') 

64 # Finished execution. 

65 COMPLETED = remote_execution_pb2.ExecutionStage.Value.Value('COMPLETED') 

66 

67 

68# Internal enumerations 

69# From buildgrid.v2/monitoring.proto: 

70 

71class LogRecordLevel(Enum): 

72 # Initially unknown level. 

73 NOTSET = monitoring_pb2.LogRecord.Level.Value('NOTSET') 

74 # Debug message severity level. 

75 DEBUG = monitoring_pb2.LogRecord.Level.Value('DEBUG') 

76 # Information message severity level. 

77 INFO = monitoring_pb2.LogRecord.Level.Value('INFO') 

78 # Warning message severity level. 

79 WARNING = monitoring_pb2.LogRecord.Level.Value('WARNING') 

80 # Error message severity level. 

81 ERROR = monitoring_pb2.LogRecord.Level.Value('ERROR') 

82 # Critical message severity level. 

83 CRITICAL = monitoring_pb2.LogRecord.Level.Value('CRITICAL') 

84 

85 

86class MetricRecordDomain(Enum): 

87 # Initially unknown domain. 

88 UNKNOWN = monitoring_pb2.MetricRecord.Domain.Value('UNKNOWN') 

89 # A server state related metric. 

90 STATE = monitoring_pb2.MetricRecord.Domain.Value('STATE') 

91 # A build execution related metric. 

92 BUILD = monitoring_pb2.MetricRecord.Domain.Value('BUILD') 

93 # A CAS-related metric. 

94 CAS = monitoring_pb2.MetricRecord.Domain.Value('CAS') 

95 

96 

97class MetricRecordType(Enum): 

98 # Initially unknown type. 

99 NONE = monitoring_pb2.MetricRecord.Type.Value('NONE') 

100 # A metric for counting. 

101 COUNTER = monitoring_pb2.MetricRecord.Type.Value('COUNTER') 

102 # A metric for mesuring a duration. 

103 TIMER = monitoring_pb2.MetricRecord.Type.Value('TIMER') 

104 # A metric in arbitrary value. 

105 GAUGE = monitoring_pb2.MetricRecord.Type.Value('GAUGE') 

106 # A metric with distribution semantics 

107 DISTRIBUTION = monitoring_pb2.MetricRecord.Type.Value('DISTRIBUTION') 

108 

109 

110class DataStoreType(Enum): 

111 MEM = "mem" 

112 SQL = "sql" 

113 

114 

115class JobEventType(Enum): 

116 STOP = "stop" 

117 CHANGE = "change" 

118 

119 

120class MetricCategories(Enum): 

121 LEASES = 'leases' 

122 OPERATIONS = 'operations' 

123 JOBS = 'jobs' 

124 

125 

126class ServiceName(Enum): 

127 EXECUTION = "execution" 

128 OPERATIONS = "operations" 

129 BOTS = "bots" 

130 

131 @classmethod 

132 def default_services(cls): 

133 return ( 

134 cls.EXECUTION.value, 

135 cls.OPERATIONS.value, 

136 cls.BOTS.value 

137 ) 

138 

139 

140class CleanupFailure(Enum): 

141 MISSING = 'missing' 

142 FAILURE = 'failure'