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>
This commit is contained in:
Salman Rana 2024-10-25 10:42:21 -04:00
parent e633510269
commit e8728e3074
8 changed files with 9 additions and 5 deletions

View File

@ -30,6 +30,7 @@ while true; do
if [ "$SYSTEM_RECONCILED" = true ] && [ "$HOST_RECONCILED" = true ]; then
break
fi
echo "Not ready - rechecking in 10s..."
sleep 10
done
echo "Ready - system deployment reconciled"

View File

@ -4,7 +4,7 @@ ConditionPathExists=/var/lib/factory-install/enabled
ConditionPathExists=!/var/lib/factory-install/state/bootstrap
[Path]
PathExists=/var/lib/factory-install/stage/bootstrap
PathModified=/var/lib/factory-install/stage/bootstrap
[Install]
WantedBy=factory-install.target

View File

@ -4,7 +4,7 @@ ConditionPathExists=/var/lib/factory-install/enabled
ConditionPathExists=!/var/lib/factory-install/state/config
[Path]
PathExists=/var/lib/factory-install/stage/config
PathModified=/var/lib/factory-install/stage/config
[Install]
WantedBy=factory-install.target

View File

@ -4,7 +4,7 @@ ConditionPathExists=/var/lib/factory-install/enabled
ConditionPathExists=!/var/lib/factory-install/state/setup
[Path]
PathExists=/var/lib/factory-install/stage/setup
PathModified=/var/lib/factory-install/stage/setup
[Install]
WantedBy=factory-install.target

View File

@ -4,7 +4,7 @@ ConditionPathExists=/var/lib/factory-install/enabled
ConditionPathExists=!/var/lib/factory-install/state/tests
[Path]
PathExists=/var/lib/factory-install/stage/tests
PathModified=/var/lib/factory-install/stage/tests
[Install]
WantedBy=factory-install.target

View File

@ -11,6 +11,7 @@ User=sysadmin
ExecStart=/usr/bin/run-parts --verbose --exit-on-error /var/lib/factory-install/tests
ExecStartPost=+/usr/bin/touch /var/lib/factory-install/state/tests
ExecStartPost=+/usr/bin/touch /var/lib/factory-install/stage/final
ExecStartPost=+/usr/bin/touch /var/lib/factory-install/complete
ExecStartPost=+/var/lib/factory-install/utils/disable-factory-install
StandardOutput=append:/var/log/factory-install.log

View File

@ -7,6 +7,8 @@
# script to disable the factory install services after the installation is complete
#
echo "Disabling factory install services"
rm -f /var/lib/factory-install/enabled
rm -f /etc/systemd/system-preset/20-factory-install.preset

View File

@ -22,7 +22,7 @@ source /etc/platform/openrc
fm --timeout 10 alarm-list --nowrap|grep -e "major\|minor\|warning\|critical"
if [ $? == 0 ]; then
# Log the health check failure and exit 0 to allow factory-install to finish up.
# Modify to exit 1 if factory-install should retry check until success.
# Modify to exit 1 if factory-install should fail the test stage and halt.
log_failure "service impacting alarms present" 0
fi