Skip to content
Open
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
10 changes: 9 additions & 1 deletion src/aks-agent/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
+++++++

1.0.0b18
++++++++
* Bump aks-agent to v0.3.0
* chore: use aks mcp streamable-http mode
* Remove runbook toolset until it's stablized
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

Typo in changelog entry: "stablized" should be "stabilized".

Suggested change
* Remove runbook toolset until it's stablized
* Remove runbook toolset until it's stabilized

Copilot uses AI. Check for mistakes.
* Several CEV fixes
* Upgrade helm chart automatically during `az aks agent` when there's an update in helm chart

1.0.0b17
++++++++
* Fix: remove the prompt to user about managed identity client id during `az aks agent-init``
* Fix: remove the prompt to user about managed identity client id during `az aks agent-init`

1.0.0b16
++++++++
Expand Down
51 changes: 45 additions & 6 deletions src/aks-agent/azext_aks_agent/agent/k8s/aks_agent_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __init__(self, resource_group_name: str, cluster_name: str,
self.subscription_id: str = subscription_id

self.chart_repo = "oci://mcr.microsoft.com/aks/aks-agent-chart/aks-agent"
self.chart_version = "0.2.0"
self.chart_version = "0.3.0"

# credentials for aks-mcp
# Default empty customized cluster role name means using default cluster role
Expand Down Expand Up @@ -584,10 +584,14 @@ def get_agent_status(self) -> Dict: # pylint: disable=too-many-locals
if list_success:
try:
releases = json.loads(list_output)
release_exists = any(
release.get("name") == self.helm_release_name
for release in releases
)
for release in releases:
if release.get("name") == self.helm_release_name:
release_exists = True
# Extract chart version from chart field (e.g., "aks-agent-0.2.0")
chart_field = release.get("chart", "")
if "-" in chart_field:
status["chart_version"] = chart_field.rsplit("-", 1)[-1]
break
except json.JSONDecodeError:
logger.warning("Failed to parse helm list output")

Expand Down Expand Up @@ -764,6 +768,41 @@ def uninstall_agent(self, delete_secret: bool = True) -> bool:
return True
raise AzCLIError(f"Failed to uninstall AKS agent: {output}")

def check_upgrade_needed(self) -> Tuple[bool, Optional[str], Optional[str]]:
"""
Check if the deployed helm chart version differs from the expected version.

Returns:
Tuple[bool, Optional[str], Optional[str]]:
- needs_upgrade: True if upgrade is needed, False otherwise
- deployed_version: The currently deployed version (or None if unknown)
- expected_version: The expected version to upgrade to (or None if no upgrade needed)
"""
agent_status = self.get_agent_status()
helm_status = agent_status.get("helm_status", "not_found")

if helm_status not in ["deployed", "superseded"]:
logger.debug("Agent not deployed or in unexpected state: %s", helm_status)
return False, None, None

deployed_version = agent_status.get("chart_version")
expected_version = self.chart_version

if not deployed_version:
logger.warning("Could not determine deployed chart version")
return False, None, None

if deployed_version == expected_version:
logger.debug("Chart version is up to date: %s", deployed_version)
return False, deployed_version, None

logger.info(
"Chart version mismatch detected. Deployed: %s, Expected: %s",
deployed_version, expected_version
)

return True, deployed_version, expected_version
Comment on lines +771 to +804
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

New check_upgrade_needed() behavior is untested. There are existing unit tests for AKSAgentManager (e.g., test_get_agent_status) but nothing covering version extraction / mismatch detection. Add tests to validate: (1) matching version returns (False, deployed_version, None), (2) mismatch returns (True, deployed_version, expected_version), and (3) missing/unknown deployed version returns (False, None, None).

Copilot uses AI. Check for mistakes.

def exec_aks_agent(self, command_flags: str = "") -> bool:
"""
Execute commands on the AKS agent pod using PodExecManager.
Expand Down Expand Up @@ -973,7 +1012,7 @@ def __init__(self, resource_group_name: str, cluster_name: str,
self.config_dir = self.base_config_dir / subscription_id / resource_group_name / cluster_name

# Docker image for client mode execution
self.docker_image = "mcr.microsoft.com/aks/aks-agent:v0.2.0-client"
self.docker_image = "mcr.microsoft.com/aks/aks-agent:v0.3.0-client"

self.llm_config_manager = LLMConfigManagerLocal(
subscription_id=subscription_id,
Expand Down
33 changes: 33 additions & 0 deletions src/aks-agent/azext_aks_agent/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,39 @@ def aks_agent(
error_msg += f"The AKS agent may not be deployed. Run 'az aks agent-init {cmd_flags}' to initialize the deployment."
raise CLIError(error_msg)

# Check if helm chart version needs upgrade and upgrade automatically if needed
console = get_console()
needs_upgrade, deployed_version, expected_version = agent_manager.check_upgrade_needed()
if needs_upgrade:
console.print(
f"\n📦 Upgrading AKS agent from version {deployed_version} to {expected_version}...",
style="bold cyan"
)
console.print(
"This may take a minute or two. Please wait...",
style="cyan"
)
try:
success, error_msg = agent_manager.deploy_agent()
if success:
console.print(
"✅ AKS agent has been automatically upgraded to the latest version.",
style=SUCCESS_COLOR)
else:
console.print(
f"⚠️ Warning: Failed to auto-upgrade agent: {error_msg}",
style=WARNING_COLOR)
console.print(
"Continuing with the current version. Run 'az aks agent-upgrade' to manually upgrade.",
style=INFO_COLOR)
except AzCLIError as e:
console.print(
f"⚠️ Warning: Failed to auto-upgrade agent: {e}",
style=WARNING_COLOR)
console.print(
"Continuing with the current version. Run 'az aks agent-upgrade' to manually upgrade.",
Comment on lines +592 to +599
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The warning suggests running az aks agent-upgrade, but this extension’s command table only defines az aks agent, az aks agent-init, and az aks agent-cleanup (no agent-upgrade). This will mislead users if auto-upgrade fails. Update the message to reference an existing command (or add the missing command if intended).

Suggested change
"Continuing with the current version. Run 'az aks agent-upgrade' to manually upgrade.",
style=INFO_COLOR)
except AzCLIError as e:
console.print(
f"⚠️ Warning: Failed to auto-upgrade agent: {e}",
style=WARNING_COLOR)
console.print(
"Continuing with the current version. Run 'az aks agent-upgrade' to manually upgrade.",
"Continuing with the current version. Run 'az aks agent-init' to manually upgrade.",
style=INFO_COLOR)
except AzCLIError as e:
console.print(
f"⚠️ Warning: Failed to auto-upgrade agent: {e}",
style=WARNING_COLOR)
console.print(
"Continuing with the current version. Run 'az aks agent-init' to manually upgrade.",

Copilot uses AI. Check for mistakes.
style=INFO_COLOR)

# prepare CLI flags

# user quoted prompt to not break the command line parsing
Expand Down
2 changes: 1 addition & 1 deletion src/aks-agent/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from setuptools import find_packages, setup

VERSION = "1.0.0b17"
VERSION = "1.0.0b18"

CLASSIFIERS = [
"Development Status :: 4 - Beta",
Expand Down
Loading