Skip to content
Snippets Groups Projects
Commit 68723d8c authored by Martin Blanchard's avatar Martin Blanchard
Browse files

job.py: Implement server-side ExecutedActionMetadata

#83
parent 6e9857e2
No related branches found
No related tags found
Loading
......@@ -184,7 +184,8 @@ ignore-on-opaque-inference=yes
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=google.protobuf.any_pb2.Any
ignored-classes=google.protobuf.any_pb2.Any,
google.protobuf.timestamp_pb2.Timestamp
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
......
......@@ -17,6 +17,8 @@ import logging
import uuid
from enum import Enum
from google.protobuf import timestamp_pb2
from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
from buildgrid._protos.google.devtools.remoteworkers.v1test2 import bots_pb2
from buildgrid._protos.google.longrunning import operations_pb2
......@@ -60,6 +62,9 @@ class Job:
self.__execute_response = None
self.__operation_metadata = remote_execution_pb2.ExecuteOperationMetadata()
self.__queued_timestamp = timestamp_pb2.Timestamp()
self.__worker_start_timestamp = timestamp_pb2.Timestamp()
self.__worker_completed_timestamp = timestamp_pb2.Timestamp()
self.__operation_metadata.action_digest.CopyFrom(action_digest)
self.__operation_metadata.stage = OperationStage.UNKNOWN.value
......@@ -177,10 +182,18 @@ class Job:
self._lease.state = state.value
if self._lease.state == LeaseState.PENDING.value:
self.__worker_start_timestamp.Clear()
self.__worker_completed_timestamp.Clear()
self._lease.status.Clear()
self._lease.result.Clear()
elif self._lease.state == LeaseState.ACTIVE.value:
self.__worker_start_timestamp.GetCurrentTime()
elif self._lease.state == LeaseState.COMPLETED.value:
self.__worker_completed_timestamp.GetCurrentTime()
action_result = remote_execution_pb2.ActionResult()
# TODO: Make a distinction between build and bot failures!
......@@ -191,6 +204,11 @@ class Job:
assert result.Is(action_result.DESCRIPTOR)
result.Unpack(action_result)
action_metadata = action_result.execution_metadata
action_metadata.queued_timestamp.CopyFrom(self.__worker_start_timestamp)
action_metadata.worker_start_timestamp.CopyFrom(self.__worker_start_timestamp)
action_metadata.worker_completed_timestamp.CopyFrom(self.__worker_completed_timestamp)
self.__execute_response = remote_execution_pb2.ExecuteResponse()
self.__execute_response.result.CopyFrom(action_result)
self.__execute_response.cached_result = False
......@@ -208,6 +226,8 @@ class Job:
self.__operation_metadata.stage = stage.value
if self.__operation_metadata.stage == OperationStage.QUEUED.value:
if self.__queued_timestamp.ByteSize() == 0:
self.__queued_timestamp.GetCurrentTime()
self._n_tries += 1
elif self.__operation_metadata.stage == OperationStage.COMPLETED.value:
......
......@@ -144,7 +144,8 @@ def test_list_operations_with_result(instance, controller, execute_request, cont
execute_response = remote_execution_pb2.ExecuteResponse()
response.operations[0].response.Unpack(execute_response)
assert execute_response.result == action_result
assert execute_response.result.output_files == action_result.output_files
def test_list_operations_empty(instance, context):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment