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

Adding logs to Tron to indicate start and scheduling times - TRON-2152 #948

Merged
merged 6 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion bin/trond
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def main():
boot_time = time.time()
setup_environment(args)
trond = trondaemon.TronDaemon(args)
trond.run(boot_time=boot_time)
trond.run(boot_time)


if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion tests/trondaemon_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import tempfile
import time
from unittest import mock

from testifycompat import setup
Expand Down Expand Up @@ -43,10 +44,11 @@ def test_run_uses_context(self):
autospec=None,
) as ndc:
ndc.return_value = mock.MagicMock()
boot_time = time.time()
ndc.return_value.__enter__.side_effect = RuntimeError()
daemon = TronDaemon(mock.Mock())
try:
daemon.run()
daemon.run(boot_time)
except Exception:
pass
assert ndc.call_count == 1
Expand Down
6 changes: 3 additions & 3 deletions tron/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_config_value(seq):
class MasterControlProgram:
"""Central state object for the Tron daemon."""

def __init__(self, working_dir, config_path, boot_time=None):
def __init__(self, working_dir, config_path, boot_time):
super().__init__()
self.jobs = JobCollection()
self.working_dir = working_dir
Expand Down Expand Up @@ -169,11 +169,11 @@ def restore_state(self, action_runner):
states = self.state_watcher.restore(self.jobs.get_names())
MesosClusterRepository.restore_state(states.get("mesos_state", {}))
log.info(
f"Tron will start restoring state for the jobs and will start scheduling them! Time elapsed since Tron started {time.time()- self.boot_time}"
f"Tron will start restoring state for the jobs and will start scheduling them! Time elapsed since Tron started {time.time() - self.boot_time}"
)
self.jobs.restore_state(states.get("job_state", {}), action_runner)
log.info(
f"Tron completed restoring state for the jobs. Time elapsed since Tron started {time.time()- self.boot_time}"
f"Tron completed restoring state for the jobs. Time elapsed since Tron started {time.time() - self.boot_time}"
)
self.state_watcher.save_metadata()

Expand Down
2 changes: 1 addition & 1 deletion tron/serialize/runstate/dynamodb_state_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _consume_save_queue(self):
log.error(error)
with self.save_lock:
self.save_queue[key] = val
duration = time.time() - start
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nopee, will commit the past version

duration = start
log.info(f"saved {saved} items in {duration}s")

if saved < qlen:
Expand Down
2 changes: 1 addition & 1 deletion tron/trondaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, options):
self.signals = {signal.SIGINT: signal.default_int_handler}
self.manhole_sock = f"{self.options.working_dir}/manhole.sock"

def run(self, boot_time=None):
def run(self, boot_time):
with no_daemon_context(self.working_dir, self.lock_file, self.signals):
signal_map = {
signal.SIGHUP: self._handle_reconfigure,
Expand Down
Loading