Skip to content

Fix: prevent needrestart prompt from hanging CVM attestation tool ins…#4607

Open
SRIKKANTH wants to merge 1 commit into
mainfrom
smyakam/cvm_attestation/2026_07_14
Open

Fix: prevent needrestart prompt from hanging CVM attestation tool ins…#4607
SRIKKANTH wants to merge 1 commit into
mainfrom
smyakam/cvm_attestation/2026_07_14

Conversation

@SRIKKANTH

Copy link
Copy Markdown
Collaborator

…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

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Documentation update

Checklist

  • Description is filled in above
  • No credentials, secrets, or internal details are included
  • Peer review requested (if not, add required peer reviewers after raising PR)
  • Tests executed and results posted below

Test Validation

Key Test Cases:

  • verify_azure_cvm_attestation_report

Impacted LISA Features:

Tested Azure Marketplace Images:

  • Canonical 0001-com-ubuntu-confidential-vm-focal 20_04-lts-cvm latest

Test Results

Image VM Size Result
Canonical 0001-com-ubuntu-confidential-vm-focal 20_04-lts-cvm latest Standard_DC2as_v6 PASSED / FAILED / SKIPPED

…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.
Copilot AI review requested due to automatic review settings July 17, 2026 21:06
@SRIKKANTH
SRIKKANTH requested a review from yangjie-msft July 17, 2026 21:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 needrestart restart-mode override to /etc/needrestart/needrestart.conf to prevent interactive prompts.
  • Switch from inline sudo ./install.sh to using node.execute(..., sudo=True) for consistency with LISA command execution conventions.

Comment on lines +112 to 116
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,
@LiliDeng

Copy link
Copy Markdown
Collaborator

AI Test Case Selection

Selected 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: debian debian-12 12 latest

Result: Succeeded

View full logs in Azure DevOps

@SRIKKANTH
SRIKKANTH requested review from kamalca and removed request for yangjie-msft July 17, 2026 21:30
@LiliDeng

Copy link
Copy Markdown
Collaborator

@SRIKKANTH
Canonical 0001-com-ubuntu-confidential-vm-focal 20_04-lts-cvm latest - I encountered provision issue.
canonical 0001-com-ubuntu-confidential-vm-jammy 22_04-lts-cvm latest - pass with / without your changes.
canonical ubuntu-26_04-lts server-cvm latest - fail with / without your changes.

I am not sure which issue you are trying to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants