Replace session upstart in the desktop session

Registered by Martin Pitt

We moved system init to systemd a while ago, but we still have and maintain the upstart package for the session startup. As this is unmaintained, we should remove this dependency by the next LTS.

Discuss and investigate what we currently use upstart for, what the original reasons were for moving away from gnome-session and/or D-Bus activation, and check how we can migrate the user upstart jobs to something else (gnome-session/xdg-autostart, D-BUS activation, or the user systemd).

Blueprint information

Status:
Started
Approver:
Sebastien Bacher
Priority:
Undefined
Drafter:
Martin Pitt
Direction:
Needs approval
Assignee:
Dimitri John Ledkov
Definition:
Review
Series goal:
Accepted for zesty
Implementation:
Good progress
Milestone target:
milestone icon ubuntu-16.08
Started by
Martin Pitt

Whiteboard

Rationale for upstartification
--------------------------------------
- auto-restart services when they crash, with respawn limit
- moved away from dbus-daemon as service management didn't give us what we need, e. g. indicators need to start by themselves
- conditional starting of services (xdg-autostart can only do some conditions, such as gsettings)
- better logging (separate logs by process)

Requirements
------------------
- dbus-activation+gnome-session is not sufficient (see above), thus if we want to drop upstart we need to use systemd --user
- want to migrate step by step, not flag day: packages add systemd user session units and drop or disable the corresponding upstart job
- only one graphical session per user (lightdm/gdm never supported multiple ones)
- we can move some things back to dbus activation (e. g. gnupg-agent)

Using systemd --user
----------------------------
This is normally designed for services that apply to/run across all login sessions. E. g. gvfs and pulseaudio already ship/use systemd user services, and there is no need to have one instance of them for every session. But this approach does not work for graphical applications which are specific to the X.org/Mir login session. Thus we only start/stop the umbrella systemd "graphical session" unit via the /usr/share/xsession/*.desktop's Exec= line, not already with the first-ever login session for a user.

Implementation steps
----------------------------
 - Martin will create the skeleton for this and a PoC with one or two converted services.
 - Review this PoC with Seb, Iain, and Dimitri for possible improvements
 - Have a 3-day virtual or IRL sprint to convert the other upstart jobs.

PPA for yakkety: https://launchpad.net/~ubuntu-desktop/+archive/ubuntu/systemd-session
Code for infra and staging units before moving them out into packages: https://git.launchpad.net/~ubuntu-desktop/+git/systemd-graphical-session/
Landing of all indicators and hud: https://bileto.ubuntu.com/#/ticket/1710

Links
-------
https://wiki.gnome.org/ThreePointThirteen/Features/SystemdUserSession
https://mail.gnome.org/archives/desktop-devel-list/2014-January/msg00079.html
discussion about using systemd --user for sessions: https://lists.freedesktop.org/archives/systemd-devel/2016-May/036440.html
https://github.com/systemd/systemd/pull/3678
relevant bugs: https://bugs.launchpad.net/ubuntu/+bugs?field.tag=systemd-session

(?)

Work Items

Work items for ubuntu-16.06:
[pitti] check that systemd user units can apply ApparmorProfile= (yes, works): DONE
[pitti] fix /usr/share/upstart/sessions/dbus.conf to not launch another session bus with dbus-user-session installed: DONE
[pitti] develop prototype systemd-graphical-session package with the structure and a few example units that suppress the corresponding upstart jobs: DONE
[pitti] fix /etc/X11/Xsession.d/90atk-adaptor to also export to dbus/user systemd: DONE

Work items for ubuntu-16.07:
[pitti] discuss where to finally place the infra: DONE
port at-spi2-core: DONE
[pitti] port bamf (in CI train): DONE
port cgmanager (obsolete): POSTPONED
port click (busted in yakkety due to packagekit update): POSTPONED
[laney] port gnome-keyring: DONE
[pitti] port gnome-session: DONE
[pitti] port gnupg2: DONE
[pitti] port im-config: DONE
[pitti] port openssh (Debian #832445): DONE
[laney] port session-migration: DONE
[seb128] port update-notifier: DONE
[pitti] port xfce4-session: DONE
[pitti] port xubuntu-default-settings: DONE
[pitti] check kubuntu (not using upstart): DONE
[pitti] check lubuntu (not using upstart): DONE
[pitti] check/fix xubuntu (using upstart): DONE
[pitti] check ubuntu-gnome (not using upstart): DONE
[pitti] fix hanging shutdown, waiting for user@1000.slice processes: DONE
[pitti] virtualbox (qt?) theming is wrong, needs to export GNOME_DESKTOP_SESSION_ID in gnome-session.service: DONE
[seb128] polkit not working with dbus-user-session (https://bugs.freedesktop.org/show_bug.cgi?id=96977, patch sent): DONE

Work items for ubuntu-16.08:
[laney] port unity-gtk-module: DONE
[pitti] port unity-settings-daemon: DONE
[ted] port unity: DONE
[laney] gnome-keyring does not shut down with session (https://bugzilla.gnome.org/show_bug.cgi?id=768943): DONE
port lubuntu-default-settings (optional, lubuntu does not install upstart): POSTPONED
[pitti] check ubuntustudio (using upstart, XFCE based): DONE
[pitti] check mythbuntu (N/A, not using upstart): DONE
[pitti] check ubuntu-mate (N/A, not using upstart): DONE
[pitti] check unity8: DONE

Work items for ubuntu-16.10:
[pitti] replace run-systemd-session's polling loop with something tasteful (https://github.com/systemd/systemd/pull/4098): DONE

Work items for ubuntu-16.11:
[seb128] port hud (https://code.launchpad.net/~seb128/hud/systemd-for-session): DONE
[ted] port indicator-application: DONE
[ted] port indicator-bluetooth: DONE
[ted] port indicator-datetime: DONE
[ted] port indicator-display: DONE
[ted] port indicator-keyboard: DONE
[ted] port indicator-location: DONE
[ted] port indicator-messages: DONE
[ted] port indicator-network: DONE
[ted] port indicator-power: DONE
[pitti] (tedg) port indicator-printers, (pitti) fix unity-services to pull it in and land it: DONE
[ted] port indicator-session: DONE
[ted] port indicator-sound: DONE
[ted] port indicator-transfer: DONE
[pitti] find out what starts another local session D-Bus in unity-greeter session and fix it: DONE

Work items for ubuntu-16.12:
[pitti] port unity-greeter session (https://code.launchpad.net/~pitti/unity-greeter/systemd-indicators/+merge/309321) (landed, but blocked on unrelated test failure, Robert is investigating): DONE

Work items for ubuntu-17.01:
[ted] port ubuntu-app-launch to use systemd units: TODO
[seb128] port gnome-settings-daemon: TODO
port account-polld: TODO
port address-book-service: TODO
port buteo-syncfw: TODO
port ciborium: TODO
port history-service: TODO
port libertine: TODO
port location-service: TODO
port lxc-android-config: TODO
port media-hub: TODO
port mediascanner2: TODO
port msva-perl: TODO
port mtp: TODO
port nuntium: TODO
port pay-service: TODO
port policykit-unity8: TODO
port sync-monitor: TODO
port telephony-service: TODO
port tone-generator: TODO
port ubuntu-push: TODO
port ubuntu-touch-customization-hooks: TODO
port ubuntu-touch-session: TODO
port unity-greeter-session-broadcast: TODO
[xnox] port unity-scope-click (https://code.launchpad.net/~xnox/unity-scope-click/systemd/+merge/313713): INPROGRESS
port unity-scopes-api: TODO
port unity8: TODO
port url-dispatcher: TODO
port usensord: TODO