Skip to content

Commit 4f2dd51

Browse files
authored
Add support for Python 3.8, 3.9 (#61)
* update a bunch of libraries * more cleanup and removing now useless lib * update plugin.json
1 parent a11d06e commit 4f2dd51

22 files changed

Lines changed: 50 additions & 525 deletions

File tree

Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## Version 2.2.0 - Feature release
4+
5+
- Add more supported Python versions. This plugin can now use 2.7 (deprecated), 3.6, 3.7, 3.8, 3.9
6+
- Fix vnet auto-attach managed identity when let AKS provision the control plane identity
7+
38
## Version 2.1.0 - Feature release
49

510
- Support GPU out-of-the-box

code-env/python/desc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"acceptedPythonInterpreters": ["PYTHON27","PYTHON36","PYTHON37"],
2+
"acceptedPythonInterpreters": ["PYTHON27","PYTHON36","PYTHON37","PYTHON38","PYTHON39"],
33
"forceConda": false,
44
"installCorePackages": true,
5-
"installJupyterSupport": false
5+
"installJupyterSupport": false,
6+
"corePackagesSet": "AUTO"
67
}

code-env/python/spec/Pipfile

Lines changed: 0 additions & 20 deletions
This file was deleted.

code-env/python/spec/Pipfile.lock

Lines changed: 0 additions & 359 deletions
This file was deleted.
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
azure-common==1.1.27
2-
azure-identity==1.6.0
3-
azure-mgmt-authorization==1.0.0
4-
azure-mgmt-compute==21.0.0
5-
azure-mgmt-containerregistry==8.0.0
6-
azure-mgmt-containerservice==16.0.0
7-
azure-mgmt-core==1.2.2
8-
azure-mgmt-resource==18.0.0
9-
azure-mgmt-msi==1.0.0
1+
azure-identity==1.7.1
2+
azure-mgmt-authorization==2.0.0
3+
azure-mgmt-compute==23.1.0
4+
azure-mgmt-containerservice==16.4.0
5+
azure-mgmt-resource==20.0.0
6+
azure-mgmt-msi==6.0.0b1
107
ipaddress==1.0.23
11-
msrest==0.6.21
128
pyyaml==5.4.1
139
uuid==1.30

code-env/python/spec/requirements_spec.txt

Lines changed: 0 additions & 33 deletions
This file was deleted.

