[Autotest] Update Database timeout to timeout_mins.
This change adds a timeout_mins column to the afe_jobs table and updates
exisiting jobs to include this entry.
Also updates the django models that reflect afe_jobs.
BUG=chromium:221264
DEPLOY=migrate, scheduler
TEST=Ran migration, checked column is in db, scheduler_models_unittest.py,
ran smoke suite on local AFE.
Change-Id: I09f8b6023a31dcef37e98c298dc0d63b37bc0a9e
Reviewed-on: https://chromium-review.googlesource.com/173916
Reviewed-by: Simran Basi <sbasi@chromium.org>
Tested-by: Simran Basi <sbasi@chromium.org>
Commit-Queue: Simran Basi <sbasi@chromium.org>
diff --git a/frontend/afe/doctests/001_rpc_test.txt b/frontend/afe/doctests/001_rpc_test.txt
index 98781f8..e409036 100644
--- a/frontend/afe/doctests/001_rpc_test.txt
+++ b/frontend/afe/doctests/001_rpc_test.txt
@@ -540,6 +540,7 @@
... 'priority': 10,
... 'synch_count': 1,
... 'timeout': 24,
+... 'timeout_mins': 1440,
... 'max_runtime_mins': 1440,
... 'max_runtime_hrs' : 72,
... 'run_verify': False,
diff --git a/frontend/afe/models.py b/frontend/afe/models.py
index 0e10576..d4ada02 100644
--- a/frontend/afe/models.py
+++ b/frontend/afe/models.py
@@ -1003,7 +1003,8 @@
synch_count: how many hosts should be used per autoserv execution
run_verify: Whether or not to run the verify phase
run_reset: Whether or not to run the reset phase
- timeout: hours from queuing time until job times out
+ timeout: DEPRECATED - hours from queuing time until job times out
+ timeout_mins: minutes from job queuing time until the job times out
max_runtime_hrs: DEPRECATED - hours from job starting time until job
times out
max_runtime_mins: minutes from job starting time until job times out
@@ -1020,8 +1021,11 @@
test_retry: Number of times to retry test if the test did not complete
successfully. (optional, default: 0)
"""
+ # TIMEOUT is deprecated.
DEFAULT_TIMEOUT = global_config.global_config.get_config_value(
- 'AUTOTEST_WEB', 'job_timeout_default', default=240)
+ 'AUTOTEST_WEB', 'job_timeout_default', default=24)
+ DEFAULT_TIMEOUT_MINS = global_config.global_config.get_config_value(
+ 'AUTOTEST_WEB', 'job_timeout_mins_default', default=24*60)
# MAX_RUNTIME_HRS is deprecated. Will be removed after switch to mins is
# completed.
DEFAULT_MAX_RUNTIME_HRS = global_config.global_config.get_config_value(
@@ -1071,6 +1075,8 @@
run_reset = dbmodels.BooleanField(default=True)
+ timeout_mins = dbmodels.IntegerField(default=DEFAULT_TIMEOUT_MINS)
+
# custom manager
objects = JobManager()
@@ -1148,6 +1154,9 @@
drone_set = DroneSet.resolve_name(options.get('drone_set'))
+ if options.get('timeout_mins') is None and options.get('timeout'):
+ options['timeout_mins'] = options['timeout'] * 60
+
job = cls.add_object(
owner=owner,
name=options['name'],
@@ -1155,7 +1164,9 @@
control_file=control_file,
control_type=options['control_type'],
synch_count=options.get('synch_count'),
+ # timeout needs to be deleted in the future.
timeout=options.get('timeout'),
+ timeout_mins=options.get('timeout_mins'),
max_runtime_mins=options.get('max_runtime_mins'),
run_verify=options.get('run_verify'),
email_list=options.get('email_list'),
diff --git a/frontend/migrations/082_job_add_timeout_mins.py b/frontend/migrations/082_job_add_timeout_mins.py
new file mode 100644
index 0000000..4caa26a
--- /dev/null
+++ b/frontend/migrations/082_job_add_timeout_mins.py
@@ -0,0 +1,8 @@
+UP_SQL = """
+ALTER TABLE afe_jobs ADD COLUMN timeout_mins integer NOT NULL;
+UPDATE afe_jobs SET timeout_mins = timeout * 60;
+"""
+
+DOWN_SQL = """
+ALTER TABLE afe_jobs DROP COLUMN timeout_mins;
+"""
\ No newline at end of file
diff --git a/global_config.ini b/global_config.ini
index 6bb63ed..4d5a66d 100644
--- a/global_config.ini
+++ b/global_config.ini
@@ -7,6 +7,7 @@
user: chromeosqa-admin
password: USE SHADOW PASSWORD
job_timeout_default: 24
+job_timeout_mins_default: 1440
job_max_runtime_mins_default: 1440
parse_failed_repair_default: 0
# Only set this if your server is not 'http://[SERVER] hostname/afe/'
diff --git a/scheduler/scheduler_models.py b/scheduler/scheduler_models.py
index 9442b79..c452430 100644
--- a/scheduler/scheduler_models.py
+++ b/scheduler/scheduler_models.py
@@ -827,7 +827,7 @@
'run_verify', 'email_list', 'reboot_before', 'reboot_after',
'parse_failed_repair', 'max_runtime_hrs', 'drone_set_id',
'parameterized_job_id', 'max_runtime_mins', 'parent_job_id',
- 'test_retry', 'run_reset')
+ 'test_retry', 'run_reset', 'timeout_mins')
_timer = stats.Timer("scheduler_models.Job")
# This does not need to be a column in the DB. The delays are likely to