Skip to content

Commit

Permalink
Check and uninstall extensions before installing it
Browse files Browse the repository at this point in the history
  • Loading branch information
LiliDeng committed Nov 20, 2024
1 parent ceac54d commit baf13fb
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand Down

0 comments on commit baf13fb

Please sign in to comment.