Merge pull request 'More selection options in scheduler-logs cli' (#4561) from scheduler-logs-cli-options into master
All checks were successful
/ tests (fedora-44@sha256:5e1187ee4536674e08961cbe6b1b84dfc9df15a513dee328365909be5a0d5ed8) (push) Successful in 1m9s
/ tests (fedora-43@sha256:cf1ef55da0d7dd9251b79263c4d1e2350d4291fcd6dc54a1e751d3fe2cf4614d) (push) Successful in 1m11s
/ tests (centos-9@sha256:c5fe30a62d4b62b46acdf764bf1f7293e9fa4287972ec6a86ccb43209646dc32) (push) Successful in 2m41s
/ tests (centos-10@sha256:1f53b2b040e449b0cfce526f1a221e6dbd6648506270220ea333728a6b52a90b) (push) Successful in 1m55s
/ tests (fedora-rawhide@sha256:5e1187ee4536674e08961cbe6b1b84dfc9df15a513dee328365909be5a0d5ed8) (push) Successful in 55s
/ flake8 (push) Successful in 18s
/ bandit (push) Successful in 18s

Reviewed-on: #4561
Reviewed-by: Tomas Kopecek <tkopecek@redhat.com>
This commit is contained in:
Mike McLean 2026-07-17 15:47:12 +00:00
commit ab11f28684

View file

@ -8661,10 +8661,18 @@ def handle_scheduler_logs(goptions, session, args):
"[monitor] Query scheduler logs"
usage = "usage: %prog scheduler-logs <options>"
parser = OptionParser(usage=get_usage_str(usage))
parser.add_option("--task", type="int", action="store",
parser.add_option("--task", type="int", action="append",
help="Filter by task ID")
parser.add_option("--host", type="str", action="store",
parser.add_option("--host", type="str", action="append",
help="Filter by host (name/ID)")
parser.add_option("--channel", type="str", action="append",
help="Filter by channel (name/ID)")
parser.add_option("--arch", type="str", action="append",
help="Filter by arch")
parser.add_option("--method", type="str", action="append",
help="Filter by method")
parser.add_option("--owner", type="str", action="append",
help="Filter by owner")
parser.add_option("--from", type="float", action="store", dest="from_ts",
help="Logs from given timestamp")
parser.add_option("--to", type="float", action="store", dest="to_ts",
@ -8679,13 +8687,38 @@ def handle_scheduler_logs(goptions, session, args):
clauses = []
if options.task:
clauses.append(['task_id', options.task])
clauses.append(['task_id', 'IN', options.task])
if options.host:
try:
host_id = int(options.host)
except ValueError:
host_id = session.getHost(options.host)['id']
clauses.append(['host_id', host_id])
hosts = []
for host in options.host:
try:
host_id = int(host)
except ValueError:
host_id = session.getHost(host, strict=True)['id']
hosts.append(host_id)
clauses.append(['host_id', 'IN', hosts])
if options.channel:
channels = []
for chan in options.channel:
try:
chan_id = int(chan)
except ValueError:
chan_id = session.getChannel(chan, strict=True)['id']
channels.append(chan_id)
clauses.append(['channel_id', 'IN', channels])
if options.arch:
clauses.append(['arch', 'IN', options.arch])
if options.method:
clauses.append(['method', 'IN', options.method])
if options.owner:
users = []
for user in options.owner:
try:
user_id = int(user)
except ValueError:
user_id = session.getUser(user, strict=True)['id']
users.append(user_id)
clauses.append(['owner', 'IN', users])
if options.from_ts:
clauses.append(['msg_ts', '>=', options.from_ts])
if options.to_ts:
@ -8715,8 +8748,12 @@ def handle_scheduler_logs(goptions, session, args):
for log in logs:
log['time'] = time.asctime(time.localtime(log['msg_ts']))
if log['task_id'] is None:
log['task_id'] = '-'
if log['host_name'] is None:
log['host_name'] = '-'
mask = ("%(task_id)-10s %(host_name)-20s %(time)-25s %(msg)-30s")
mask = ("%(time)-25s %(task_id)-10s %(host_name)-20s %(msg)-30s")
if not goptions.quiet:
h = mask % {
'task_id': 'Task',