servo: Add verifier that removes old servod log files.
The servod log rotation tends to leave behind a bunch of old files,
and can use a lot of disk space. Since autotest already saves the
most recent parts of the logs, it's good to clean up old ones,
including any from servod instances that are no longer running.
BUG=chromium:1024065
TEST=Run firmware_FAFTRPC.system or other test against servod on a labstation.
Change-Id: Id90fd8ed95188e94cd1203d9aed2df79dfc8514a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/1938015
Tested-by: Dana Goyette <dgoyette@chromium.org>
Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Commit-Queue: Dana Goyette <dgoyette@chromium.org>
diff --git a/server/hosts/servo_repair.py b/server/hosts/servo_repair.py
index c24f46e..f553be2 100644
--- a/server/hosts/servo_repair.py
+++ b/server/hosts/servo_repair.py
@@ -194,6 +194,22 @@
return 'servod upstart job is running'
+class _ServodLogsVerifier(hosts.Verifier):
+ """
+ Clean up old servod logs
+ """
+ KEEP_LOGS_MAX_DAYS = 5
+
+ def verify(self, host):
+ host.run(
+ '/usr/bin/find /var/log/servod_* -mtime +%d -print -delete'
+ % self.KEEP_LOGS_MAX_DAYS, ignore_status=True)
+
+ @property
+ def description(self):
+ return 'old servod logs removed'
+
+
class _ServodConnectionVerifier(hosts.Verifier):
"""
Verifier to check that we can connect to `servod`.
@@ -363,6 +379,7 @@
config = ['brd_config', 'ser_config']
verify_dag = [
(repair_utils.SshVerifier, 'servo_ssh', []),
+ (_ServodLogsVerifier, 'servod_logs', ['servo_ssh']),
(_UpdateVerifier, 'update', ['servo_ssh']),
(_BoardConfigVerifier, 'brd_config', ['servo_ssh']),
(_SerialConfigVerifier, 'ser_config', ['servo_ssh']),