1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-13 17:16:23 +01:00

Fix single service disabled run

Without this patch, running an individual service that has parameters
defined in the _service file fails:

  $ osc service run obs_scm
  Please specify valid --scm=... options
  Aborting: service call failed:  /usr/lib/obs/service/obs_scm --outdir [snipped]

This is because although the service is defined in the _service file and
the "scm" parameter is set in it, the service wasn't being found in the
data structure and so the service executable wasn't being called with
the parameters supplied in the _service file. This patch corrects the
issue with the services data structure so that the service data isn't
overridden if it is defined in the _service file.

A side effect of this correction for services defined in the _service
file is that instead of overriding the service mode with '', the mode is
taken from the _service file. When using the "run" command, this would
mean that the call mode of None may not be in agreement with the service
mode defined in the file, e.g. "manual", and so the "run" command would
no longer cause it to run when it would before. We can take this
opportunity to define this as the correct behavior - the "run" command
now only runs services with "trylocal", "localonly", or no mode set -
and also ensure that other call mode commands result in sensible
behavior when called with a service name, for instance "osc service
manualrun download_files" will run only services with mode="manual" and
name="download"files" instead of all services with mode="manual".
Additionally, services that aren't defined in the _service file can be
called with a call mode command and will use that call mode rather than
None.
This commit is contained in:
Colleen Murphy 2020-03-16 14:13:15 -07:00
parent 7612fe1614
commit cb6eaf3720
2 changed files with 11 additions and 8 deletions

View File

@ -6938,18 +6938,20 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc service COMMAND (inside working copy)
osc service run [SOURCE_SERVICE]
osc service runall
osc service localrun
osc service disabledrun
osc service manualrun [SOURCE_SERVICE]
osc service localrun [SOURCE_SERVICE]
osc service disabledrun [SOURCE_SERVICE]
osc service remoterun [PROJECT PACKAGE]
osc service merge [PROJECT PACKAGE]
osc service wait [PROJECT PACKAGE]
COMMAND can be:
run r run defined services locally, it takes an optional parameter to run only a
run r run defined services with modes "trylocal", "localonly", or no mode set locally, may take an optional parameter to run only a
specified source service. In case parameters exist for this one in _service file
they are used.
runall ra run all services independent of the used mode
manualrun mr run all services with mode "manual"
manualrun mr run all services with mode "manual", may take an optional parameter to run only a
specified source service
remoterun rr trigger a re-run on the server side
merge commits all server side generated files and drops the _service definition
wait waits until the service finishes and returns with an error if it failed

View File

@ -422,10 +422,13 @@ class Serviceinfo:
os.unlink(ent)
allservices = self.services or []
if singleservice and not singleservice in allservices:
service_names = [s['name'] for s in allservices]
if singleservice and singleservice not in service_names:
# set array to the manual specified singleservice, if it is not part of _service file
data = { 'name' : singleservice, 'command' : [ singleservice ], 'mode' : '' }
data = { 'name' : singleservice, 'command' : [ singleservice ], 'mode' : callmode }
allservices = [data]
elif singleservice:
allservices = [s for s in allservices if s['name'] == singleservice]
if not allservices:
# short-circuit to avoid a potential http request in vc_export_env
@ -449,8 +452,6 @@ class Serviceinfo:
ret = 0
for service in allservices:
if callmode != "all":
if singleservice and service['name'] != singleservice:
continue
if service['mode'] == "buildtime":
continue
if service['mode'] == "serveronly" and callmode != "local":