From 4bf901782ef3d1606545f691c76befdfa9b693b9 Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Tue, 6 Jul 2021 20:39:05 -0700 Subject: [PATCH] [k8s-extension] Release v0.5.0 of extension customizations (#3545) * Create pull.yml * Update pull.yml * Update azure-pipelines.yml * Initial commit of k8s-extension * Update pipelines file * Update CODEOWNERS * Update private preview pipelines * Remove open service mesh from public release * Update pipeline files * Update public extension pipeline * Change condition variable * Add version to public preview/private preview * Update pipelines * Add different testing based on private branch * Add annotations to extension model * Update k8s-custom-pipelines.yml * Update SDKs with Updated Swagger Spec for 2020-07-01-preview (#13) * Update sdks with updated swagger spec * Update version and history rst * Reorder release history timeline * Fix ExtensionInstanceForCreate for import * remove py2 bdist support * Add custom table formatting * Remove unnecessary files * Fix style issues * Fix branch based on comments * Update identity piece manually * Don't handle defaults at the CLI level * Remove defaults from CLI client * Check null target namespace with namespace scope * Update style * Add cassandra operator and location to model * Stage Public Version of k8s-extension 0.2.0 for official release (#15) * Create pull.yml * Update pull.yml * Update azure-pipelines.yml * Initial commit of k8s-extension * Update pipelines file * Update CODEOWNERS * Update private preview pipelines * Remove open service mesh from public release * Update pipeline files * Update public extension pipeline * Change condition variable * Add version to public preview/private preview * Update pipelines * Add different testing based on private branch * Add annotations to extension model * Update k8s-custom-pipelines.yml * Update SDKs with Updated Swagger Spec for 2020-07-01-preview (#13) * Update sdks with updated swagger spec * Update version and history rst * Reorder release history timeline * Fix ExtensionInstanceForCreate for import * remove py2 bdist support * Add custom table formatting * Remove unnecessary files * Fix style issues * Fix branch based on comments * Update identity piece manually * Don't handle defaults at the CLI level * Remove defaults from CLI client * Check null target namespace with namespace scope * Update style * Add cassandra operator and location to model Co-authored-by: action@github.com * Remove custom pipelines file * Update extension description, remove private const * Update pipeline file * Disable refs docs * Update to include better create warning logs and remove update context (#20) * Update to include better create warning logs and remove update context * Remove help text for update * Fix spelling error * Update message * Fix k8s-extension conflict with private version * Fix style errors * Fix filename * add customization for microsoft.azureml.kubernetes (#23) * add customization for microsoft.azureml.kubernetes * Update release history Co-authored-by: Yue Yu Co-authored-by: jonathan-innis * Add E2E Testing from Separate branch into internal code (#26) * Add internal e2e testing * Change to testing folder * Inference CLI validation for Scoring FE (#24) * cli validation starter * added the call to the fe validation function * nodeport validation not required * test fix Co-authored-by: Jonathan Innis * legal warning added (#27) * Remove deprecated method logger.warn * Update k8s-custom-pipelines.yml for Azure Pipelines * Update k8s-custom-pipelines.yml for Azure Pipelines * Add Azure Defender to E2E testing (#28) * Add azure defender testing to e2e * Remove the debug flag * Add configuration testing * Fix pipeline failures * Make test script more intuitive * Remove parameter from testing * Fix wrong location for k8s config whl * Fix pip upgrade issue * Fix pip install upgrade issue * Fix pip install issue * delete resurce in testcase (#29) Co-authored-by: Yue Yu Co-authored-by: Jonathan Innis * Check Provider is Registered with Subscription Before Making Requests (#18) * Add check for KubernetesConfiguration * Disable pylint and rename * Update provider registration link * Update version * Remove extra blank line * Fix bug in import * only validate scoring fe when inference is enabled (#31) * only validate scoring fe when inference is enabled * Fix versioning Co-authored-by: Yue Yu Co-authored-by: jonathan-innis * Provider registration case insensitive * do not validate against scoring fe if inference is not enabled. (#33) * do not validate against scoring fe if inference is not enabled. * add inference enabled scenario * refine * increase sleeping time * fix Co-authored-by: Yue Yu Co-authored-by: Jonathan Innis * Add OSM as Public Preview Extension (#34) * Add OSM as public preview extension * Add osm testing * Add release train to tests * Fix failing osm test * Upgrade pip in integration testing * Remove ununsed import * Fix release train check in update * Parallelize E2E Testing (#36) * Add OSM as public preview extension * Add osm testing * Update test logic to parallelize * Fix test success checking * Parallelize extension testing * Better error checking logic * Fix azureml deletion * Fix private build (#40) * change amlk8s to amlarc (#42) Co-authored-by: Yue Yu * Servicebus client model changes (#44) * Servicebus client model changes * Fix testing script * Update history file and pipeline * Update min cli core version for track 2 updates * Read SSL cert and key from files (#38) * first sketch of the change fixes removed extra blank lines changes regarding param renaming added ssl tests added more detail to the unit test additional import moved pem files out of public folder fixed import chenged import changed import unit tests fix unit test fix fixed unit tests fixed unit test unit test fix changes int test cert and key * test protected config * fix test typo * temporary changes reverted * fixing tests * fixed file paths * removed accidentally added file * changes according to review comments * more changes according to review comments * changes according to review comments Co-authored-by: Jonathan Innis * Upgrade release version * Liakaz/inference read ssl from file (#47) * first sketch of the change fixes removed extra blank lines changes regarding param renaming added ssl tests added more detail to the unit test additional import moved pem files out of public folder fixed import chenged import changed import unit tests fix unit test fix fixed unit tests fixed unit test unit test fix changes int test cert and key * test protected config * fix test typo * temporary changes reverted * fixing tests * fixed file paths * removed accidentally added file * changes according to review comments * more changes according to review comments * changes according to review comments * fixed decode error * renamed the experimental param Co-authored-by: Jonathan Innis * Fix style issues (#51) * Fixed scoring fe related extension param names (#49) * fixed scoring fe related extension params * bug fix and style fixes * variable rename * fixed the error type * set cluster to prod by default * Add distro validation for osm-arc (#50) * Add distro validation for osm-arc * fixed indentation * Fix linting * Resolve comments * Add unit test * fix lint Co-authored-by: Jonathan Innis * Add distro validation for osm-arc (#50) * Add distro validation for osm-arc * fixed indentation * Fix linting * Resolve comments * Add unit test * fix lint Co-authored-by: Jonathan Innis * Add distro validation for osm-arc (#53) removed release-train logic * Add Custom Delete Logic for Partners (#54) * Add custom delete logic * Fix failing unit tests * Add warning message when deleting amlarc extension (#55) * add warning message * fix indentation * Update release version Co-authored-by: action@github.com Co-authored-by: yuyue9284 <15863499+yuyue9284@users.noreply.github.com> Co-authored-by: Yue Yu Co-authored-by: Lia Kazakova <58274127+liakaz@users.noreply.github.com> Co-authored-by: Niranjan Shankar Co-authored-by: jingyizhu99 <83610845+jingyizhu99@users.noreply.github.com> --- src/k8s-extension/HISTORY.rst | 6 +- .../azext_k8s_extension/custom.py | 11 ++ .../partner_extensions/AzureDefender.py | 3 + .../partner_extensions/AzureMLKubernetes.py | 8 +- .../partner_extensions/Cassandra.py | 3 + .../partner_extensions/ContainerInsights.py | 3 + .../partner_extensions/DefaultExtension.py | 3 + .../partner_extensions/OpenServiceMesh.py | 117 ++++++++++--- .../PartnerExtensionModel.py | 4 + .../latest/recordings/test_k8s_extension.yaml | 158 ++++++++++++++---- .../latest/test_k8s_extension_scenario.py | 9 +- .../tests/latest/test_open_service_mesh.py | 22 +++ src/k8s-extension/setup.py | 6 +- 13 files changed, 291 insertions(+), 62 deletions(-) create mode 100644 src/k8s-extension/azext_k8s_extension/tests/latest/test_open_service_mesh.py diff --git a/src/k8s-extension/HISTORY.rst b/src/k8s-extension/HISTORY.rst index 4a96664d562..eeed091c6cc 100644 --- a/src/k8s-extension/HISTORY.rst +++ b/src/k8s-extension/HISTORY.rst @@ -3,11 +3,15 @@ Release History =============== +0.5.0 +++++++++++++++++++ +* Add microsoft.openservicemesh customization to check distros +* Delete customization for partners + 0.4.3 ++++++++++++++++++ * Add SSL support for AzureML - 0.4.2 ++++++++++++++++++ diff --git a/src/k8s-extension/azext_k8s_extension/custom.py b/src/k8s-extension/azext_k8s_extension/custom.py index 504539179d1..8d6b82d1885 100644 --- a/src/k8s-extension/azext_k8s_extension/custom.py +++ b/src/k8s-extension/azext_k8s_extension/custom.py @@ -195,6 +195,17 @@ def delete_k8s_extension(client, resource_group_name, cluster_name, name, cluste """ # Determine ClusterRP cluster_rp = __get_cluster_rp(cluster_type) + extension = None + try: + extension = client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name) + except ErrorResponseException: + logger.warning("No extension with name '%s' found on cluster '%s', so nothing to delete", cluster_name, name) + return None + extension_class = ExtensionFactory(extension.extension_type.lower()) + + # If there is any custom delete logic, this will call the logic + extension_class.Delete(client, resource_group_name, cluster_name, name, cluster_type) + return client.delete(resource_group_name, cluster_rp, cluster_type, cluster_name, name) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py index a3e805006de..ffb6a926328 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py @@ -70,3 +70,6 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version): release_train=release_train, version=version ) + + def Delete(self, client, resource_group_name, cluster_name, name, cluster_type): + pass diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureMLKubernetes.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureMLKubernetes.py index bd49a164a3b..9f6aff45aac 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureMLKubernetes.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureMLKubernetes.py @@ -162,6 +162,12 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version): version=version ) + def Delete(self, client, resource_group_name, cluster_name, name, cluster_type): + # Give a warning message + logger.warning("If nvidia.com/gpu or fuse resource is not recognized by kubernetes after this deletion, " + "you probably have installed nvidia-device-plugin or fuse-device-plugin before installing AMLArc extension. " + "Please try to reinstall device plugins to fix this issue.") + def __validate_config(self, configuration_settings, configuration_protected_settings): # perform basic validation of the input config config_keys = configuration_settings.keys() @@ -226,7 +232,7 @@ def __validate_scoring_fe_settings(self, configuration_settings, configuration_p if feIsNodePort and feIsInternalLoadBalancer: raise MutuallyExclusiveArgumentError( "Specify either privateEndpointNodeport=true or privateEndpointILB=true, but not both.") - elif feIsNodePort: + if feIsNodePort: configuration_settings['scoringFe.serviceType.nodePort'] = feIsNodePort elif feIsInternalLoadBalancer: configuration_settings['scoringFe.serviceType.internalLoadBalancer'] = feIsInternalLoadBalancer diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/Cassandra.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/Cassandra.py index 2357bf08af6..289e8053223 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/Cassandra.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/Cassandra.py @@ -55,3 +55,6 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version): release_train=release_train, version=version ) + + def Delete(self, client, resource_group_name, cluster_name, name, cluster_type): + pass diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py index e42f22199da..1c2a334cdda 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py @@ -82,6 +82,9 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version): version=version ) + def Delete(self, client, resource_group_name, cluster_name, name, cluster_type): + pass + # Custom Validation Logic for Container Insights diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py index a72aef847fc..8977ec4187e 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py @@ -55,3 +55,6 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version): release_train=release_train, version=version ) + + def Delete(self, client, resource_group_name, cluster_name, name, cluster_type): + pass diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py index 6d11064821c..c5ad73ac35f 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py @@ -4,21 +4,39 @@ # -------------------------------------------------------------------------------------------- # pylint: disable=unused-argument +# pylint: disable=redefined-outer-name +# pylint: disable=no-member -from azure.cli.core.azclierror import InvalidArgumentValueError, RequiredArgumentMissingError from knack.log import get_logger -from ..vendored_sdks.models import ExtensionInstance -from ..vendored_sdks.models import ExtensionInstanceUpdate -from ..vendored_sdks.models import ScopeCluster -from ..vendored_sdks.models import Scope +from azure.cli.core.azclierror import InvalidArgumentValueError, RequiredArgumentMissingError +from azure.cli.core.commands.client_factory import get_subscription_id + +from pyhelm.chartbuilder import ChartBuilder +from pyhelm.repo import VersionError +from packaging import version +import yaml + +from ..partner_extensions import PartnerExtensionModel from .PartnerExtensionModel import PartnerExtensionModel +from ..vendored_sdks.models import ( + ExtensionInstance, + ExtensionInstanceUpdate, + ScopeCluster, + Scope +) + +from .._client_factory import cf_resources + logger = get_logger(__name__) class OpenServiceMesh(PartnerExtensionModel): + CHART_NAME = "osm-arc" + CHART_LOCATION = "https://azure.github.io/osm-azure" + def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type, scope, auto_upgrade_minor_version, release_train, version, target_namespace, release_namespace, configuration_settings, configuration_protected_settings, @@ -38,30 +56,21 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t scope_cluster = ScopeCluster(release_namespace=release_namespace) ext_scope = Scope(cluster=scope_cluster, namespace=None) - valid_release_trains = ['staging', 'pilot'] - # If release-train is not input, set it to 'stable' - if release_train is None: + # version is a mandatory if release-train is staging or pilot + if version is None: raise RequiredArgumentMissingError( - "A release-train must be provided. Valid values are 'staging', 'pilot'." - ) - - if release_train.lower() in valid_release_trains: - # version is a mandatory if release-train is staging or pilot - if version is None: - raise RequiredArgumentMissingError( - "A version must be provided for release-train {}.".format(release_train) - ) - # If the release-train is 'staging' or 'pilot' then auto-upgrade-minor-version MUST be set to False - if auto_upgrade_minor_version or auto_upgrade_minor_version is None: - auto_upgrade_minor_version = False - logger.warning("Setting auto-upgrade-minor-version to False since release-train is '%s'", release_train) - else: - raise InvalidArgumentValueError( - "Invalid release-train '{}'. Valid values are 'staging', 'pilot'.".format(release_train) + "A version must be provided for release-train {}.".format(release_train) ) + # If the release-train is 'staging' or 'pilot' then auto-upgrade-minor-version MUST be set to False + if auto_upgrade_minor_version or auto_upgrade_minor_version is None: + auto_upgrade_minor_version = False + logger.warning("Setting auto-upgrade-minor-version to False since release-train is '%s'", release_train) # NOTE-2: Return a valid ExtensionInstance object, Instance name and flag for Identity create_identity = False + + _validate_tested_distro(cmd, resource_group_name, cluster_name, version) + extension_instance = ExtensionInstance( extension_type=extension_type, auto_upgrade_minor_version=auto_upgrade_minor_version, @@ -93,3 +102,63 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version): release_train=release_train, version=version ) + + def Delete(self, client, resource_group_name, cluster_name, name, cluster_type): + pass + + +def _validate_tested_distro(cmd, cluster_resource_group_name, cluster_name, extension_version): + + field_unavailable_error = '\"testedDistros\" field unavailable for version {0} of microsoft.openservicemesh, ' \ + 'cannot determine if this Kubernetes distribution has been properly tested'.format(extension_version) + + if version.parse(str(extension_version)) <= version.parse("0.8.3"): + logger.warning(field_unavailable_error) + return + + subscription_id = get_subscription_id(cmd.cli_ctx) + resources = cf_resources(cmd.cli_ctx, subscription_id) + + cluster_resource_id = '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Kubernetes' \ + '/connectedClusters/{2}'.format(subscription_id, cluster_resource_group_name, cluster_name) + + resource = resources.get_by_id(cluster_resource_id, '2020-01-01-preview') + cluster_distro = resource.properties['distribution'].lower() + + if cluster_distro == "general": + logger.warning('Unable to determine if distro has been tested for microsoft.openservicemesh, ' + 'kubernetes distro: \"general\"') + return + + tested_distros = _get_tested_distros(extension_version) + + if tested_distros is None: + logger.warning(field_unavailable_error) + elif cluster_distro not in tested_distros.split(): + logger.warning('Untested kubernetes distro for microsoft.openservicemesh, Kubernetes distro is %s', + cluster_distro) + + +def _get_tested_distros(chart_version): + + try: + chart_arc = ChartBuilder({ + "name": OpenServiceMesh.CHART_NAME, + "version": str(chart_version), + "source": { + "type": "repo", + "location": OpenServiceMesh.CHART_LOCATION + } + }) + except VersionError: + raise InvalidArgumentValueError( + "Invalid version '{}' for microsoft.openservicemesh".format(chart_version) + ) + + values = chart_arc.get_values() + values_yaml = yaml.load(values.raw, Loader=yaml.FullLoader) + + try: + return values_yaml['OpenServiceMesh']['testedDistros'] + except KeyError: + return None diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py index b8cb01334d3..98a6c1ea63f 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py @@ -21,3 +21,7 @@ def Create(self, cmd, client, resource_group_name: str, cluster_name: str, name: def Update(self, extension: ExtensionInstance, auto_upgrade_minor_version: bool, release_train: str, version: str) -> ExtensionInstanceUpdate: pass + + @abstractmethod + def Delete(self, client, resource_group_name: str, cluster_name: str, name: str, cluster_type: str): + pass diff --git a/src/k8s-extension/azext_k8s_extension/tests/latest/recordings/test_k8s_extension.yaml b/src/k8s-extension/azext_k8s_extension/tests/latest/recordings/test_k8s_extension.yaml index 127b21ac873..c55ebb0a737 100644 --- a/src/k8s-extension/azext_k8s_extension/tests/latest/recordings/test_k8s_extension.yaml +++ b/src/k8s-extension/azext_k8s_extension/tests/latest/recordings/test_k8s_extension.yaml @@ -1,9 +1,58 @@ interactions: - request: - body: '{"properties": {"extensionType": "microsoft.openservicemesh", "autoUpgradeMinorVersion": - false, "releaseTrain": "staging", "version": "0.1.0", "scope": {"cluster": {}}, - "configurationSettings": {}, "configurationProtectedSettings": {}}, "location": - ""}' + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - k8s-extension create + Connection: + - keep-alive + ParameterSetName: + - -g -n -c --cluster-type --extension-type --release-train --version + User-Agent: + - AZURECLI/2.24.2 azsdk-python-azure-mgmt-resource/18.0.0 Python/3.9.0 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.KubernetesConfiguration?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.KubernetesConfiguration","namespace":"Microsoft.KubernetesConfiguration","authorizations":[{"applicationId":"c699bf69-fb1d-4eaf-999b-99e6b2ae4d85","roleDefinitionId":"90155430-a360-410f-af5d-89dc284d85c6"},{"applicationId":"03db181c-e9d3-4868-9097-f0b728327182","roleDefinitionId":"DE2ADB97-42D8-49C8-8FCF-DBB53EF936AC"},{"applicationId":"a0f92522-89de-4c5e-9a75-0044ccf66efd","roleDefinitionId":"b3429810-7d5c-420e-8605-cf280f3099f2"},{"applicationId":"bd9b7cd5-dac1-495f-b013-ac871e98fa5f","roleDefinitionId":"0d44c8f0-08b9-44d4-9f59-e51c83f95200"}],"resourceTypes":[{"resourceType":"sourceControlConfigurations","locations":["East + US","West Europe","West Central US","West US 2","South Central US","East US + 2","North Europe","UK South","Southeast Asia","Australia East","France Central","East + US 2 EUAP"],"apiVersions":["2021-03-01","2020-10-01-preview","2020-07-01-preview","2019-11-01-preview"],"defaultApiVersion":"2021-03-01","capabilities":"SupportsExtension"},{"resourceType":"extensions","locations":["East + US","West Europe","West Central US","West US 2","South Central US","East US + 2","North Europe","UK South","Southeast Asia","Australia East","France Central","East + US 2 EUAP"],"apiVersions":["2021-05-01-preview","2020-07-01-preview"],"capabilities":"SystemAssignedResourceIdentity, + SupportsExtension"},{"resourceType":"operations","locations":[],"apiVersions":["2021-05-01-preview","2021-03-01","2020-10-01-preview","2020-07-01-preview","2019-11-01-preview"],"capabilities":"None"}],"registrationState":"Registered","registrationPolicy":"RegistrationRequired"}' + headers: + cache-control: + - no-cache + content-length: + - '1654' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Jun 2021 23:19:11 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "", "properties": {"extensionType": "microsoft.openservicemesh", + "autoUpgradeMinorVersion": false, "releaseTrain": "pilot", "version": "0.8.3", + "scope": {"cluster": {}}, "configurationSettings": {}, "configurationProtectedSettings": + {}}}' headers: Accept: - application/json @@ -14,32 +63,32 @@ interactions: Connection: - keep-alive Content-Length: - - '252' + - '250' Content-Type: - application/json; charset=utf-8 ParameterSetName: - -g -n -c --cluster-type --extension-type --release-train --version User-Agent: - python/3.9.0 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.4 - azure-mgmt-kubernetesconfiguration/0.1.0 Azure-SDK-For-Python AZURECLI/2.19.1 + azure-mgmt-kubernetesconfiguration/0.3.0 Azure-SDK-For-Python AZURECLI/2.24.2 accept-language: - en-US method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservice-mesh?api-version=2020-07-01-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservicemesh?api-version=2020-07-01-preview response: body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservice-mesh","name":"openservice-mesh","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"configurationSettings":{},"statuses":[],"extensionType":"microsoft.openservicemesh","autoUpgradeMinorVersion":false,"releaseTrain":"staging","version":"0.1.0","scope":{"cluster":{"releaseNamespace":"arc-osm-system"}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-03-08T23:14:12.4010326+00:00","lastModifiedTime":"2021-03-08T23:14:12.4010327+00:00"}}' + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservicemesh","name":"openservicemesh","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"configurationSettings":{},"statuses":[],"extensionType":"microsoft.openservicemesh","autoUpgradeMinorVersion":false,"releaseTrain":"pilot","version":"0.8.3","scope":{"cluster":{"releaseNamespace":"arc-osm-system"}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-06-22T23:19:13.9750935+00:00","lastModifiedTime":"2021-06-22T23:19:13.9750935+00:00"}}' headers: api-supported-versions: - - 2020-07-01-Preview + - 2020-07-01-Preview, 2021-05-01-preview cache-control: - no-cache content-length: - - '708' + - '704' content-type: - application/json; charset=utf-8 date: - - Mon, 08 Mar 2021 23:14:11 GMT + - Tue, 22 Jun 2021 23:19:13 GMT expires: - '-1' pragma: @@ -74,25 +123,25 @@ interactions: - -c -g --cluster-type User-Agent: - python/3.9.0 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.4 - azure-mgmt-kubernetesconfiguration/0.1.0 Azure-SDK-For-Python AZURECLI/2.19.1 + azure-mgmt-kubernetesconfiguration/0.3.0 Azure-SDK-For-Python AZURECLI/2.24.2 accept-language: - en-US method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions?api-version=2020-07-01-preview response: body: - string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservice-mesh","name":"openservice-mesh","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"extensionType":"microsoft.openservicemesh","autoUpgradeMinorVersion":false,"releaseTrain":"staging","version":"0.1.0","scope":{"cluster":{"releaseNamespace":"arc-osm-system"}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-03-08T23:14:12.4010326+00:00","lastModifiedTime":"2021-03-08T23:14:12.4010327+00:00"}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/hci22jan21","name":"hci22jan21","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"extensionType":"microsoft.azstackhci.operator","autoUpgradeMinorVersion":true,"releaseTrain":"stable","version":"1.0.0","scope":{"cluster":{"releaseNamespace":null}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-01-22T20:49:34.3336157+00:00","lastModifiedTime":"2021-01-22T20:49:34.3336249+00:00"}}],"nextLink":null}' + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservicemesh","name":"openservicemesh","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"extensionType":"microsoft.openservicemesh","autoUpgradeMinorVersion":false,"releaseTrain":"pilot","version":"0.8.3","scope":{"cluster":{"releaseNamespace":"arc-osm-system"}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-06-22T23:19:13.9750935+00:00","lastModifiedTime":"2021-06-22T23:19:13.9750935+00:00"}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/hci22jan21","name":"hci22jan21","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"extensionType":"microsoft.azstackhci.operator","autoUpgradeMinorVersion":true,"releaseTrain":"stable","version":"1.0.0","scope":{"cluster":{"releaseNamespace":null}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-01-22T20:49:34.3336157+00:00","lastModifiedTime":"2021-01-22T20:49:34.3336249+00:00"}}],"nextLink":null}' headers: api-supported-versions: - - 2020-07-01-Preview + - 2020-07-01-Preview, 2021-05-01-preview cache-control: - no-cache content-length: - - '1341' + - '1337' content-type: - application/json; charset=utf-8 date: - - Mon, 08 Mar 2021 23:14:13 GMT + - Tue, 22 Jun 2021 23:19:14 GMT expires: - '-1' pragma: @@ -125,25 +174,76 @@ interactions: - -c -g -n --cluster-type User-Agent: - python/3.9.0 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.4 - azure-mgmt-kubernetesconfiguration/0.1.0 Azure-SDK-For-Python AZURECLI/2.19.1 + azure-mgmt-kubernetesconfiguration/0.3.0 Azure-SDK-For-Python AZURECLI/2.24.2 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservicemesh?api-version=2020-07-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservicemesh","name":"openservicemesh","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"configurationSettings":{},"statuses":[],"extensionType":"microsoft.openservicemesh","autoUpgradeMinorVersion":false,"releaseTrain":"pilot","version":"0.8.3","scope":{"cluster":{"releaseNamespace":"arc-osm-system"}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-06-22T23:19:13.9750935+00:00","lastModifiedTime":"2021-06-22T23:19:13.9750935+00:00"}}' + headers: + api-supported-versions: + - 2020-07-01-Preview, 2021-05-01-preview + cache-control: + - no-cache + content-length: + - '704' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Jun 2021 23:19:15 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - openresty/1.15.8.2 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - k8s-extension delete + Connection: + - keep-alive + ParameterSetName: + - -g -c -n --cluster-type -y + User-Agent: + - python/3.9.0 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.4 + azure-mgmt-kubernetesconfiguration/0.3.0 Azure-SDK-For-Python AZURECLI/2.24.2 accept-language: - en-US method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservice-mesh?api-version=2020-07-01-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservicemesh?api-version=2020-07-01-preview response: body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservice-mesh","name":"openservice-mesh","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"configurationSettings":{},"statuses":[],"extensionType":"microsoft.openservicemesh","autoUpgradeMinorVersion":false,"releaseTrain":"staging","version":"0.1.0","scope":{"cluster":{"releaseNamespace":"arc-osm-system"}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-03-08T23:14:12.4010326+00:00","lastModifiedTime":"2021-03-08T23:14:12.4010327+00:00"}}' + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservicemesh","name":"openservicemesh","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"configurationSettings":{},"statuses":[],"extensionType":"microsoft.openservicemesh","autoUpgradeMinorVersion":false,"releaseTrain":"pilot","version":"0.8.3","scope":{"cluster":{"releaseNamespace":"arc-osm-system"}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-06-22T23:19:13.9750935+00:00","lastModifiedTime":"2021-06-22T23:19:13.9750935+00:00"}}' headers: api-supported-versions: - - 2020-07-01-Preview + - 2020-07-01-Preview, 2021-05-01-preview cache-control: - no-cache content-length: - - '708' + - '704' content-type: - application/json; charset=utf-8 date: - - Mon, 08 Mar 2021 23:14:14 GMT + - Tue, 22 Jun 2021 23:19:16 GMT expires: - '-1' pragma: @@ -178,17 +278,17 @@ interactions: - -g -c -n --cluster-type -y User-Agent: - python/3.9.0 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.4 - azure-mgmt-kubernetesconfiguration/0.1.0 Azure-SDK-For-Python AZURECLI/2.19.1 + azure-mgmt-kubernetesconfiguration/0.3.0 Azure-SDK-For-Python AZURECLI/2.24.2 accept-language: - en-US method: DELETE - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservice-mesh?api-version=2020-07-01-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservicemesh?api-version=2020-07-01-preview response: body: string: '{"content":null,"statusCode":200,"headers":[],"version":"1.1","reasonPhrase":"OK","trailingHeaders":[],"requestMessage":null,"isSuccessStatusCode":true}' headers: api-supported-versions: - - 2020-07-01-Preview + - 2020-07-01-Preview, 2021-05-01-preview cache-control: - no-cache content-length: @@ -196,7 +296,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 08 Mar 2021 23:14:14 GMT + - Tue, 22 Jun 2021 23:19:17 GMT expires: - '-1' pragma: @@ -231,7 +331,7 @@ interactions: - -c -g --cluster-type User-Agent: - python/3.9.0 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.4 - azure-mgmt-kubernetesconfiguration/0.1.0 Azure-SDK-For-Python AZURECLI/2.19.1 + azure-mgmt-kubernetesconfiguration/0.3.0 Azure-SDK-For-Python AZURECLI/2.24.2 accept-language: - en-US method: GET @@ -241,7 +341,7 @@ interactions: string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/hci22jan21","name":"hci22jan21","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"extensionType":"microsoft.azstackhci.operator","autoUpgradeMinorVersion":true,"releaseTrain":"stable","version":"1.0.0","scope":{"cluster":{"releaseNamespace":null}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-01-22T20:49:34.3336157+00:00","lastModifiedTime":"2021-01-22T20:49:34.3336249+00:00"}}],"nextLink":null}' headers: api-supported-versions: - - 2020-07-01-Preview + - 2020-07-01-Preview, 2021-05-01-preview cache-control: - no-cache content-length: @@ -249,7 +349,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 08 Mar 2021 23:14:16 GMT + - Tue, 22 Jun 2021 23:19:19 GMT expires: - '-1' pragma: diff --git a/src/k8s-extension/azext_k8s_extension/tests/latest/test_k8s_extension_scenario.py b/src/k8s-extension/azext_k8s_extension/tests/latest/test_k8s_extension_scenario.py index 010df2e3077..53db4ce2c2d 100644 --- a/src/k8s-extension/azext_k8s_extension/tests/latest/test_k8s_extension_scenario.py +++ b/src/k8s-extension/azext_k8s_extension/tests/latest/test_k8s_extension_scenario.py @@ -6,7 +6,7 @@ # pylint: disable=line-too-long import os -from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, record_only) +from azure.cli.testsdk import (ScenarioTest, record_only) TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) @@ -14,17 +14,16 @@ class K8sExtensionScenarioTest(ScenarioTest): @record_only() - @ResourceGroupPreparer(name_prefix='cli_test_k8s_extension') def test_k8s_extension(self): resource_type = 'microsoft.openservicemesh' self.kwargs.update({ - 'name': 'openservice-mesh', + 'name': 'openservicemesh', 'rg': 'nanthirg0923', 'cluster_name': 'nanthicluster0923', 'cluster_type': 'connectedClusters', 'extension_type': resource_type, - 'release_train': 'staging', - 'version': '0.1.0' + 'release_train': 'pilot', + 'version': '0.8.3' }) self.cmd('k8s-extension create -g {rg} -n {name} -c {cluster_name} --cluster-type {cluster_type} ' diff --git a/src/k8s-extension/azext_k8s_extension/tests/latest/test_open_service_mesh.py b/src/k8s-extension/azext_k8s_extension/tests/latest/test_open_service_mesh.py new file mode 100644 index 00000000000..72e94a06831 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/tests/latest/test_open_service_mesh.py @@ -0,0 +1,22 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=protected-access + +import os +import unittest + +from azure.cli.core.azclierror import InvalidArgumentValueError +from azext_k8s_extension.partner_extensions.OpenServiceMesh import _get_tested_distros + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + +class TestOpenServiceMesh(unittest.TestCase): + def test_bad_osm_arc_version(self): + version = "0.7.1" + err = "Invalid version \'" + str(version) + "\' for microsoft.openservicemesh" + with self.assertRaises(InvalidArgumentValueError) as argError: + _get_tested_distros(version) + self.assertEqual(str(argError.exception), err) diff --git a/src/k8s-extension/setup.py b/src/k8s-extension/setup.py index 7937b085006..a8400af15cc 100644 --- a/src/k8s-extension/setup.py +++ b/src/k8s-extension/setup.py @@ -30,9 +30,11 @@ ] # TODO: Add any additional SDK dependencies here -DEPENDENCIES = [] +DEPENDENCIES = [ + 'pyhelm' +] -VERSION = "0.4.3" +VERSION = "0.5.0" with open('README.rst', 'r', encoding='utf-8') as f: README = f.read()