Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andmat900 committed Apr 22, 2024
1 parent 26c924b commit 4b0ac20
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/environment_provider/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

TRACER = trace.get_tracer(__name__)


def checkin_provider(
item: dict, provider: Union[IutProvider, ExecutionSpaceProvider, LogAreaProvider]
) -> tuple[bool, Optional[Exception]]:
Expand Down Expand Up @@ -79,21 +80,21 @@ def release_environment(

failure = None

span_name="stop_iuts"
span_name = "stop_iuts"
with TRACER.start_as_current_span(span_name):
success, exception = checkin_provider(Iut(**iut), IutProvider(etos, jsontas, iut_ruleset))
if not success:
failure = exception

span_name="stop_log_area"
span_name = "stop_log_area"
with TRACER.start_as_current_span(span_name):
success, exception = checkin_provider(
LogArea(**log_area), LogAreaProvider(etos, jsontas, log_area_ruleset)
)
if not success:
failure = exception

span_name="stop_execution_space"
span_name = "stop_execution_space"
with TRACER.start_as_current_span(span_name):
success, exception = checkin_provider(
ExecutionSpace(**executor),
Expand Down
3 changes: 1 addition & 2 deletions src/environment_provider/environment_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,7 @@ def checkout(
self.environment_provider_config,
)
finished = []
timeout = self.checkout_timeout()
while time.time() < timeout:
while time.time() < self.checkout_timeout():
self.set_total_test_count_and_test_runners(test_runners)

with self.tracer.start_as_current_span("request_iuts") as span:
Expand Down
7 changes: 1 addition & 6 deletions src/execution_space_provider/utilities/external_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def checkin(self, execution_space: ExecutionSpace) -> None:
otel_span.set_attribute("request.host", host)
otel_span.set_attribute("request.headers", json.dumps(headers, indent=4))
otel_span.set_attribute("request.body", json.dumps(execution_spaces, indent=4))
#opentelemetry.propagate.inject(headers) # inject current OpenTelemetry conext to HTTP request headers
self.logger.info("OpenTelemetry context headers: %s", headers)
timeout = time.time() + end
first_iteration = True
Expand All @@ -131,9 +130,7 @@ def checkin(self, execution_space: ExecutionSpace) -> None:
else:
time.sleep(2)
try:
response = requests.post(
host, json=execution_spaces, headers=headers
)
response = requests.post(host, json=execution_spaces, headers=headers)
if response.status_code == requests.codes["no_content"]:
return
response = response.json()
Expand Down Expand Up @@ -201,7 +198,6 @@ def start(self, minimum_amount: int, maximum_amount: int) -> str:
otel_span.set_attribute("request.host", host)
otel_span.set_attribute("request.headers", json.dumps(headers, indent=4))
otel_span.set_attribute("request.body", json.dumps(data, indent=4))
#opentelemetry.propagate.inject(headers) # inject current OpenTelemetry conext to HTTP request headers
self.logger.info("OpenTelemetry context headers: %s", headers)
try:
response = self.http.post(
Expand Down Expand Up @@ -236,7 +232,6 @@ def wait(self, provider_id: str) -> dict:
else:
time.sleep(2)
headers = {"X-ETOS-ID": self.identifier}
#opentelemetry.propagate.inject(headers) # inject current OpenTelemetry conext to HTTP request headers
self.logger.info("OpenTelemetry context headers: %s", headers)
try:
response = requests.get(
Expand Down
4 changes: 1 addition & 3 deletions src/log_area_provider/utilities/external_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ def checkin(self, log_area: LogArea) -> None:
else:
time.sleep(2)
try:
response = requests.post(
host, json=log_areas, headers=headers
)
response = requests.post(host, json=log_areas, headers=headers)
if response.status_code == requests.codes["no_content"]:
return
response = response.json()
Expand Down

0 comments on commit 4b0ac20

Please sign in to comment.