Bug 952297 - PRD33 - ovirt-engine service re-work
Summary: PRD33 - ovirt-engine service re-work
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: 3.3.0
Assignee: Alon Bar-Lev
QA Contact: Ilanit Stein
URL:
Whiteboard: integration
Depends On: 954359
Blocks: 838527 959800 976171
TreeView+ depends on / blocked
 
Reported: 2013-04-15 15:33 UTC by Alon Bar-Lev
Modified: 2015-09-22 13:09 UTC (History)
10 users (show)

Fixed In Version: is1
Doc Type: Enhancement
Doc Text:
I am unsure this should go into docs. comment#0 should cover all required information.
Clone Of:
Environment:
Last Closed: 2014-01-21 17:17:31 UTC
oVirt Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2014:0038 0 normal SHIPPED_LIVE Important: Red Hat Enterprise Virtualization Manager 3.3.0 update 2014-01-21 22:03:06 UTC
oVirt gerrit 13033 0 None None None Never
oVirt gerrit 13034 0 None None None Never
oVirt gerrit 13413 0 None None None Never
oVirt gerrit 13414 0 None None None Never
oVirt gerrit 13415 0 None None None Never
oVirt gerrit 13418 0 None None None Never
oVirt gerrit 13427 0 None None None Never
oVirt gerrit 13435 0 None None None Never
oVirt gerrit 13485 0 None None None Never
oVirt gerrit 13488 0 None None None Never
oVirt gerrit 13495 0 None None None Never
oVirt gerrit 13496 0 None None None Never
oVirt gerrit 13497 0 None None None Never
oVirt gerrit 13587 0 None None None Never
oVirt gerrit 13626 0 None None None Never
oVirt gerrit 13627 0 None None None Never
oVirt gerrit 13628 0 None None None Never
oVirt gerrit 13643 0 None None None Never
oVirt gerrit 13645 0 None None None Never
oVirt gerrit 13646 0 None None None Never
oVirt gerrit 13647 0 None None None Never
oVirt gerrit 13663 0 None None None Never
oVirt gerrit 14151 0 None None None Never
oVirt gerrit 14152 0 None None None Never
oVirt gerrit 14153 0 None None None Never
oVirt gerrit 14154 0 None None None Never

Description Alon Bar-Lev 2013-04-15 15:33:12 UTC
BACKGROUND

Effort to port ovirt-engine to other distributions, such as upstart based and OpenRC based.

CURRENT IMPLEMENTATION

