Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check and uninstall extensions before installing it #3520

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
from lisa.sut_orchestrator import AZURE
from lisa.sut_orchestrator.azure.features import AzureExtension
from lisa.sut_orchestrator.azure.tools import Waagent
from lisa.util import LisaException
from microsoft.testsuites.vm_extensions.runtime_extensions.common import (
check_waagent_version_supported,
execute_command,
@@ -38,10 +39,22 @@ def _create_and_verify_extension_run(
assert_exception: Any = None,
) -> None:
extension = node.features[AzureExtension]
extension_name = "CustomScript"
try:
# Delete VM Extension if already present
extension.delete(extension_name)
except HttpResponseError as identifier:
if any(s in str(identifier) for s in ["was not found"]):
node.log.info(f"{extension_name} is not installed")
else:
raise LisaException(
f"unexpected exception happened {identifier} during delete"
f" extension {extension_name}"
) from identifier

def enable_extension() -> Any:
result = extension.create_or_update(
name="CustomScript",
name=extension_name,
publisher="Microsoft.Azure.Extensions",
type_="CustomScript",
type_handler_version="2.1",