#4486 CLI: add override option to assign-task
Merged by mikem. Opened by jcupova.
jcupova/koji issue-4465  into  master

Download 4486.patch

Fixes: https://pagure.io/koji/issue/4465

The help text could be shorter. The "specify override to..." lead-in is redundant since this is the help text for that very option. I would use just "prevent the scheduler from reassigning later".

options.override is already either True for False. The three lines that set override to match this value are redundant. I see that you're cloning the code for the force option above, but that code is also redundant; there's no sense in repeating the mistake in the older code.

However, we do need to have some special handling of the override option here. It was added in 1.34 (in pr #3980). While I certainly hope that folks are keeping their Koji systems up to date, it would be nicer to preserve compatibility here. We should probably only pass the arg if it is needed.

rebased onto ff90fb9bf146962c04e0720f1fa3dbf4aba42bd3

@mikem all should be fixed.

And yes, I saw redundant lines for force and I was thinking about some special meaning. And I added it also for override, for sure :-D. But now, for force and override, I dropped it.

Your fallback case silently ignores the --override option.

try:
    ret = session.assignTask(task_id, hostname, options.force, options.override)
except koji.ParameterError:
    # override option added in 1.36
    ret = session.assignTask(task_id, hostname, options.force)

(also the comment about which version added the option is incorrect)

In my previous comment, I wrote this:

We should probably only pass the arg if it is needed.

There are a few different ways that we have implemented backwards compatibility in the cli, including:

  • catching ParameterError
  • catching GenericError
  • checking hub_version
  • only passing new options when explicitly requested by the user
  • a combination of these

Which approach is best depends on the situation. In this case, I think it is best to only pass the new option when it is requested by the user. This is often simplest when use of the new option is governed by a user parameter.

rebased onto ff90fb9bf146962c04e0720f1fa3dbf4aba42bd3

rebased onto ff90fb9bf146962c04e0720f1fa3dbf4aba42bd3

rebased onto bd05c42e388e782f2594c863e73ad5fce4aa4bc5

Just a couple minor things, otherwise looks good

+    parser.add_option('--override', action='store_true', dest="override", default=False,
+                      help='prevent the scheduler from reassigning later')
     (options, args) = parser.parse_args(args)

The dest="override" is redundant. The option name is already override.

if options.override:
    # override option added in 1.36
    kwargs['override'] = options.override

It was added in 1.34

rebased onto bd05c42e388e782f2594c863e73ad5fce4aa4bc5

rebased onto bd05c42e388e782f2594c863e73ad5fce4aa4bc5

@mikem updated

:thumbsup:

Metadata Update from @mikem:
- Pull-request tagged with: testing-basic

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

Commit 68f7f97b fixes this pull-request

Pull-Request has been merged by mikem

Metadata