Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent status timeout configurable #1306

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/smoketest_k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ if [[ "$delete_existing_objects" == "delete_existing_k8s_objs" ]]; then
kubectl delete daemonset scalyr-agent-2 || true
kubectl delete configmap scalyr-config || true
kubectl delete secret scalyr-api-key || true
kubectl delete -f https://raw.githubusercontent.com/scalyr/scalyr-agent-2/release/k8s/scalyr-service-account.yaml || true
kubectl delete -f ./k8s/scalyr-service-account.yaml || true
echo "::endgroup::"
fi

echo ""
echo "::group::Creating k8s objects"
echo "=================================================="
# Create service account
kubectl create -f https://raw.githubusercontent.com/scalyr/scalyr-agent-2/release/k8s/scalyr-service-account.yaml
kubectl create -f ./k8s/scalyr-service-account.yaml

# Define api key
kubectl create secret generic scalyr-api-key --from-literal=scalyr-api-key=${SCALYR_API_KEY}
Expand Down
10 changes: 5 additions & 5 deletions scalyr_agent/agent_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ def __detailed_status(
return 2

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

last_debug_stat_time = 0
# Now loop until we see it show up.
Expand Down Expand Up @@ -980,9 +980,9 @@ def __detailed_status(
debug_stats_str = ""

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

log.log(
scalyr_logging.DEBUG_LEVEL_4,
'Wrote agent status data in "%s" format to %s'
% (status_format, final_file_path),
'Wrote agent status data in "%s" format to %s in %.2f seconds'
% (status_format, final_file_path, time.time() - start_ts),
)

return final_file_path
Expand Down
13 changes: 13 additions & 0 deletions scalyr_agent/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,11 @@ def api_key(self):
"""Returns the configuration value for 'api_key'."""
return self.__get_config().get_string("api_key")

@property
def agent_status_timeout(self):
"""Returns the configuration value for 'agent_status_timeout'."""
return self.__get_config().get_int("agent_status_timeout")

@property
def scalyr_server(self):
"""Returns the configuration value for 'scalyr_server'."""
Expand Down Expand Up @@ -3604,6 +3609,14 @@ def __verify_main_config_and_apply_defaults(
apply_defaults,
)

self.__verify_or_set_optional_int(
config,
"agent_status_timeout",
30,
description,
apply_defaults,
)

def __verify_compression_type(self, compression_type):
"""
Verify that the library for the specified compression type (algorithm) is available.
Expand Down
Loading