Skip to content

Commit

Permalink
[k8s-extension] Update extension CLI to v1.4.0 (#5895)
Browse files Browse the repository at this point in the history
  • Loading branch information
bavneetsingh16 authored Feb 20, 2023
1 parent 72b9b32 commit 872f3dd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/k8s-extension/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

1.4.0
++++++++++++++++++
* microsoft.dapr: Update version comparison logic to use semver based comparison
* microsoft.azuremonitor.containers: Make ContainerInsights DataCollectionRuleName consistent with portal and other onboarding clients

1.3.9
++++++++++++++++++
* Deprecating --config-settings alias for --configuration-settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,9 @@ def _ensure_container_insights_dcr_for_monitoring(cmd, subscription_id, cluster_
except HttpResponseError as ex:
raise ex

dataCollectionRuleName = f"MSCI-{cluster_name}-{cluster_region}"
dataCollectionRuleName = f"MSCI-{workspace_region}-{cluster_name}"
# Max length of the DCR name is 64 chars
dataCollectionRuleName = dataCollectionRuleName[0:64]
dcr_resource_id = f"/subscriptions/{subscription_id}/resourceGroups/{cluster_resource_group_name}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"

# first get the association between region display names and region IDs (because for some reason
Expand Down
14 changes: 13 additions & 1 deletion src/k8s-extension/azext_k8s_extension/partner_extensions/Dapr.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from copy import deepcopy
from knack.log import get_logger
from knack.prompting import prompt, prompt_y_n
from packaging import version as packaging_version

from ..vendored_sdks.models import Extension, PatchExtension, Scope, ScopeCluster
from .DefaultExtension import DefaultExtension
Expand Down Expand Up @@ -173,7 +174,7 @@ def Update(self, cmd, resource_group_name: str, cluster_name: str, auto_upgrade_
logger.debug("Auto-upgrade is disabled and version is pinned to %s. Setting '%s' to false.",
version, self.APPLY_CRDS_HOOK_ENABLED_KEY)
configuration_settings[self.APPLY_CRDS_HOOK_ENABLED_KEY] = 'false'
elif original_version and version and version < original_version:
elif original_version and version and Dapr._is_downgrade(version, original_version):
logger.debug("Downgrade detected from %s to %s. Setting %s to false.",
original_version, version, self.APPLY_CRDS_HOOK_ENABLED_KEY)
configuration_settings[self.APPLY_CRDS_HOOK_ENABLED_KEY] = 'false'
Expand All @@ -196,3 +197,14 @@ def Update(self, cmd, resource_group_name: str, cluster_name: str, auto_upgrade_
version=version,
configuration_settings=configuration_settings,
configuration_protected_settings=configuration_protected_settings)

@staticmethod
def _is_downgrade(v1: str, v2: str) -> bool:
"""
Returns True if version v1 is less than version v2.
"""
try:
return packaging_version.Version(v1) < packaging_version.Version(v2)
except packaging_version.InvalidVersion:
logger.debug("Warning: Unable to compare versions %s and %s.", v1, v2)
return True # This will cause the apply-CRDs hook to be disabled, which is safe.
2 changes: 1 addition & 1 deletion src/k8s-extension/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# TODO: Add any additional SDK dependencies here
DEPENDENCIES = []

VERSION = "1.3.9"
VERSION = "1.4.0"

with open("README.rst", "r", encoding="utf-8") as f:
README = f.read()
Expand Down

0 comments on commit 872f3dd

Please sign in to comment.