Skip to content
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

Merge in k8s-extension/public (0.3.1) #32

Merged
merged 5 commits into from
May 11, 2021
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
6 changes: 6 additions & 0 deletions src/k8s-extension/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Release History
===============

0.3.1
++++++++++++++++++

* Add provider registration to check to validations
* Only validate scoring fe settings when inference is enabled in microsoft.azureml.kubernetes

0.3.0
++++++++++++++++++

Expand Down
6 changes: 6 additions & 0 deletions src/k8s-extension/HISTORY_private.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Release History
===============

0.3.1-beta.1
++++++++++++++++++

* Add provider registration to check to validations
* Only validate scoring fe settings when inference is enabled in microsoft.azureml.kubernetes

0.3.0-beta.1
++++++++++++++++++
* Release customization for microsoft.azureml.kubernetes
Expand Down
5 changes: 5 additions & 0 deletions src/k8s-extension/azext_k8s_extension/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ def cf_resources(cli_ctx, subscription_id=None):
def cf_log_analytics(cli_ctx, subscription_id=None):
from azure.mgmt.loganalytics import LogAnalyticsManagementClient # pylint: disable=no-name-in-module
return get_mgmt_service_client(cli_ctx, LogAnalyticsManagementClient, subscription_id=subscription_id)


def _resource_providers_client(cli_ctx):
from azure.mgmt.resource import ResourceManagementClient
return get_mgmt_service_client(cli_ctx, ResourceManagementClient).providers
26 changes: 26 additions & 0 deletions src/k8s-extension/azext_k8s_extension/_validators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from knack.log import get_logger
from azext_k8s_extension._client_factory import _resource_providers_client
from . import consts


logger = get_logger(__name__)


# pylint: disable=broad-except
def _validate_cc_registration(cmd):
try:
rp_client = _resource_providers_client(cmd.cli_ctx)
registration_state = rp_client.get(consts.PROVIDER_NAMESPACE).registration_state

if registration_state != "Registered":
logger.warning("'Extensions' cannot be used because '%s' provider has not been registered."
"More details for registering this provider can be found here - "
"https://aka.ms/RegisterKubernetesConfigurationProvider", consts.PROVIDER_NAMESPACE)
except Exception:
logger.warning("Unable to fetch registration state of '%s' provider. "
"Failed to enable 'extensions' feature...", consts.PROVIDER_NAMESPACE)
1 change: 1 addition & 0 deletions src/k8s-extension/azext_k8s_extension/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

EXTENSION_NAME = 'k8s-extension'
EXTENSION_PACKAGE_NAME = "azext_k8s_extension"
PROVIDER_NAMESPACE = 'Microsoft.KubernetesConfiguration'
13 changes: 8 additions & 5 deletions src/k8s-extension/azext_k8s_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
from azure.cli.core.azclierror import ResourceNotFoundError, MutuallyExclusiveArgumentError, \
InvalidArgumentValueError, CommandNotFoundError, RequiredArgumentMissingError
from azure.cli.core.commands.client_factory import get_subscription_id
from .vendored_sdks.models import ConfigurationIdentity
from .vendored_sdks.models import ErrorResponseException
from .vendored_sdks.models import Scope
from azext_k8s_extension.vendored_sdks.models import ConfigurationIdentity
from azext_k8s_extension.vendored_sdks.models import ErrorResponseException
from azext_k8s_extension.vendored_sdks.models import Scope
from azext_k8s_extension._validators import _validate_cc_registration

from .partner_extensions.ContainerInsights import ContainerInsights
from .partner_extensions.AzureDefender import AzureDefender
Expand Down Expand Up @@ -82,9 +83,8 @@ def create_k8s_extension(cmd, client, resource_group_name, cluster_name, name, c
"""Create a new Extension Instance.
"""
extension_type_lower = extension_type.lower()

# Determine ClusterRP
extension_type_lower = extension_type.lower()
cluster_rp = __get_cluster_rp(cluster_type)

# Configuration Settings & Configuration Protected Settings
Expand Down Expand Up @@ -139,6 +139,9 @@ def create_k8s_extension(cmd, client, resource_group_name, cluster_name, name, c
__validate_version_and_auto_upgrade(extension_instance.version, extension_instance.auto_upgrade_minor_version)
__validate_scope_after_customization(extension_instance.scope)

# Check that registration has been done on Microsoft.KubernetesConfiguration for the subscription
_validate_cc_registration(cmd)

# Create identity, if required
if create_identity:
extension_instance.identity, extension_instance.location = \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,13 @@ def __validate_config(self, configuration_settings, configuration_protected_sett

if enable_inference:
logger.warning("The installed AzureML extension for AML inference is experimental and not covered by customer support. Please use with discretion.")
self.__validate_scoring_fe_settings(configuration_settings, configuration_protected_settings)
elif not (enable_training or enable_inference):
raise InvalidArgumentValueError(
"Please create Microsoft.AzureML.Kubernetes extension instance either "
"for Machine Learning training or inference by specifying "
f"'--configuration-settings {self.ENABLE_TRAINING}=true' or '--configuration-settings {self.ENABLE_INFERENCE}=true'")

self.__validate_scoring_fe_settings(configuration_settings, configuration_protected_settings)

configuration_settings[self.ENABLE_TRAINING] = configuration_settings.get(self.ENABLE_TRAINING, enable_training)
configuration_settings[self.ENABLE_INFERENCE] = configuration_settings.get(
self.ENABLE_INFERENCE, enable_inference)
Expand Down
2 changes: 1 addition & 1 deletion src/k8s-extension/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# TODO: Add any additional SDK dependencies here
DEPENDENCIES = []

VERSION = "0.3.0"
VERSION = "0.3.1"

with open('README.rst', 'r', encoding='utf-8') as f:
README = f.read()
Expand Down
2 changes: 1 addition & 1 deletion src/k8s-extension/setup_private.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# TODO: Add any additional SDK dependencies here
DEPENDENCIES = []

VERSION = "0.3.0-beta.1"
VERSION = "0.3.1-beta.1"

with open('README.rst', 'r', encoding='utf-8') as f:
README = f.read()
Expand Down
9 changes: 9 additions & 0 deletions testing/test/extensions/public/AzureMLKubernetes.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Describe 'AzureML Kubernetes Testing' {
$extensionName = "azureml-kubernetes-connector"
$extensionAgentNamespace = "azureml"
$relayResourceIDKey = "relayserver.hybridConnectionResourceID"
$serviceBusResourceIDKey = "servicebus.resourceID"

. $PSScriptRoot/../../helper/Constants.ps1
. $PSScriptRoot/../../helper/Helper.ps1
Expand Down Expand Up @@ -78,6 +79,14 @@ Describe 'AzureML Kubernetes Testing' {
}

It "Deletes the extension from the cluster" {
# cleanup the relay and servicebus
$relayResourceID = Get-ExtensionConfigurationSettings $extensionName $relayResourceIDKey
$serviceBusResourceID = Get-ExtensionConfigurationSettings $extensionName $serviceBusResourceIDKey
$relayNamespaceName = $relayResourceID.split("/")[8]
$serviceBusNamespaceName = $serviceBusResourceID.split("/")[8]
az relay namespace delete --resource-group $ENVCONFIG.resourceGroup --name $relayNamespaceName
az servicebus namespace delete --resource-group $ENVCONFIG.resourceGroup --name $serviceBusNamespaceName

az k8s-extension delete --cluster-name $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters --name $extensionName
$? | Should -BeTrue

Expand Down