parameter-sets/cluster-identity/parameter-set.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"label": "Kubelet user identity",
7575
"type": "STRING",
7676
"mandatory" : false,
77-
"description": "User Assigned Managed Identity for the kubelets. Only available with Azure feature Microsoft.ContainerService/CustomKubeletIdentityPreview. See documentation.",
77+
"description": "User Assigned Managed Identity for the kubelets.",
7878
"visibilityCondition": "model.identityType=='managed-identity' && !model.useAKSManagedKubeletIdentity && !model.inheritDSSIdentity"
7979
},
8080
{

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "aks-clusters",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"meta": {
55
"label": "AKS clusters",
66
"description": "Interact with or create Microsoft Azure Kubernetes Service clusters",

python-clusters/attach-aks-cluster/cluster.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import os, json, logging, yaml
1+
import os, logging, yaml
22
from dataiku.cluster import Cluster
33

44
from azure.mgmt.containerservice import ContainerServiceClient
55
from dku_utils.access import _is_none_or_blank
6-
from dku_utils.cluster import make_overrides, get_subscription_id
6+
from dku_utils.cluster import make_overrides
77
from dku_azure.auth import get_credentials_from_connection_info, get_credentials_from_connection_infoV2
8-
from dku_azure.utils import run_and_process_cloud_error
98
from dku_azure.utils import run_and_process_cloud_error, get_instance_metadata, get_subscription_id
109

1110
class MyCluster(Cluster):

python-clusters/create-aks-cluster/cluster.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os, json, logging, yaml, time, uuid
1+
import os, logging, yaml, time, uuid
22
from dataiku.cluster import Cluster
33

44
from azure.mgmt.containerservice import ContainerServiceClient
@@ -7,15 +7,13 @@
77
from azure.mgmt.authorization import AuthorizationManagementClient
88
from azure.core.pipeline.policies import UserAgentPolicy
99
from azure.core.exceptions import ResourceNotFoundError, HttpResponseError
10-
from msrestazure.azure_exceptions import CloudError
1110

12-
from dku_utils.access import _is_none_or_blank, _has_not_blank_property
13-
from dku_utils.cluster import make_overrides, get_cluster_from_connection_info
11+
from dku_utils.access import _is_none_or_blank
12+
from dku_utils.cluster import make_overrides
1413
from dku_kube.nvidia_utils import add_gpu_driver_if_needed
1514
from dku_azure.auth import get_credentials_from_connection_info, get_credentials_from_connection_infoV2
1615
from dku_azure.clusters import ClusterBuilder
17-
from dku_azure.utils import run_and_process_cloud_error, get_subnet_id, get_instance_metadata, get_subscription_id
18-
from dku_azure.auth import AzureIdentityCredentialAdapter
16+
from dku_azure.utils import run_and_process_cloud_error, get_instance_metadata, get_subscription_id
1917

2018
class MyCluster(Cluster):
2119
def __init__(self, cluster_id, cluster_name, config, plugin_config):
@@ -84,9 +82,7 @@ def start(self):
8482
existing = clusters_client.managed_clusters.get(resource_group, self.cluster_name)
8583
if existing is not None:
8684
raise Exception("A cluster with name %s in resource group %s already exists" % (self.cluster_name, resource_group))
87-
except CloudError as e:
88-
logging.info("Cluster doesn't seem to exist yet")
89-
except ResourceNotFoundError as e:
85+
except ResourceNotFoundError:
9086
logging.info("Cluster doesn't seem to exist yet")
9187

9288
cluster_builder = ClusterBuilder(clusters_client)
@@ -153,7 +149,7 @@ def start(self):
153149
if not cluster_identity.get("useAKSManagedKubeletIdentity",True):
154150
kubelet_mi = cluster_identity["kubeletUserAssignedIdentity"]
155151
_,_,mi_subscription_id,_,mi_resource_group,_,_,_,mi_name = kubelet_mi.split("/")
156-
msiclient = ManagedServiceIdentityClient(AzureIdentityCredentialAdapter(credentials), mi_subscription_id)
152+
msiclient = ManagedServiceIdentityClient(credentials, mi_subscription_id)
157153
mi = msiclient.user_assigned_identities.get(mi_resource_group, mi_name)
158154
cluster_builder.with_kubelet_identity(kubelet_mi, mi.client_id, mi.principal_id)
159155
logging.info("Configure kubelet identity with user assigned identity resourceId=\"{}\", clientId=\"{}\", objectId=\"{}\"".format(kubelet_mi, mi.client_id, mi.principal_id))
@@ -184,7 +180,7 @@ def start(self):
184180
acr_scope = "/subscriptions/{acr_subscription_id}/resourceGroups/{acr_resource_group}/providers/Microsoft.ContainerRegistry/registries/{acr_name}".format(**locals())
185181
try:
186182
acr_roles = list(authorization_client.role_definitions.list(acr_scope,"roleName eq 'AcrPull'"))
187-
except ResourceNotFoundError as e:
183+
except ResourceNotFoundError:
188184
raise Exception("ACR {} not found. Check it exists and you are Owner of it.".format(acr_scope))
189185
if 0 == len(acr_roles):
190186
raise Exception("Could not find the AcrPull role on the ACR {}. Check you are Owner of it.".format(acr_scope))
@@ -245,9 +241,9 @@ def start(self):
245241
authorization_client = AuthorizationManagementClient(credentials, subscription_id)
246242
try:
247243
vnet_roles = list(authorization_client.role_definitions.list(vnet_id,"roleName eq 'Contributor'"))
248-
except ResourceNotFoundError as e:
244+
except ResourceNotFoundError:
249245
raise Exception("Vnet {} not found. Check it exists and you are Owner of it.".format(vnet_id))
250-
if 0 == len(acr_roles):
246+
if 0 == len(vnet_roles):
251247
raise Exception("Could not find the Contributor role on the vnet {}. Check you are Owner of it.".format(vnet_id))
252248
else:
253249
vnet_role_id = vnet_roles[0].id
@@ -424,7 +420,7 @@ def stop(self, data):
424420
authorization_client = AuthorizationManagementClient(credentials, acr_attachment["subscription_id"])
425421
try:
426422
authorization_client.role_assignments.delete_by_id(acr_attachment["role_assignment"]["id"])
427-
except ResourceNotFoundError as e:
423+
except ResourceNotFoundError:
428424
logging.warn("It looks that the ACR role assignment doesnt exist. Ignore this step")
429425

430426
# Detach Vnet like ACR
@@ -436,13 +432,13 @@ def stop(self, data):
436432
authorization_client = AuthorizationManagementClient(credentials, vnet_attachment["subscription_id"])
437433
try:
438434
authorization_client.role_assignments.delete_by_id(vnet_attachment["role_assignment"]["id"])
439-
except ResourceNotFoundError as e:
435+
except ResourceNotFoundError:
440436
logging.warn("It looks that the Vnet role assignment doesnt exist. Ignore this step")
441437

442438
def do_delete():
443439
future = clusters_client.managed_clusters.begin_delete(resource_group, cluster_name)
444440
return future.result()
445-
delete_result = run_and_process_cloud_error(do_delete)
441+
run_and_process_cloud_error(do_delete)
446442

447443
# delete returns void, so we poll until the cluster is really gone
448444
gone = False
@@ -453,6 +449,6 @@ def do_delete():
453449
if cluster.provisioning_state.lower() != 'deleting':
454450
logging.info("Cluster is not deleting anymore, must be deleted now (state = %s)" % cluster.provisioning_state)
455451
# other exceptions should not be ignored
456-
except ResourceNotFoundError as e:
452+
except ResourceNotFoundError:
457453
logging.info("Cluster doesn't seem to exist anymore, considering it deleted")
458454
gone = True

0 commit comments

Comments
 (0)