parse_known_args() silently consumes -w and all --watch-* flags
before subcommand arguments reach the command validator. When a
user ran "ceph orch ps -w", the watch handler entered cluster log
streaming mode while discarding the subcommand entirely, with no
error or indication that the orch ps command was ignored.
Add a guard at the entry of the watch handler: if any watch flag
is active and childargs is non-empty, print "Invalid command:
unused arguments: [...]" and return EINVAL. This matches the
behaviour already seen when -s/--status is combined with a
subcommand.
Assisted-by: Claude:claude-4.6-sonnet
Fixes: https://tracker.ceph.com/issues/77121
Signed-off-by: Yonatan Zaken <yzaken@redhat.com>
elif k != "watch_channel":
level = k.replace('watch_', '')
if level:
+ if childargs:
+ print('Invalid command: unused arguments: {0}'.format(childargs), file=sys.stderr)
+ return errno.EINVAL
# an awfully simple callback
def watch_cb(arg, line, channel, name, who, stamp_sec, stamp_nsec, seq, level, msg):
# Filter on channel