Skip to content

Commit 86a478f

Browse files
authored
Agent status timeout configurable (#1306)
* Agent status timeout configurable * Using k8s yamls from checked-out repo instead of the hard-coded release branch
1 parent 0894391 commit 86a478f

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

.circleci/smoketest_k8s.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ if [[ "$delete_existing_objects" == "delete_existing_k8s_objs" ]]; then
7070
kubectl delete daemonset scalyr-agent-2 || true
7171
kubectl delete configmap scalyr-config || true
7272
kubectl delete secret scalyr-api-key || true
73-
kubectl delete -f https://raw.githubusercontent.com/scalyr/scalyr-agent-2/release/k8s/scalyr-service-account.yaml || true
73+
kubectl delete -f ./k8s/scalyr-service-account.yaml || true
7474
echo "::endgroup::"
7575
fi
7676

7777
echo ""
7878
echo "::group::Creating k8s objects"
7979
echo "=================================================="
8080
# Create service account
81-
kubectl create -f https://raw.githubusercontent.com/scalyr/scalyr-agent-2/release/k8s/scalyr-service-account.yaml
81+
kubectl create -f ./k8s/scalyr-service-account.yaml
8282

8383
# Define api key
8484
kubectl create secret generic scalyr-api-key --from-literal=scalyr-api-key=${SCALYR_API_KEY}

scalyr_agent/agent_main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ def __detailed_status(
926926
return 2
927927

928928
# We wait for five seconds at most to get the status.
929-
deadline = time.time() + 5
929+
deadline = time.time() + self.__config.agent_status_timeout
930930

931931
last_debug_stat_time = 0
932932
# Now loop until we see it show up.
@@ -980,9 +980,9 @@ def __detailed_status(
980980
debug_stats_str = ""
981981

982982
print(
983-
"Failed to get status within 5 seconds. Giving up. The agent process is "
983+
"Failed to get status within %d seconds. Giving up. The agent process is "
984984
"possibly stuck. See %s for more details.\n%s"
985-
% (agent_log, debug_stats_str),
985+
% (self.__config.agent_status_timeout, agent_log, debug_stats_str),
986986
file=sys.stderr,
987987
)
988988
return 1
@@ -2329,8 +2329,8 @@ def __report_status_to_file(self):
23292329

23302330
log.log(
23312331
scalyr_logging.DEBUG_LEVEL_4,
2332-
'Wrote agent status data in "%s" format to %s'
2333-
% (status_format, final_file_path),
2332+
'Wrote agent status data in "%s" format to %s in %.2f seconds'
2333+
% (status_format, final_file_path, time.time() - start_ts),
23342334
)
23352335

23362336
return final_file_path

scalyr_agent/configuration.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,11 @@ def api_key(self):
14981498
"""Returns the configuration value for 'api_key'."""
14991499
return self.__get_config().get_string("api_key")
15001500

1501+
@property
1502+
def agent_status_timeout(self):
1503+
"""Returns the configuration value for 'agent_status_timeout'."""
1504+
return self.__get_config().get_int("agent_status_timeout")
1505+
15011506
@property
15021507
def scalyr_server(self):
15031508
"""Returns the configuration value for 'scalyr_server'."""
@@ -3604,6 +3609,14 @@ def __verify_main_config_and_apply_defaults(
36043609
apply_defaults,
36053610
)
36063611

3612+
self.__verify_or_set_optional_int(
3613+
config,
3614+
"agent_status_timeout",
3615+
30,
3616+
description,
3617+
apply_defaults,
3618+
)
3619+
36073620
def __verify_compression_type(self, compression_type):
36083621
"""
36093622
Verify that the library for the specified compression type (algorithm) is available.

0 commit comments

Comments
 (0)