Commit fc31c117 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Fix cleaned joblog remove.

parent 8b508476
Pipeline #27576 passed with stages
in 2 minutes and 41 seconds
......@@ -47,7 +47,9 @@ def main():
help="Clean logs before start",
clean.add_argument("--before", help="DateTime before log will be deleted", required=False)
clean.add_argument("--last", type=int, help="Cleanup joblog to last N record", required=False, default=10)
"--last", type=int, help="Cleanup joblog to last N record", required=False, default=10
args = parser.parse_args()
if args.cmd == "list":
......@@ -112,7 +114,11 @@ def joblog_clean(args):
cleaned_job = JobLog.filter(start_ts__gte=before, is_complete=True)
print(" %d JobLog before %s will be cleaned" % (cleaned_job.count(), args.before))
elif args.last and joblog_count > args.last:
cleaned_job = JobLog.filter(is_complete=True).order_by(("start_ts", "DESC")).limit(joblog_count - args.last)
cleaned_job = (
.limit(joblog_count - args.last)
print(" %d JobLog more %s will be cleaned" % (cleaned_job.count(), args.last))
die("Please set cleanup policy")
......@@ -121,8 +127,8 @@ def joblog_clean(args):
print("%d\n" % i)
for job in cleaned_job:
if __name__ == '__main__':
if __name__ == "__main__":
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment