Skip to content

[vme] Update vme list table format #8873

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

Merged
merged 2 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion src/vme/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ Release History

1.0.0b2
++++++
* Add new 'az vme list' command to list all version managed extensions.
* Add new 'az vme list' command to list all version managed extensions.

1.0.0b3
++++++
* Update 'az vme list --output table' to show correct versions.
* Wait for the bundle feature flag to fully propagate after enabling it.
2 changes: 1 addition & 1 deletion src/vme/azext_vme/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __get_table_row(result):
return OrderedDict([
('name', result['name']),
('extensionType', result.get('properties', {}).get('extensionType', '')),
('version', result.get('properties', {}).get('version', '')),
('version', result.get('properties', {}).get('currentVersion', '')),
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

To maintain compatibility with resources that use the old version property, consider falling back to it: e.g., get('currentVersion', result.get('version', '')).

Suggested change
('version', result.get('properties', {}).get('currentVersion', '')),
('version', result.get('properties', {}).get('currentVersion', result.get('version', ''))),

Copilot uses AI. Check for mistakes.

('provisioningState', result.get('properties', {}).get('provisioningState', '')),
('isSystemExtension', result.get('properties', {}).get('isSystemExtension', '')),
('lastModifiedAt', result.get('systemData', {}).get('lastModifiedAt', '')),
Expand Down
14 changes: 8 additions & 6 deletions src/vme/azext_vme/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from knack.log import get_logger
import time
from azure.cli.core.commands.client_factory import get_subscription_id
from datetime import datetime
from ._client_factory import cf_deployments, cf_resources
from azure.core.exceptions import ResourceNotFoundError

Expand All @@ -35,7 +34,8 @@ def install_vme(

utils.check_and_add_cli_extension("connectedk8s")
utils.check_and_add_cli_extension("k8s-extension")
utils.check_and_enable_bundle_feature_flag(cluster, resource_group_name, cluster_name, kube_config, kube_context)
utils.check_and_enable_bundle_feature_flag(
cmd, subscription_id, cluster, resource_group_name, cluster_name, kube_config, kube_context)

# Install the bundle extensions one by one
for extension_type in include_extension_types:
Expand Down Expand Up @@ -73,7 +73,8 @@ def install_vme(
print(f"Installed extension {extension_type} successfully.")
print(result)

print("All extensions installed successfully.")
if len(include_extension_types) > 1:
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider extracting the conditional summary logic into a helper function to eliminate duplicated code between install and uninstall flows.

Copilot uses AI. Check for mistakes.

print("All extensions installed successfully.")


def uninstall_vme(
Expand Down Expand Up @@ -111,7 +112,8 @@ def uninstall_vme(
"--yes"]
utils.call_subprocess_raise_output(command)
print(f"Uninstalled extension {extension_type} successfully.")
print("All extensions uninstalled successfully.")
if len(include_extension_types) > 1:
print("All extensions uninstalled successfully.")


def upgrade_vme(
Expand All @@ -136,7 +138,7 @@ def upgrade_vme(

utils.check_and_add_cli_extension("connectedk8s")
utils.check_and_enable_bundle_feature_flag(
cluster, resource_group_name, cluster_name, kube_config, kube_context)
cmd, subscription_id, cluster, resource_group_name, cluster_name, kube_config, kube_context)
deployment_name = (consts.ARC_UPDATE_PREFIX + cluster_name).lower()
print(f"Checking arm template deployment '{deployment_name}' for '{cluster_resource_id}' "
f"which has agent version '{agent_version}'")
Expand All @@ -149,7 +151,7 @@ def upgrade_vme(
deployment = None
while time.time() - start_time < wait_timeout:
# Get current timestamp
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
timestamp = utils.get_utctimestring()
try:
deployment = client.get(resource_group_name, deployment_name)
if (not deployment or not deployment.tags):
Expand Down
23 changes: 21 additions & 2 deletions src/vme/azext_vme/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from knack.log import get_logger
from azext_vme import consts
import threading
from ._client_factory import cf_deployments

logger = get_logger(__name__)

Expand Down Expand Up @@ -136,7 +137,7 @@ def check_and_add_cli_extension(cli_extension_name):


def check_and_enable_bundle_feature_flag(
cluster, resource_group_name, cluster_name, kube_config=None, kube_context=None):
cmd, subscription_id, cluster, resource_group_name, cluster_name, kube_config=None, kube_context=None):
"""Enable the bundle feature flag for the given cluster if it's not already enabled."""

auto_upgrade = extract_auto_upgrade_value(cluster)
Expand All @@ -163,7 +164,21 @@ def check_and_enable_bundle_feature_flag(
call_subprocess_raise_output(command)

# Wait for the feature flag to be enabled on the dp side.
time.sleep(30)
wait_timeout = 300
start_time = time.time()
deployment_name = (consts.ARC_UPDATE_PREFIX + cluster_name).lower()
client = cf_deployments(cmd.cli_ctx, subscription_id)
deployment = None
while time.time() - start_time < wait_timeout:
try:
deployment = client.get(resource_group_name, deployment_name)
break
except ResourceNotFoundError:
print(f"[{get_utctimestring()}] Waiting for the bundle feature flag to propagate...")
time.sleep(5)

if (not deployment):
raise CLIError("The bundle feature flag failed to propagate within the timeout period.")
print("Enabled the bundle feature flag successfully.")


Expand Down Expand Up @@ -201,3 +216,7 @@ def handle_failure(resources, deployment, timestamp):
)

raise CLIError(f"[{timestamp}] {consts.UPGRADE_FAILED_MSG + deployment.properties.error.message}")


def get_utctimestring() -> str:
return time.strftime("%Y-%m-%dT%H-%M-%SZ", time.gmtime())
2 changes: 1 addition & 1 deletion src/vme/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from setuptools import setup, find_packages

# HISTORY.rst entry.
VERSION = '1.0.0b2'
VERSION = '1.0.0b3'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down
Loading