Custom python script to be used directly by sysvinit and systemd.
The script is complex as:
1. it expects be executed by root and fallback to correct engine account.
2. it forks into the background always, while downstream services such as upstart and systemd do not require that.
3. it exec() the java process (jboss) without waiting for it to exit, so it does not cleanup after execution.
4. it does not conform with other services when start and pid is not cleaned (bug#838527)
5. it cannot be fully used for development mode.
6. it implements its own daemon implementation, while python-daemon is available.
7. it parsed its own command-line parameters.
8. it did not use standard python logging module, but direct calls to syslog.
9. it used global variables, which in python are very complex to use. 

NEW IMPLEMENTATION

Use downstream services for maximum compatibility with distributions:
1. Execute as non privileged user
2. Set rlimit resources.
3. Remove the stop and status from the service code, as downstream services provide that.
4. Handle pid file only on downstreams that requires that, align with behavior of other services.
5. Wait for java process to exit in order to cleanup tmp, pid file and exit cleanly to downstream services.
6. Add foreground mode, add pid file-less mode, 

Cleanup service packaging.
Cleanup service build.
Major cleanup of service code (95% rewrite).
Added extensive logs and debug, added an option to debug messages.  
Added support to gettext to allow localization.

METHOD

To ease review the work was split into evolution type of patches, don't be alarmed from the number of patches.

Comment 1 Alon Bar-Lev 2013-04-15 15:34:41 UTC
packaging: service: do not use users from configuration if non-root

Comment 2 Alon Bar-Lev 2013-04-15 15:35:49 UTC
packaging: service: only verify engine user owned directories owner

In development mode directories will not be owned by root.

Comment 3 Alon Bar-Lev 2013-04-15 15:36:20 UTC
packaging: engine-service: recover from corrupted pid file

The case in which pidfile is empty is common.

Comment 4 Alon Bar-Lev 2013-04-15 15:37:01 UTC
packaging: engine-service: remove limits.d file

the limits.d file is not used as service applies rlimit on its own.

Comment 5 Alon Bar-Lev 2013-04-15 15:37:39 UTC
packaging: engine-service: allow service user customization

Comment 6 Alon Bar-Lev 2013-04-15 15:38:34 UTC
packaging: engine-service: use python daemon instead of own implementation

Comment 7 Alon Bar-Lev 2013-04-15 15:39:48 UTC
packaging: engine-service: rework start pid file handling

There is no reason to force user to explicit stop and start the service
in case pid file contains non running process.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=838527
Change-Id: I8d8a7f8f8b7f5941f447df3d279686b973b5c393
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 8 Alon Bar-Lev 2013-04-15 15:40:58 UTC
packaging: engine-service: add options for wrappers

In order to be used at other environments, with their own init.d layout,

Add:
--quiet
--pidfile
--foreground

Change-Id: I00d868fc51ec73800cae2eb24002feb933744851
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 9 Alon Bar-Lev 2013-04-15 15:41:43 UTC
packaging: engine-service: downstream infrastructure usage

Use features of downstream instead our own implementation.

systemd

1. detach from controlling terminal.
2. Change user/group.
3. stop service using signal.
4. set rlimit.

sysv

1. Change user/group.
2. stop service by pidfile.
3. set rlimit

systemd note:

As jboss return non zero error code when receiving SIGTERM, and systemd
expect processes to terminate with zero error code, we create a wrapper
over the java.

Change-Id: Ie02f0d44bbba7d1a7af6bcf6b808610e85b907c6
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 10 Alon Bar-Lev 2013-04-15 15:42:19 UTC
packaging: engine-service: remove dead code

Change-Id: Id520a0ff33e797b2995fb217754605c219f6a922
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 11 Alon Bar-Lev 2013-04-15 15:42:54 UTC
packaging: engine-service: set default service mode to foreground

this will ease developer when executing the service.

Change-Id: Ib7e5ffe4e104d2c3a0c931f3f344f7c3c12eb57f
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 12 Alon Bar-Lev 2013-04-15 15:43:30 UTC
packaging: engine-service: remove /usr/bin symlink

The engine-service script is not a utility to be used by user but by
downstream packager, hence no reason to install at /usr/bin.

Change-Id: I49fc25ad586b8f04e1588d04ab772858f2bfd169
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 13 Alon Bar-Lev 2013-04-15 15:44:12 UTC
packaging: engine-service: do not allow execution as non-root

all downstream has a mean to execute the script under the correct
account. So no need for us to change identity nor expect other user.

Change-Id: Ic30ce5316918a98bf2ef4cbf17d0eb91b85c74d1
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 14 Alon Bar-Lev 2013-04-15 15:44:51 UTC
packaging: engine-service: do not clean environment

the init system may put important variables in environment.

add LC_ALL as java is effected by AC_CTYPE per defaults of string
conversions, as if it is set by init it will effect us.

in practice we should only set LC_CTYPE or use jnu.encoding, when
we are sure that no default locale is used for conversions within
application.

Change-Id: Ia8231b343574df83e65c55d9ffa75698a3f2d692
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 15 Alon Bar-Lev 2013-04-15 15:45:24 UTC
packaging: engine-service: remove unused tmpfiles config

Change-Id: I81175c21f018be180157ffcaadef1dd28ee8801c
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 16 Alon Bar-Lev 2013-04-15 15:46:08 UTC
packaging: engine-service: move service to backend subpackage

Change-Id: I3df9c0f0d221d883c7a49b0c7f953a2ffde211c0
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 17 Alon Bar-Lev 2013-04-15 15:46:41 UTC
packaging: engine-service: major cleanup

Last patch in series of engine-service, after all core issues merged
into existing implementation, this introduce python only rework and
cleanups.

1. Removal global variable.
2. Previous patch already use python subprocess instead of direct exec.
3. Use python logging instead of direct syslog calls.
4. Add debug log.
5. Add debug parameter.
6. Add gettext support.
7. Modular functional.
8. Remove one time used variables.
9. Remove replication of configuration variable into local variables.
10. Remove dead code.
11. pyflakes free
12. pep8 complaint.

Change-Id: Iea45e8131190f41171e937699ec2e261939c4bd9
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 18 Alon Bar-Lev 2013-04-15 15:47:09 UTC
packaging: engine-service: fix systemd packaging per fedora requirements

Change-Id: I84d290d2cc389450be183cd85fb91ee1e58e4e9a
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 19 Alon Bar-Lev 2013-04-15 15:49:14 UTC
packaging: engine-service: clean /var/tmp in upgrade and cleanup

previous service implementation used mixed ownership of root/ovirt in
/var/tmp/ovirt-engine, /var/lib/ovirt-engine/deployments.

the /var/tmp/ovirt-engine was not cleared if daemon exited so likely to
remain.

new service implementation does not run under root account, so having
root owned resources is not healthy.

during upgrade setup correct setting, during setup remove leftovers, as
engine-cleanup not to be trusted as it does not actually revert to
initial state.

Change-Id: If0efa0b8a71673140490e2c363af7d3ba6044ffe
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 20 Alon Bar-Lev 2013-04-15 15:50:22 UTC
packaging: engine-service: cleanup: merge check for running process

Change-Id: I20238c634c418029c669bdf2b4b77e329b39faa1
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 21 Alon Bar-Lev 2013-04-15 15:52:30 UTC
Modified per future rebase.

Comment 22 Alon Bar-Lev 2013-04-25 09:25:57 UTC
packaging: engine-service: move service out of fedora into own directory

service is working in fedora, rhel, cenots, gentoo, ubuntu.

service resources are installed at one directory at target, reorder
filesystem structure within source tree to be similar.

Change-Id: I38c2653509795ae04c190c4a84f00f53410fa983
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 23 Alon Bar-Lev 2013-04-25 09:27:16 UTC
packaging: engine-service: split service to allow code reuse

this will allow to reuse effort to implement other services.

Change-Id: Ie912a502f220417e72efbd2f5b87c5674525f79b
Signed-off-by: Alon Bar-Lev <alonbl>

Comment 24 Alon Bar-Lev 2013-06-26 20:23:48 UTC
Got need-info but I cannot see this in bug.

How to test

this is drop-in replacement using re-implementation using downstream services.

existing tests should be sufficient.

Comment 25 yeylon@redhat.com 2013-06-26 21:32:12 UTC
thanks. ACKed

Comment 26 Ilanit Stein 2013-07-08 12:11:08 UTC
Verified on is3:

[root@istein-33 ~]# service ovirt-engine status
 (pid  27342) is running...
[root@istein-33 ~]# service ovirt-engine stop
Stopping oVirt Engine: 
                                                           [  OK  ]
[root@istein-33 ~]# service ovirt-engine start
Starting oVirt Engine:                                     [  OK  ]
[root@istein-33 ~]# service ovirt-engine status
 (pid  21751) is running...
[root@istein-33 ~]# kill -9 21751
[root@istein-33 ~]# service ovirt-engine status
 dead but pid file exists

Comment 27 Charlie 2013-11-28 00:11:22 UTC
This bug is currently attached to errata RHEA-2013:15231. If this change is not to be documented in the text for this errata please either remove it from the errata, set the requires_doc_text flag to minus (-), or leave a "Doc Text" value of "--no tech note required" if you do not have permission to alter the flag.

Otherwise to aid in the development of relevant and accurate release documentation, please fill out the "Doc Text" field above with these four (4) pieces of information:

* Cause: What actions or circumstances cause this bug to present.
* Consequence: What happens when the bug presents.
* Fix: What was done to fix the bug.
* Result: What now happens when the actions or circumstances above occur. (NB: this is not the same as 'the bug doesn't present anymore')

Once filled out, please set the "Doc Type" field to the appropriate value for the type of change made and submit your edits to the bug.

For further details on the Cause, Consequence, Fix, Result format please refer to:

https://bugzilla.redhat.com/page.cgi?id=fields.html#cf_release_notes 

Thanks in advance.

Comment 28 errata-xmlrpc 2014-01-21 17:17:31 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2014-0038.html


Note You need to log in before you can comment on or make changes to this bug.