#41 [backend] make systemd services out of ActionDispatcher and BuildDispatcher
Merged 7 years ago by clime. Opened 7 years ago by clime.
Unknown source robust_backend  into  master

@@ -26,7 +26,7 @@

  

  class CoprBackend(object):

      """

-     Core process - starts/stops dispatchers for actions and builds

+     COPR backend head process.

  

      :param config_file: path to the backend configuration file

      :param ext_opts: additional options for backend
@@ -66,12 +66,6 @@

              self.log.exception(err)

              raise CoprBackendError(err)

  

-         build_dispatcher = BuildDispatcher(self.opts)

-         action_dispatcher = ActionDispatcher(self.opts)

- 

-         build_dispatcher.start()

-         action_dispatcher.start()

- 

  

  def run_backend(opts):

      """

@@ -203,19 +203,13 @@

  

  %post

  %systemd_post copr-backend.service

- %systemd_post copr-backend-vmm.service

- %systemd_post copr-backend-log.service

  %systemd_post logstash.service

  

  %preun

  %systemd_preun copr-backend.service

- %systemd_preun copr-backend-vmm.service

- %systemd_preun copr-backend-log.service

  

  %postun

  %systemd_postun_with_restart copr-backend.service

- %systemd_postun_with_restart copr-backend-vmm.service

- %systemd_postun_with_restart copr-backend-log.service

  

  %files

  %license LICENSE

@@ -0,0 +1,12 @@

+ #!/usr/bin/python2

+ # coding: utf-8

+ 

+ from backend.daemons.action_dispatcher import ActionDispatcher

+ from backend.helpers import get_backend_opts

+ 

+ def main():

+     action_dispatcher = ActionDispatcher(get_backend_opts())

+     action_dispatcher.run()

+ 

+ if __name__ == "__main__":

+     main()

@@ -0,0 +1,12 @@

+ #!/usr/bin/python2

+ # coding: utf-8

+ 

+ from backend.daemons.build_dispatcher import BuildDispatcher

+ from backend.helpers import get_backend_opts

+ 

+ def main():

+     build_dispatcher = BuildDispatcher(get_backend_opts())

+     build_dispatcher.run()

+ 

+ if __name__ == "__main__":

+     main()

@@ -0,0 +1,15 @@

+ [Unit]

+ Description=Copr Backend service, Action Dispatcher component

+ After=syslog.target network.target auditd.service

+ Before=copr-backend.service

+ PartOf=copr-backend.service

+ 

+ [Service]

+ Type=simple

+ Environment="PYTHONPATH=/usr/share/copr/"

+ User=copr

+ Group=copr

+ ExecStart=/usr/bin/copr_run_action_dispatcher.py

+ 

+ [Install]

+ WantedBy=multi-user.target

@@ -0,0 +1,15 @@

+ [Unit]

+ Description=Copr Backend service, Build Dispatcher component

+ After=syslog.target network.target auditd.service

+ Before=copr-backend.service

+ PartOf=copr-backend.service

+ 

+ [Service]

+ Type=simple

+ Environment="PYTHONPATH=/usr/share/copr/"

+ User=copr

+ Group=copr

+ ExecStart=/usr/bin/copr_run_build_dispatcher.py

+ 

+ [Install]

+ WantedBy=multi-user.target

@@ -2,6 +2,7 @@

  Description=Copr Backend service, Log Handler component

  After=syslog.target network.target auditd.service

  Before=copr-backend.service copr-backend-vmm.service

+ PartOf=copr-backend.service

  

  [Service]

  Type=simple

@@ -2,6 +2,7 @@

  Description=Copr Backend service, Virtual Machine Management component

  After=syslog.target network.target auditd.service

  Before=copr-backend.service

+ PartOf=copr-backend.service

  

  [Service]

  Type=simple

@@ -1,10 +1,11 @@

  [Unit]

- Description=Copr Backend service, Workers controller

+ Description=Copr Backend service

  After=syslog.target network.target auditd.service

- Requires=copr-backend-vmm.service copr-backend-log.service

+ Requires=copr-backend-vmm.service copr-backend-log.service copr-backend-build.service copr-backend-action.service

  

  [Service]

- Type=simple

+ Type=oneshot

+ RemainAfterExit=True

Is this RemainAfterExit statement really needed?

clime commented 7 years ago

It is not needed but with this the service shows as active (exited). (without it shows as inactive (dead) after it has been successufully run). Also, this setting is recommended to use with "Type=oneshot".

Ah, thanks for the info.

  PIDFile=/var/run/copr-backend/copr-be.pid

  Environment="PYTHONPATH=/usr/share/copr/"

  User=copr

This pull request enables a COPR admin to start/stop COPR components individually. This might be useful for error recovery in case some component stops functioning properly. COPR components currently include: copr-backend-action (Action dispatcher), copr-backend-build (Build dispatcher), copr-backend-log (Redis Log handler), and copr-backend-vmm (Virtual Machine manager).

Is this RemainAfterExit statement really needed?

I can not verify there's no bug in service inter-dependencies, but it seems like this could be bug-fixed later. So it looks like good idea to me, thanks!

Btw., I was about to complain about SELinux fixes ... but backend seems to be run unconfined :) .. I did not know this till now (so I filled 1430459).

It is not needed but with this the service shows as active (exited). (without it shows as inactive (dead) after it has been successufully run). Also, this setting is recommended to use with "Type=oneshot".

Btw., I was about to complain about SELinux fixes ... but backend seems to be run unconfined :) .. I did not know this till now (so I filled 1430459).

What selinux fixes in particular?

There should be really nothing wrong with selinux at the moment. As you reported, backend runs unconfined. If there is anything else, please, let me know.

Pull-Request has been merged by clime

7 years ago

Right, I missed your question, sorry.

This change added new scripts which should be confined ... but as we have nothing confined in copr-backend, it is not an immediate issue.