Skip to content

Startup fails on first attempt after service update — aos-unit-dnsmasq.service already exists #9

Description

@vladyslavabohdanova

After updating aos-unit to a newer version, the service fails on its first startup attempt because the transient systemd unit aos-unit-dnsmasq.service from the previous run was not fully torn down before the new version tries to create it.

The service recovers automatically on the second attempt (after the systemd restart delay), so it is not a blocking issue — but it introduces an unnecessary ~10 second delay and a logged failure on every update/restart cycle.

Steps to Reproduce

  1. Have aos-unit 1.1.1~jammy running with an existing aos-unit-dnsmasq.service transient unit active
  2. Update aos-unit to a newer version 1.1.2~jammy (service is stopped and restarted as part of the update)
  3. Observe the first startup attempt fails

Expected Behavior

The startup script should detect and stop any existing aos-unit-dnsmasq.service transient unit before attempting to create a new one, ensuring a clean first-attempt startup after an update.

Actual Behavior

The startup script attempts to create aos-unit-dnsmasq.service while a stale unit from the previous session still exists, causing an immediate failure:

aos-unit:startup: Starting dnsmasq as transient unit: aos-unit-dnsmasq.service
Failed to start transient service unit: Unit aos-unit-dnsmasq.service already exists.
aos-unit:startup: Startup failed (exit 1). Rolling back...
aos-unit:startup: Rollback complete.
systemd[1]: aos-unit.service: Control process exited, code=exited, status=1/FAILURE
systemd[1]: Failed to start AosEdge Unit VM Manager.

Systemd then schedules a restart, and the second attempt succeeds normally.

Logs

Full log snippet (first failed attempt + successful retry)
Mar 05 09:38:49 systemd[1]: Stopping AosEdge Unit VM Manager...
Mar 05 09:38:49 aos-unit[7514]: aos-unit:network-helper: Removing NAT rules
Mar 05 09:38:49 aos-unit[7522]: aos-unit:cleanup: nft table inet aos_unit removed
Mar 05 09:38:49 aos-unit[7522]: aos-unit:cleanup: Removing bridge: aosbrec28bf
Mar 05 09:38:49 aos-unit[7522]: aos-unit:cleanup: Cleanup complete
Mar 05 09:38:49 systemd[1]: Stopped AosEdge Unit VM Manager.
Mar 05 09:38:49 systemd[1]: Starting AosEdge Unit VM Manager...
Mar 05 09:38:49 aos-unit[7537]: aos-unit:startup: Creating bridge: aosbrec28bf (10.0.0.1)
Mar 05 09:38:49 aos-unit[7537]: aos-unit:startup: Starting dnsmasq as transient unit: aos-unit-dnsmasq.service
Mar 05 09:38:49 aos-unit[7575]: Failed to start transient service unit: Unit aos-unit-dnsmasq.service already exists.
Mar 05 09:38:49 aos-unit[7537]: aos-unit:startup: Startup failed (exit 1). Rolling back...
Mar 05 09:38:49 systemd[1]: aos-unit.service: Failed with result 'exit-code'.
Mar 05 09:38:49 systemd[1]: Failed to start AosEdge Unit VM Manager.
Mar 05 09:38:59 systemd[1]: aos-unit.service: Scheduled restart job, restart counter is at 1.
Mar 05 09:38:59 systemd[1]: Starting AosEdge Unit VM Manager...
Mar 05 09:38:59 aos-unit[7687]: aos-unit:startup: dnsmasq started (systemd unit aos-unit-dnsmasq.service)
Mar 05 09:38:59 aos-unit[7687]: aos-unit:startup: Startup complete
Mar 05 09:39:00 systemd[1]: Started AosEdge Unit VM Manager.

Environment

  • Host: AWS EC2
  • Host architecture: x86_64
  • Triggered by: Service update (version upgrade)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions