utilities/tools/nocloud-factory-install
Salman Rana e8728e3074 Factory-install: Update stage service activation
Update unit configs for factory-install to use PathModified
instead of PathExists to monitor the flag path for stage-service
activations. This change ensures that when a stage fails,
factory-install halts rather than re-triggering
(indefinitely for unresolved failures). It allows users to view
the failure, take corrective action, and manually restart the
automation process with systemctl restart.

These changes also add minor usability improvements:
- Enhanced logging messages
- 'complete' flag to easily identify successful completion of
  factory install (equivalent to the existing
  /var/lib/factory-install/stage/final flag). This flag has no
  functional purpose except to help users easily recognize
  completion.

Test Plan:
1. PASS: Verify successful end-to-end factory installation.
         Ensure the System in the unlocked-enabled-available state.
         Furthermore, ensure:
          1) Factory install services disabled
          1) No alarms raised
          2) System/host reconciled
          3) No fatal errors reported in /var/log/factory-install

2. PASS: Verify factory install services execution, ensure:
         1) Streamlined staged execution. At most 1
            factory install service unit must be active at a time,
            strictly in the following order:
            bootstrap, config, setup and test
         2) All 4 path units must be active at start, with each
            stage transition, the previous path+service units
            must exit
         3) Suceesfuly exited services should be permanently disabled
         4) Validate /var/lib/factory-install/{stage,state}/
            flags with service statues

3. PASS: Verify service/stage failure and recovery behavior:
         Induce failure in different stages
         (e.g., add Ansible failure task and exit 1 in test stage).
         ensure:
         1) Factory install halts and reports failure in
            systemctl status.

         Fix failure  and ensure:
         2) Factory install starts failed stage using
            'systemctl restart factory-install-<stage>.service
             --no-block'.
         3) Automation (transation to other stages) continues after
            failure recovery restart.

4. PASS: Validate factory install services after manual reboot
         with/without failed stage. Ensure factory-install services
         are started.

Closes-Bug: 2085572

Change-Id: Ic44e37594b82f6f9b6a34306ccd12774952653bc
Signed-off-by: Salman Rana <salman.rana@windriver.com>
2024-10-25 20:09:54 +00:00
..