Fix: prevent needrestart prompt from hanging CVM attestation tool ins…#4607
Fix: prevent needrestart prompt from hanging CVM attestation tool ins…#4607SRIKKANTH wants to merge 1 commit into
Conversation
…tall on Ubuntu 22.04+
Problem
AzureCVMAttestationTestSuite.verify_azure_cvm_attestation_report fails during tool setup with:
On Ubuntu 22.04+, the tool's install.sh runs apt-get install, which triggers needrestart in interactive mode. It renders a whiptail dialog — "Daemons using outdated libraries — Which services should be restarted?" — that blocks on stdin. Because LISA runs non-interactively (no TTY), the dialog never gets input and the command runs until the 600s timeout, failing the test before any attestation logic executes.
Root cause
The hang is inside AzureCVMAttestationTests._install(), not in the attestation logic. install.sh invokes apt through its own inner sudo, which resets the environment (env_reset in sudoers). This strips process-level mitigations like NEEDRESTART_MODE=a / DEBIAN_FRONTEND=noninteractive, so they don't reach the apt call that spawns needrestart.
Fix
Before running install.sh, force needrestart into automatic mode by appending $nrconf{restart} = "a"; to the end of /etc/needrestart/needrestart.conf. This is read from disk on every needrestart invocation (immune to the inner-sudo env reset), and as a perl config the last assignment wins — guaranteeing the override regardless of the packaged default. Also moved sudo from the inline command string to the sudo=True parameter for consistency with LISA conventions.
There was a problem hiding this comment.
Pull request overview
This PR addresses a hang during Azure CVM attestation tool installation on Ubuntu 22.04+ by forcing needrestart into a non-interactive mode via an on-disk config override that survives sudo environment resets inside install.sh.
Changes:
- Add a pre-install step that appends a
needrestartrestart-mode override to/etc/needrestart/needrestart.confto prevent interactive prompts. - Switch from inline
sudo ./install.shto usingnode.execute(..., sudo=True)for consistency with LISA command execution conventions.
| needrestart_conf = "/etc/needrestart/needrestart.conf" | ||
| self.node.execute( | ||
| "sudo ./install.sh", | ||
| f"test -f {needrestart_conf} && " | ||
| f"echo '$nrconf{{restart}} = \"a\";' >> {needrestart_conf} || true", | ||
| shell=True, |
AI Test Case SelectionSelected 5 test case(s): verify_azure_cvm_attestation_report,verify_nested_cvm_attestation_report,verify_azure_vm_snp_enablement,verify_encrypted_root_partition,verify_boot_success_after_component_upgrade Marketplace image: Result: Succeeded |
|
@SRIKKANTH I am not sure which issue you are trying to fix. |
…tall on Ubuntu 22.04+
Problem
AzureCVMAttestationTestSuite.verify_azure_cvm_attestation_report fails during tool setup with:
On Ubuntu 22.04+, the tool's install.sh runs apt-get install, which triggers needrestart in interactive mode. It renders a whiptail dialog — "Daemons using outdated libraries — Which services should be restarted?" — that blocks on stdin. Because LISA runs non-interactively (no TTY), the dialog never gets input and the command runs until the 600s timeout, failing the test before any attestation logic executes.
Root cause
The hang is inside AzureCVMAttestationTests._install(), not in the attestation logic. install.sh invokes apt through its own inner sudo, which resets the environment (env_reset in sudoers). This strips process-level mitigations like NEEDRESTART_MODE=a / DEBIAN_FRONTEND=noninteractive, so they don't reach the apt call that spawns needrestart.
Fix
Before running install.sh, force needrestart into automatic mode by appending $nrconf{restart} = "a"; to the end of /etc/needrestart/needrestart.conf. This is read from disk on every needrestart invocation (immune to the inner-sudo env reset), and as a perl config the last assignment wins — guaranteeing the override regardless of the packaged default. Also moved sudo from the inline command string to the sudo=True parameter for consistency with LISA conventions.
Description
Related Issue
Type of Change
Checklist
Test Validation
Key Test Cases:
Impacted LISA Features:
Tested Azure Marketplace Images:
Test Results