Skip to content

Commit 4bf9017

Browse files
jonathan-innisyuyue9284Yue Yuliakaznshankar13
authored
[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: [email protected] <Action - Fork Sync> * 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 <[email protected]> Co-authored-by: jonathan-innis <[email protected]> * 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 <[email protected]> * 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 <[email protected]> Co-authored-by: Jonathan Innis <[email protected]> * 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 <[email protected]> Co-authored-by: jonathan-innis <[email protected]> * 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 <[email protected]> Co-authored-by: Jonathan Innis <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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: [email protected] <Action - Fork Sync> Co-authored-by: yuyue9284 <[email protected]> Co-authored-by: Yue Yu <[email protected]> Co-authored-by: Lia Kazakova <[email protected]> Co-authored-by: Niranjan Shankar <[email protected]> Co-authored-by: jingyizhu99 <[email protected]>
1 parent b4e0709 commit 4bf9017

File tree

13 files changed

+291
-62
lines changed

13 files changed

+291
-62
lines changed

src/k8s-extension/HISTORY.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
Release History
44
===============
55

6+
0.5.0
7+
++++++++++++++++++
8+
* Add microsoft.openservicemesh customization to check distros
9+
* Delete customization for partners
10+
611
0.4.3
712
++++++++++++++++++
813
* Add SSL support for AzureML
914

10-
1115
0.4.2
1216
++++++++++++++++++
1317

src/k8s-extension/azext_k8s_extension/custom.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,17 @@ def delete_k8s_extension(client, resource_group_name, cluster_name, name, cluste
195195
"""
196196
# Determine ClusterRP
197197
cluster_rp = __get_cluster_rp(cluster_type)
198+
extension = None
199+
try:
200+
extension = client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name)
201+
except ErrorResponseException:
202+
logger.warning("No extension with name '%s' found on cluster '%s', so nothing to delete", cluster_name, name)
203+
return None
204+
extension_class = ExtensionFactory(extension.extension_type.lower())
205+
206+
# If there is any custom delete logic, this will call the logic
207+
extension_class.Delete(client, resource_group_name, cluster_name, name, cluster_type)
208+
198209
return client.delete(resource_group_name, cluster_rp, cluster_type, cluster_name, name)
199210

200211

src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version):
7070
release_train=release_train,
7171
version=version
7272
)
73+
74+
def Delete(self, client, resource_group_name, cluster_name, name, cluster_type):
75+
pass

src/k8s-extension/azext_k8s_extension/partner_extensions/AzureMLKubernetes.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version):
162162
version=version
163163
)
164164

165+
def Delete(self, client, resource_group_name, cluster_name, name, cluster_type):
166+
# Give a warning message
167+
logger.warning("If nvidia.com/gpu or fuse resource is not recognized by kubernetes after this deletion, "
168+
"you probably have installed nvidia-device-plugin or fuse-device-plugin before installing AMLArc extension. "
169+
"Please try to reinstall device plugins to fix this issue.")
170+
165171
def __validate_config(self, configuration_settings, configuration_protected_settings):
166172
# perform basic validation of the input config
167173
config_keys = configuration_settings.keys()
@@ -226,7 +232,7 @@ def __validate_scoring_fe_settings(self, configuration_settings, configuration_p
226232
if feIsNodePort and feIsInternalLoadBalancer:
227233
raise MutuallyExclusiveArgumentError(
228234
"Specify either privateEndpointNodeport=true or privateEndpointILB=true, but not both.")
229-
elif feIsNodePort:
235+
if feIsNodePort:
230236
configuration_settings['scoringFe.serviceType.nodePort'] = feIsNodePort
231237
elif feIsInternalLoadBalancer:
232238
configuration_settings['scoringFe.serviceType.internalLoadBalancer'] = feIsInternalLoadBalancer

src/k8s-extension/azext_k8s_extension/partner_extensions/Cassandra.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version):
5555
release_train=release_train,
5656
version=version
5757
)
58+
59+
def Delete(self, client, resource_group_name, cluster_name, name, cluster_type):
60+
pass

src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version):
8282
version=version
8383
)
8484

85+
def Delete(self, client, resource_group_name, cluster_name, name, cluster_type):
86+
pass
87+
8588

8689
# Custom Validation Logic for Container Insights
8790

src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version):
5555
release_train=release_train,
5656
version=version
5757
)
58+
59+
def Delete(self, client, resource_group_name, cluster_name, name, cluster_type):
60+
pass

src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py

Lines changed: 93 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,39 @@
44
# --------------------------------------------------------------------------------------------
55

66
# pylint: disable=unused-argument
7+
# pylint: disable=redefined-outer-name
8+
# pylint: disable=no-member
79

8-
from azure.cli.core.azclierror import InvalidArgumentValueError, RequiredArgumentMissingError
910
from knack.log import get_logger
1011

11-
from ..vendored_sdks.models import ExtensionInstance
12-
from ..vendored_sdks.models import ExtensionInstanceUpdate
13-
from ..vendored_sdks.models import ScopeCluster
14-
from ..vendored_sdks.models import Scope
12+
from azure.cli.core.azclierror import InvalidArgumentValueError, RequiredArgumentMissingError
13+
from azure.cli.core.commands.client_factory import get_subscription_id
14+
15+
from pyhelm.chartbuilder import ChartBuilder
16+
from pyhelm.repo import VersionError
17+
from packaging import version
18+
import yaml
19+
20+
from ..partner_extensions import PartnerExtensionModel
1521

1622
from .PartnerExtensionModel import PartnerExtensionModel
1723

24+
from ..vendored_sdks.models import (
25+
ExtensionInstance,
26+
ExtensionInstanceUpdate,
27+
ScopeCluster,
28+
Scope
29+
)
30+
31+
from .._client_factory import cf_resources
32+
1833
logger = get_logger(__name__)
1934

2035

2136
class OpenServiceMesh(PartnerExtensionModel):
37+
CHART_NAME = "osm-arc"
38+
CHART_LOCATION = "https://azure.github.io/osm-azure"
39+
2240
def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type,
2341
scope, auto_upgrade_minor_version, release_train, version, target_namespace,
2442
release_namespace, configuration_settings, configuration_protected_settings,
@@ -38,30 +56,21 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t
3856
scope_cluster = ScopeCluster(release_namespace=release_namespace)
3957
ext_scope = Scope(cluster=scope_cluster, namespace=None)
4058

41-
valid_release_trains = ['staging', 'pilot']
42-
# If release-train is not input, set it to 'stable'
43-
if release_train is None:
59+
# version is a mandatory if release-train is staging or pilot
60+
if version is None:
4461
raise RequiredArgumentMissingError(
45-
"A release-train must be provided. Valid values are 'staging', 'pilot'."
46-
)
47-
48-
if release_train.lower() in valid_release_trains:
49-
# version is a mandatory if release-train is staging or pilot
50-
if version is None:
51-
raise RequiredArgumentMissingError(
52-
"A version must be provided for release-train {}.".format(release_train)
53-
)
54-
# If the release-train is 'staging' or 'pilot' then auto-upgrade-minor-version MUST be set to False
55-
if auto_upgrade_minor_version or auto_upgrade_minor_version is None:
56-
auto_upgrade_minor_version = False
57-
logger.warning("Setting auto-upgrade-minor-version to False since release-train is '%s'", release_train)
58-
else:
59-
raise InvalidArgumentValueError(
60-
"Invalid release-train '{}'. Valid values are 'staging', 'pilot'.".format(release_train)
62+
"A version must be provided for release-train {}.".format(release_train)
6163
)
64+
# If the release-train is 'staging' or 'pilot' then auto-upgrade-minor-version MUST be set to False
65+
if auto_upgrade_minor_version or auto_upgrade_minor_version is None:
66+
auto_upgrade_minor_version = False
67+
logger.warning("Setting auto-upgrade-minor-version to False since release-train is '%s'", release_train)
6268

6369
# NOTE-2: Return a valid ExtensionInstance object, Instance name and flag for Identity
6470
create_identity = False
71+
72+
_validate_tested_distro(cmd, resource_group_name, cluster_name, version)
73+
6574
extension_instance = ExtensionInstance(
6675
extension_type=extension_type,
6776
auto_upgrade_minor_version=auto_upgrade_minor_version,
@@ -93,3 +102,63 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version):
93102
release_train=release_train,
94103
version=version
95104
)
105+
106+
def Delete(self, client, resource_group_name, cluster_name, name, cluster_type):
107+
pass
108+
109+
110+
def _validate_tested_distro(cmd, cluster_resource_group_name, cluster_name, extension_version):
111+
112+
field_unavailable_error = '\"testedDistros\" field unavailable for version {0} of microsoft.openservicemesh, ' \
113+
'cannot determine if this Kubernetes distribution has been properly tested'.format(extension_version)
114+
115+
if version.parse(str(extension_version)) <= version.parse("0.8.3"):
116+
logger.warning(field_unavailable_error)
117+
return
118+
119+
subscription_id = get_subscription_id(cmd.cli_ctx)
120+
resources = cf_resources(cmd.cli_ctx, subscription_id)
121+
122+
cluster_resource_id = '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Kubernetes' \
123+
'/connectedClusters/{2}'.format(subscription_id, cluster_resource_group_name, cluster_name)
124+
125+
resource = resources.get_by_id(cluster_resource_id, '2020-01-01-preview')
126+
cluster_distro = resource.properties['distribution'].lower()
127+
128+
if cluster_distro == "general":
129+
logger.warning('Unable to determine if distro has been tested for microsoft.openservicemesh, '
130+
'kubernetes distro: \"general\"')
131+
return
132+
133+
tested_distros = _get_tested_distros(extension_version)
134+
135+
if tested_distros is None:
136+
logger.warning(field_unavailable_error)
137+
elif cluster_distro not in tested_distros.split():
138+
logger.warning('Untested kubernetes distro for microsoft.openservicemesh, Kubernetes distro is %s',
139+
cluster_distro)
140+
141+
142+
def _get_tested_distros(chart_version):
143+
144+
try:
145+
chart_arc = ChartBuilder({
146+
"name": OpenServiceMesh.CHART_NAME,
147+
"version": str(chart_version),
148+
"source": {
149+
"type": "repo",
150+
"location": OpenServiceMesh.CHART_LOCATION
151+
}
152+
})
153+
except VersionError:
154+
raise InvalidArgumentValueError(
155+
"Invalid version '{}' for microsoft.openservicemesh".format(chart_version)
156+
)
157+
158+
values = chart_arc.get_values()
159+
values_yaml = yaml.load(values.raw, Loader=yaml.FullLoader)
160+
161+
try:
162+
return values_yaml['OpenServiceMesh']['testedDistros']
163+
except KeyError:
164+
return None

src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ def Create(self, cmd, client, resource_group_name: str, cluster_name: str, name:
2121
def Update(self, extension: ExtensionInstance, auto_upgrade_minor_version: bool,
2222
release_train: str, version: str) -> ExtensionInstanceUpdate:
2323
pass
24+
25+
@abstractmethod
26+
def Delete(self, client, resource_group_name: str, cluster_name: str, name: str, cluster_type: str):
27+
pass

0 commit comments

Comments
 (0)