disabled daemons are started after refresh

Bug #1818306 reported by Ian Johnson
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
snapd
Fix Released
High
Ian Johnson

Bug Description

If a snap is installed with a daemon, then the daemon is stopped and disabled, snapd will always re-start and re-enable the daemon after the snap is refreshed.

See:

snapcraft.yaml:
```
name: test
version: "1.0.0"
summary: test snapd disabled daemons refresh
description: test snapd disabled daemons refresh
grade: stable
confinement: strict
apps:
    test1:
        command: bin
        daemon: simple
parts:
   part:
     plugin: nil
     override-build: |
         touch ${SNAPCRAFT_PART_INSTALL}/bin
         echo "#!/bin/sh" >> ${SNAPCRAFT_PART_INSTALL}/bin
         echo "sleep 1000" >> ${SNAPCRAFT_PART_INSTALL}/bin
         chmod +x ${SNAPCRAFT_PART_INSTALL}/bin
```

Installing the snap:

$ snap install test_1.0.0_amd64.snap --dangerous
test 1.0.0 installed
$ snap services test
Service Startup Current Notes
test.test1 enabled active -
$ snap stop --disable test.test1
Stopped.
$ snap services test
Service Startup Current Notes
test.test1 disabled inactive -
$ snap install test_1.0.0_amd64.snap --dangerous
test 1.0.0 installed
$ snap services test
Service Startup Current Notes
test.test1 enabled active -

Revision history for this message
Ian Johnson (anonymouse67) wrote :

Note: I see this behavior with both the stable channel of the core snap (revision 6405 - snapd version 2.37.2) and also with the edge channel of the core snap.

Revision history for this message
Ian Johnson (anonymouse67) wrote :

This also happens on a revert and still happens with snapd 2.38

Revision history for this message
Ian Johnson (anonymouse67) wrote :

A somewhat hacky workaround for this is to save the state of the services that ought to be disabled in config settings, then in the configure hook stop and disable those services based on the state in the config settings.
This isn't a full fix because after a refresh, all services are still started (and the install is still aborted if any of them fail), but at least with this workaround after the refresh tasks run the services that were disabled will be disabled again. This assumes that the services can at least "somewhat start" such that the installation doesn't get aborted however.

Revision history for this message
Ian Johnson (anonymouse67) wrote :

This also happens when calling `snap disable snap-name` and then doing `snap enable snap-name`, i.e. this flow is broken:

```
$ snap install test_1.0.0_amd64.snap --dangerous
test 1.0.0 installed
$ snap services test
Service Startup Current Notes
test.test1 enabled active -
$ snap stop --disable test.test1
Stopped.
$ snap services test
Service Startup Current Notes
test.test1 disabled inactive -
$ snap disable test
test disabled
$ snap enable test
test enabled
$ snap services test
Service Startup Current Notes
test.test1 enabled active -
```

Changed in snapd:
assignee: nobody → Ian Johnson (anonymouse67)
Changed in snapd:
status: New → Confirmed
Changed in snapd:
status: Confirmed → In Progress
importance: Undecided → High
Changed in snapd:
status: In Progress → Fix Committed
milestone: none → 2.43
Changed in snapd:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.