fix(linux-scripts): fix linux scripts when systemd is degraded + imp… (#5871)#200
Conversation
|
Thank you for your contribution. This PR is but one step away from being ready for merging: all commits must be PGP-signed. To get started, please see https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits |
|
🤖 [AI-generated] Hey @MarineLeM! 👋 Thanks a lot for opening PR #200 — really appreciate the fix for the degraded-systemd installation path! 🙏 I just had a quick look and I think the description could be enhanced a little to help reviewers get through it faster. I haven't changed anything in your description — just a gentle suggestion:
Nice touch already having concrete Testing Instructions and the linked issue (#5871) — that really helps! 🙌
No rush at all — thanks again for contributing to OpenAEV! 🚀 |
…rove errors handling
There was a problem hiding this comment.
Pull request overview
This PR updates the Linux installer/upgrade shell scripts to tolerate systemctl is-system-running returning a non-zero exit code for acceptable states (notably degraded) and to improve failure diagnostics by introducing small log/die/run helpers.
Changes:
- Capture systemd status without tripping
set -eand treatrunning+degradedas acceptable states. - Introduce
log(),die(), andrun()helpers to standardize error handling and messages. - Improve install-time filesystem checks and replace silent exits with explicit error messages.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| installer/linux/agent-upgrade.sh | Adds log/die/run and systemd-state handling; refactors upgrade + reinstall flow. |
| installer/linux/agent-upgrade-session-user.sh | Same systemd-state handling + helper functions for session-user upgrade path. |
| installer/linux/agent-upgrade-service-user.sh | Same systemd-state handling + helper functions for service-user upgrade path. |
| installer/linux/agent-installer.sh | Same systemd-state handling + helper functions; improves install directory checks and service setup flow. |
| installer/linux/agent-installer-session-user.sh | Same systemd-state handling + helper functions for session-user installer path. |
| installer/linux/agent-installer-service-user.sh | Same systemd-state handling + helper functions for service-user installer path and argument validation errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| rm -f ${uninstall_dir}/openbas-agent | ||
| systemctl disable ${uninstall_service} --now | ||
| ) || (echo "Error while uninstalling OpenBAS Agent" >&2 && exit 1) | ||
| run curl -sSfLG ${base_url}/api/tenants/${tenant_id}/agent/installer/openaev/${os}/service/${OPENAEV_TOKEN} --data-urlencode "installationDir=${openaev_dir}" --data-urlencode "serviceName=${openaev_service}" | sh |
| log "01. Installing OpenAEV Agent..." | ||
| openaev_session=$(printf %s "${session_name}" | sed 's/openbas/openaev/g') | ||
| curl -sSfLG ${base_url}/api/tenants/${tenant_id}/agent/installer/openaev/${os}/session-user/${OPENAEV_TOKEN} --data-urlencode "installationDir=${openaev_dir}" --data-urlencode "serviceName=${openaev_session}" | sh | ||
| run curl -sSfLG ${base_url}/api/tenants/${tenant_id}/agent/installer/openaev/${os}/session-user/${OPENAEV_TOKEN} --data-urlencode "installationDir=${openaev_dir}" --data-urlencode "serviceName=${openaev_session}" | sh |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
🧪 Test Matrix — Agent Install / Update / Execution (In Progress)Legend
🏗️ ARM64 (aarch64)Install
Update
Execution
🏗️ x86_64 (amd64) FAILED❌Install
Update
Execution
✅ Acceptance Criteria
📋 Environment Details
🔧 How to simulate degraded mode# Force systemd into "degraded" state
sudo bash -c 'cat > /etc/systemd/system/fake-degraded.service <<EOF
[Unit]
Description=Fake service to simulate degraded state
[Service]
Type=oneshot
ExecStart=/bin/false
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF'
sudo systemctl daemon-reload
sudo systemctl start fake-degraded.service
systemctl is-system-running # → degraded |
PR Test Results — Linux Agent Install FixEnvironment: Tested on both x86 and arm64 Linux VMs. Observations
ConclusionThe PR successfully fixes the original install script issue on both architectures. However, a separate, pre-existing bug in the x86 agent binary prevents the service from running on x86 — this should be tracked in a dedicated issue. |
Problem Information :
systemctl is-system-running returns a non-zero exit code for any state other than running (e.g. degraded → exit code 1). Combined with set -e, this causes the script to exit immediately, even though degraded is an acceptable state.
Moreover, the script exits silently without any details about what failed
Proposed changes
systemd_status=$(systemctl is-system-running 2>/dev/null || true)Then explicitly handle each state — accepting running and degraded, otherwise stopping the script with a clear error message.
- run() — wraps any command and calls die on failure
- die() — logs the exact command that failed and exits
Testing Instructions
systemctl is-system-runningRelated issues