Skip to content

Commit

Permalink
{AKS} az aks mesh get-upgrades fails with a traceback if ASM addon …
Browse files Browse the repository at this point in the history
…is disabled (#7353)
  • Loading branch information
deveshdama committed Mar 7, 2024
1 parent b57267b commit f1ea4ca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ If there is no rush to release a new version, please just add a description of t

To release a new version, please select a new version number (usually plus 1 to last patch version, X.Y.Z -> Major.Minor.Patch, more details in `\doc <https://semver.org/>`_), and then add a new section named as the new version number in this file, the content should include the new modifications and everything from the *Pending* section. Finally, update the `VERSION` variable in `setup.py` with this new version number.

Pending
2.0.0b3
+++++++
* Add parameter to set revision `--revision` for the Azure Service Mesh addon while creating AKS cluster.
* Fix for `az aks mesh get-upgrades` command panic response when ASM addon is not enabled.

2.0.0b2
+++++++
Expand Down
28 changes: 19 additions & 9 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2947,22 +2947,32 @@ def aks_mesh_get_revisions(
return None


def check_iterator(iterator):
import itertools
try:
first = next(iterator)
except StopIteration: # iterator is empty
return True, iterator
except TypeError: # iterator is not iterable, e.g. None
return True, iterator
return False, itertools.chain([first], iterator)


def aks_mesh_get_upgrades(
cmd,
client,
resource_group_name,
name
):
upgradeProfiles = client.list_mesh_upgrade_profiles(resource_group_name, name)
# 'upgradeProfiles' is an ItemPaged object
upgrades = []
# Iterate over items within pages
for page in upgradeProfiles.by_page():
for item in page:
upgrades.append(item)

if upgrades:
return upgrades[0].properties
is_empty, upgradeProfiles = check_iterator(upgradeProfiles)
if is_empty:
logger.warning("No mesh upgrade profiles found for the cluster '%s' " +
"in the resource group '%s'.", name, resource_group_name)
return None
upgrade = next(upgradeProfiles, None)
if upgrade:
return upgrade.properties
return None


Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from setuptools import setup, find_packages

VERSION = "2.0.0b2"
VERSION = "2.0.0b3"

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

0 comments on commit f1ea4ca

Please sign in to comment.