= Bodhi Infrastructure Releng SOP

Bodhi is used by Fedora developers to submit potential package updates
for releases and to manage buildroot overrides. From here, bodhi handles
all of the dirty work, from sending around emails, dealing with Koji, to
composing the repositories.

Bodhi production instance: https://bodhi.fedoraproject.org

Bodhi project page: https://github.com/fedora-infra/bodhi

== Contents

* <<_contact_information>>
* <<_configuring_all_bodhi_nodes>>
* <<_pushing_updates>>
* <<_monitoring_the_bodhi_composer_output>>
* <<_resuming_a_failed_push>>
* <<_adding_notices_to_the_front_page_or_new_update_form>>
* <<_using_the_bodhi_shell_to_modify_updates_by_hand>>

== Contact Information

Owner::
  Fedora Infrastructure Team
Contact::
  #fedora-admin
Location::
  iad2
Servers::
  * bodhi-backend01.iad2.fedoraproject.org (composer)
  * bodhi.fedoraproject.org (web front end and backend task workers for
  non-compose tasks)
  * bodhi-backend01.stg.iad2.fedoraproject.org (staging composer)
  * bodhi.fedoraproject.org (staging web front end and backend task
  workers for non-compose tasks)
Purpose::
  Push package updates, and handle new submissions.

== Configuring all bodhi nodes

Run this command from the _ansible_ checkout to configure
all of bodhi in production:

....
# This will configure the backends
$ sudo rbac-playbook playbooks/groups/bodhi2.yml
# This will configure the frontend
$ sudo rbac-playbook openshift-apps/bodhi.yml
....

== Pushing updates

SSH into the `bodhi-backend01` machine and run:

....
$ sudo -u apache bodhi-push
....

You can restrict the updates by release and/or request:

....
$ sudo -u apache bodhi-push --releases f23,f22 --request stable
....

You can also push specific builds:

....
$ sudo -u apache bodhi-push --builds openssl-1.0.1k-14.fc22,openssl-1.0.1k-14.fc23
....

This will display a list of updates that are ready to be pushed.

== Monitoring the bodhi composer output

You can monitor the bodhi composer via the `bodhi` CLI tool, or via the
systemd journal on `bodhi-backend01`:

....
# From the comfort of your own laptop.
$ bodhi composes list
# From bodhi-backend01
$ journalctl -f -u bodhi-celery
....

== Resuming a failed push

If a push fails for some reason, you can easily resume it on
`bodhi-backend01` by running:

....
$ sudo -u apache bodhi-push --resume
....

== Adding notices to the front page or new update form

You can easily add notification messages to the front page of bodhi
using the _frontpage_notice_ option in
_ansible/roles/bodhi2/base/templates/production.ini.j2_. If
you want to flash a message on the New Update Form, you can use the
_newupdate_notice_ variable instead. This can be useful for
announcing things like service outages, etc.

== Using the Bodhi Shell to modify updates by hand

The "bodhi shell" is a Python shell with the SQLAlchemy session and
transaction manager initialized. It can be run from any
production/staging backend instance and allows you to modify any models
by hand.

....
sudo pshell /etc/bodhi/production.ini

# Execute a script that sets up the `db` and provides a `delete_update` function.
# This will eventually be shipped in the bodhi package, but can also be found here.
# https://raw.githubusercontent.com/fedora-infra/bodhi/develop/tools/shelldb.py
>>> execfile('shelldb.py')
....

At this point you have access to a _db_ SQLAlchemy Session
instance, a _t_ _transaction module_, and
_m_ for the _bodhi.models_.

....
# Fetch an update, and tweak it as necessary.
>>> up = m.Update.get(u'u'FEDORA-2016-4d226a5f7e', db)

# Commit the transaction
>>> t.commit()
....

Here is an example of merging two updates together and deleting the
original.

....
>>> up = m.Update.get(u'FEDORA-2016-4d226a5f7e', db)
>>> up.builds
[<Build {'epoch': 0, 'nvr': u'resteasy-3.0.17-2.fc24'}>, <Build {'epoch': 0, 'nvr': u'pki-core-10.3.5-1.fc24'}>]
>>> b = up.builds[0]
>>> up2 = m.Update.get(u'FEDORA-2016-5f63a874ca', db)
>>> up2.builds
[<Build {'epoch': 0, 'nvr': u'resteasy-3.0.17-3.fc24'}>]
>>> up.builds.remove(b)
>>> up.builds.append(up2.builds[0])
>>> delete_update(up2)
>>> t.commit()
....
