Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
581cb60
[Breadth Coverage] Onboard Import Export (#1515)
arrownj Apr 22, 2020
54e0ed2
[Monitor]App byos and link la (#1499)
mmyyrroonn Apr 22, 2020
850f6aa
[Release] Update index.json for extension [ application-insights ] (#…
Apr 22, 2020
56a867c
[Release] Update index.json for extension [ support ] (#1569)
Apr 22, 2020
e99c137
[Release] Update index.json for extension [ import-export ] (#1574)
Apr 23, 2020
5b84f75
[HanaOnAzure] Updated HanaOnAzure CLI extension to include SapMonitor…
PakDLiu Apr 23, 2020
8877ae4
[Import Export] add __init__.py for generated package (#1582)
arrownj Apr 23, 2020
81d264d
[Release] Update index.json for extension [ import-export ] (#1583)
Apr 23, 2020
3d97c71
downgrade the version since the service is not ready (#1580)
mmyyrroonn Apr 23, 2020
3360eca
[Breadth Coverage] Datashare (#1476)
fengzhou-msft Apr 23, 2020
73dfe9e
[Release] Update index.json for extension [ datashare ] (#1586)
Apr 23, 2020
5cfc900
[Breadth Coverage] Portal (#1428)
Apr 23, 2020
85c8cbf
Change portal README file from rst to markdown (#1589)
Apr 23, 2020
4c707a0
[Breadth Coverage] logic apps (#1423)
bquantump Apr 24, 2020
5e3d07c
[Release] Update index.json for extension [ image-copy ] (#1568)
Apr 24, 2020
69c7333
Fix a small error in commands.py and update test sample file (#1595)
Apr 25, 2020
12e0bd9
[Release] Update index.json for extension [ portal ] (#1599)
Apr 25, 2020
246ec8e
[Release] Update index.json for extension [ logic ] (#1594)
Apr 25, 2020
f40506c
Fixed bug when hyperV version variable is None (#1553)
swbae31 Apr 26, 2020
285a0b5
[Release] Update index.json for extension [ vm-repair ] (#1601)
Apr 27, 2020
d597d8e
[Portal] Add portal generated module init file (#1609)
Apr 27, 2020
9528c6a
[Release] Update index.json for extension [ portal ] (#1610)
Apr 27, 2020
35b244f
{Monitor} refactor the logic (#1596)
mmyyrroonn Apr 27, 2020
3ede273
Update azure-cli-ml version to 1.4.0 (#1615)
j-so Apr 27, 2020
2fc19bd
[Release] Update index.json for extension [ application-insights ] (#…
Apr 28, 2020
14799ae
[Breadth Coverage] Log Analytics Solution (#1545)
zhoxing-ms Apr 29, 2020
e6c21fd
[Release] Update index.json for extension [ log-analytics-solution ] …
Apr 29, 2020
6827793
[Breadth Coverage] Time Series Insights (#1539)
Apr 29, 2020
71449ed
[Release] Update index.json for extension [ timeseriesinsights ] (#1623)
Apr 29, 2020
0f9aa58
Revert "spring-cloud: add support to enable/disable MSI (#1523)" (#1622)
leonard520 Apr 30, 2020
51f8b5d
[CI] Add wheel preinstallation for job IndexRefDocVerify and fix azur…
Apr 30, 2020
1ce82b0
[CI] Remove wheel usage (#1628)
Apr 30, 2020
13404e3
[storage-ors-preview] Support ORS policy for storage account (#1461)
Juliehzl May 1, 2020
d6aad6c
Adding updated Kusto extension (#1605)
astauben May 1, 2020
78df589
[Release] Update index.json for extension [ kusto ] (#1633)
May 1, 2020
2d844dd
[AKS] fix incorrect usage of ARM without going through the multi-api …
marwanad May 4, 2020
f178285
cli extension for connected kubernetes RP (#1570)
akashkeshari May 5, 2020
1884169
[Release] Update index.json for extension [ aks-preview ] (#1637)
May 5, 2020
2fb2d14
[Release] Update index.json for extension [ storage-ors-preview ] (#1…
May 6, 2020
1eb927c
[AKS] Unblock agentpool min count range check (#1606)
marwanad May 6, 2020
880774b
Fix the persicope version to always point to latest tag. (#1630)
Tatsinnit May 6, 2020
0b1ac90
[IoT] CLI extension release v0.9.2 (#1542)
digimaun May 6, 2020
14ec628
[storage-ors-preview] fix no azext metadata (#1648)
May 6, 2020
5926f06
[Release] Update index.json for extension [ storage-ors-preview ] (#1…
May 6, 2020
3fa9b10
added telemetry code for connect cli
May 6, 2020
5cbe47c
update help context (#1634)
zqingqing1 May 7, 2020
e489082
WIP {KubernetesConfiguration} Add extension CLI (#1550)
NarayanThiru May 7, 2020
9d60981
[storage-or-policy] rename the extension (#1662)
Juliehzl May 8, 2020
fca378c
{CI} temporary disable CredScan since ADO bug (#1666)
May 8, 2020
3d46998
[Release] Update index.json for extension [ storage-or-preview ] (#1665)
May 8, 2020
cf586cc
spring cloud - custom domain - cli (#1419)
1openwindow May 8, 2020
b0872b7
[Release] Update index.json for extension [ spring-cloud ] (#1669)
May 8, 2020
9f022a0
[Release] Update index.json for extension [ k8sconfiguration ] (#1659)
May 8, 2020
df2ecf4
[Release] Update index.json for extension [ connectedk8s ] (#1644)
May 8, 2020
f928d72
Fix extension name in readme (#1672)
ilidemi May 8, 2020
bffd137
[Breadth Coverage] Onboard Custom Providers Commands (#1627)
jsntcy May 9, 2020
5db8ce5
[Release] Update index.json for extension [ custom-providers ] (#1674)
May 9, 2020
01d4407
[TimeSeriesInsights] Fix timeSeriesIdPropertyName is not parsed prope…
May 9, 2020
5cf8340
[Release] Update index.json for extension [ timeseriesinsights ] (#1676)
May 11, 2020
94df344
update azure-cli-ml version to 1.2.0 (#1682)
j-so May 12, 2020
5c56299
Added exception telemetry for delete operation
May 12, 2020
4ddea41
Updated fork master with latest master
May 12, 2020
47fc01b
Updated with latest master
May 12, 2020
9239f83
Updated setup.py
May 12, 2020
ccdbff0
Changed default kubernetes distro
May 12, 2020
e6333d7
Distro detect.
pasankav May 12, 2020
1ef6cdd
Updated history
May 13, 2020
c1612c2
removed arm resourceid from telemetry
May 13, 2020
db1f4bd
Kubernetes connect cli telemetry integration (#1684)
akashkeshari May 13, 2020
5ed8f5d
bump vmware to 0.6.0 (#1656)
cataggar May 13, 2020
9943139
download from az-csvmware-cli (#1681)
cataggar May 13, 2020
feb1883
[Release] Update index.json for extension [ connectedk8s ] (#1689)
May 14, 2020
fb40791
AKS: add aks-custom-headers for nodepool and update (#1686)
andyzhangx May 14, 2020
3ed99da
Merge branch 'akash/connect_telemetry' into pavan/distro_detect
pasankav May 14, 2020
8a92c0c
[Release] Update index.json for extension [ aks-preview ] (#1699)
May 14, 2020
8b26810
Add kubernetes distro and identifying it.
pasankav May 14, 2020
df6806d
K8s configuration update min cli core version (#1697)
NarayanThiru May 14, 2020
87cbfa1
Add "Did You Mean This" Extension (#1692)
christopher-o-toole May 15, 2020
6bb06a7
[Release] Update index.json for extension [ k8sconfiguration ] (#1700)
May 15, 2020
fdacc2b
Remove additional line.
pasankav May 15, 2020
3860c00
correct indentation.
pasankav May 15, 2020
b9b4915
Merge branch 'master' into pavan/distro_detect
pasankav May 15, 2020
f8c4e04
correct indentation.
pasankav May 15, 2020
b752e92
correct version number.
pasankav May 15, 2020
9404057
Merge pull request #5 from akashkeshari/pavan/distro_detect
akashkeshari May 18, 2020
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
97 changes: 86 additions & 11 deletions src/connectedk8s/azext_connectedk8s/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.cli.core.util import sdk_no_wait
from azure.cli.core._profile import Profile
from azure.cli.core import telemetry
from azext_connectedk8s._client_factory import _graph_client_factory
from azext_connectedk8s._client_factory import cf_resource_groups
from azext_connectedk8s._client_factory import _resource_client_factory
Expand All @@ -42,9 +43,17 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
logger.warning("Ensure that you have the latest helm version installed before proceeding.")
logger.warning("This operation might take a while...\n")

#telemetry.add_extension_event('connectedk8s', {'testk': 'testval'})
#print(telemetry._session.events['c4395b75-49cc-422c-bc95-c7d51aef5d46'])
#return

@raunakpandya raunakpandya May 11, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: We need to update the version to 0.2.0 as part of this #Closed


# Setting subscription id
subscription_id = get_subscription_id(cmd.cli_ctx)

# Setting resource Id
resource_id = "/subscriptions/{}/resourceGroups/{}/providers/Microsoft.Kubernetes/connectedClusters/{}".format(subscription_id, resource_group_name, cluster_name)
telemetry.add_extension_event('connectedk8s', {'Context.Default.AzureCLI.ResourceId': resource_id})
Comment thread
akashkeshari marked this conversation as resolved.
Outdated

# Setting user profile
profile = Profile(cli_ctx=cmd.cli_ctx)

Expand All @@ -62,6 +71,9 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
try:
config.load_kube_config(config_file=kube_config, context=kube_context)
except Exception as e:
telemetry.set_user_fault()
telemetry.set_exception(exception=e, fault_type='kubeconfig-load-error',
summary='Problem loading the kubeconfig file')
raise CLIError("Problem loading the kubeconfig file." + str(e))
configuration = kube_client.Configuration()

Expand All @@ -70,11 +82,21 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
# if the user had not logged in.
check_kube_connection(configuration)

Comment thread
akashkeshari marked this conversation as resolved.
# Get kubernetes cluster info for telemetry
kubernetes_version = get_server_version(configuration)
kubernetes_distro = 'default'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do add distro flag to CLI, default value should be auto-detect.

kubernetes_properties = {
'Context.Default.AzureCLI.KubernetesVersion': kubernetes_version,
'Context.Default.AzureCLI.KubernetesDistro': kubernetes_distro
}
telemetry.add_extension_event('connectedk8s', kubernetes_properties)

# Checking helm installation
check_helm_install(kube_config, kube_context)

Comment thread
akashkeshari marked this conversation as resolved.
# Check helm version
check_helm_version(kube_config, kube_context)
helm_version = check_helm_version(kube_config, kube_context)
telemetry.add_extension_event('connectedk8s', {'Context.Default.AzureCLI.HelmVersion': helm_version})

# Validate location
rp_locations = []
Expand All @@ -84,6 +106,9 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
if resourceTypes.resource_type == 'connectedClusters':
rp_locations = [location.replace(" ", "").lower() for location in resourceTypes.locations]
if location.lower() not in rp_locations:
telemetry.set_user_fault()
telemetry.set_exception(exception='Location not supported', fault_type='location-validation-error',
summary='Provided location is not supported for creating connected clusters')
raise CLIError("Connected cluster resource creation is supported only in the following locations: " +

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default [](start = 25, length = 7)

Actually, the param can be auto-detect. For telemetry we should put what we detected. If we dont detect (like today) we should trace/ log default. Hence I think default as distro is better.

', '.join(map(str, rp_locations)) +
". Use the --location flag to specify one of these locations.")
Expand All @@ -97,6 +122,8 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
try:
configmap = api_instance.read_namespaced_config_map('azure-clusterconfig', 'azure-arc')
except Exception as e: # pylint: disable=broad-except
telemetry.set_exception(exception=e, fault_type='configmap-read-error',
summary='Unable to read ConfigMap')
raise CLIError("Unable to read ConfigMap 'azure-clusterconfig' in 'azure-arc' namespace: %s\n" % e)
configmap_rg_name = configmap.data["AZURE_RESOURCE_GROUP"]
configmap_cluster_name = configmap.data["AZURE_RESOURCE_NAME"]
Expand All @@ -113,6 +140,9 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
except CloudError as ex:
raise CLIError(ex)

@raunakpandya raunakpandya May 11, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLIError [](start = 26, length = 8)

What here? #Closed

else:
telemetry.set_user_fault()
telemetry.set_exception(exception='The kubernetes cluster is already onboarded', fault_type='cluster-already-onboarded-error',
summary='Kubernetes cluster already onboarded')
raise CLIError("The kubernetes cluster you are trying to onboard" +
"is already onboarded to the resource group" +
" '{}' with resource name '{}'.".format(configmap_rg_name, configmap_cluster_name))
Expand All @@ -121,6 +151,9 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
delete_arc_agents(release_namespace, kube_config, kube_context, configuration)
else:
if connected_cluster_exists(client, resource_group_name, cluster_name):
telemetry.set_user_fault()
telemetry.set_exception(exception='The connected cluster resource already exists', fault_type='resource-already-exists-error',

@raunakpandya raunakpandya May 11, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resource-already-exists-error [](start = 107, length = 29)

Can we define all of these as constants at a single place/ file and refer? #Closed

summary='Connected cluster resource already exists')
raise CLIError("The connected cluster resource {} already exists ".format(cluster_name) +
"in the resource group {} ".format(resource_group_name) +
"and corresponds to a different Kubernetes cluster. To onboard this Kubernetes cluster" +
Expand All @@ -132,6 +165,9 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
try:
resourceClient.resource_groups.create_or_update(resource_group_name, resource_group_params)
except Exception as e:
telemetry.set_user_fault()
telemetry.set_exception(exception=e, fault_type='resource-group-creation-error',

@raunakpandya raunakpandya May 11, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why do we think we should mark this as user fault? #Closed

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot think of a reason for changing our code if the resource group creation fails. It probably should be permission. But since it could also be connectivity issue, i also think we should not set user fault here

summary='Failed to create the resource group')
raise CLIError("Failed to create the resource group {} :".format(resource_group_name) + str(e))

# Adding helm repo
Expand All @@ -144,6 +180,8 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
response_helm_repo = Popen(cmd_helm_repo, stdout=PIPE, stderr=PIPE)
_, error_helm_repo = response_helm_repo.communicate()
if response_helm_repo.returncode != 0:
telemetry.set_exception(exception=error_helm_repo.decode("ascii"), fault_type='helm-repo-add-error',
summary='Failed to add helm repository')
raise CLIError("Unable to add repository {} to helm: ".format(repo_url) + error_helm_repo.decode("ascii"))

# Retrieving Helm chart OCI Artifact location
Expand All @@ -161,15 +199,21 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
try:
key_pair = RSA.generate(4096)
except Exception as e:
telemetry.set_exception(exception=e, fault_type='keypair-generation-error',
summary='Failed to generate public-private key pair')
raise CLIError("Failed to generate public-private key pair. " + str(e))
try:
public_key = get_public_key(key_pair)
except Exception as e:
raise CLIError("Failed to generate public key." + str(e))
telemetry.set_exception(exception=e, fault_type='publickey-export-error',
summary='Failed to export public key')
raise CLIError("Failed to export public key." + str(e))
try:
private_key_pem = get_private_key(key_pair)
except Exception as e:
raise CLIError("Failed to generate private key." + str(e))
telemetry.set_exception(exception=e, fault_type='privatekey-export-error',
summary='Failed to export private key')
raise CLIError("Failed to export private key." + str(e))

# Helm Install
helm_chart_path = os.path.join(chart_export_path, 'azure-arc-k8sagents')
Expand All @@ -188,8 +232,14 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
response_helm_install = Popen(cmd_helm_install, stdout=PIPE, stderr=PIPE)
_, error_helm_install = response_helm_install.communicate()
if response_helm_install.returncode != 0:
telemetry.set_exception(exception=error_helm_install.decode("ascii"), fault_type='helm-release-install-error',
summary='Unable to install helm release')
raise CLIError("Unable to install helm release: " + error_helm_install.decode("ascii"))

# Get azure-arc agent version for telemetry
azure_arc_agent_version = get_agent_version(configuration)
telemetry.add_extension_event('connectedk8s', {'Context.Default.AzureCLI.AgentVersion': azure_arc_agent_version})

@raunakpandya raunakpandya May 11, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we capture this before helm install based on what is the chart we got? #Closed


# Create connected cluster resource
cc = generate_request_payload(configuration, location, public_key, tags)
try:
Expand All @@ -199,6 +249,8 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
if no_wait:
return put_cc_response
except CloudError as ex:
telemetry.set_exception(exception=ex, fault_type='connected-cluster-create-error',
summary='Unable to create connected cluster resource')
raise CLIError(ex)

# Getting total number of pods scheduled to run in azure-arc namespace
Expand All @@ -209,6 +261,8 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, location
try:
check_pod_status(pod_dict)
except Exception as e: # pylint: disable=broad-except
telemetry.set_exception(exception=e, fault_type='check-pod-status-error',
summary='Failed to check arc agent pods statuses')
logger.warning("Failed to check arc agent pods statuses: %s", e)

return put_cc_response
Expand All @@ -234,6 +288,9 @@ def check_kube_connection(configuration):
try:
api_instance.get_api_resources()
except Exception as e:
telemetry.set_user_fault()
telemetry.set_exception(exception=e, fault_type='kubernetes-cluster-connection-error',
summary='Unable to verify connectivity to the Kubernetes cluster')
logger.warning("Unable to verify connectivity to the Kubernetes cluster: %s\n", e)
raise CLIError("If you are using AAD Enabled cluster, " +
"verify that you are able to access the cluster. Learn more at " +
Expand All @@ -249,8 +306,14 @@ def check_helm_install(kube_config, kube_context):
_, error_helm_installed = response_helm_installed.communicate()
if response_helm_installed.returncode != 0:
if "unknown flag" in error_helm_installed.decode("ascii"):
telemetry.set_user_fault()
telemetry.set_exception(exception='Helm 3 not found', fault_type='helm-not-updated-error',
summary='Helm3 not found on the machine')
raise CLIError("Please install the latest version of Helm. " +
"Learn more at https://aka.ms/arc/k8s/onboarding-helm-install")
telemetry.set_user_fault()
telemetry.set_exception(exception=error_helm_installed.decode("ascii"), fault_type='helm-not-installed-error',
summary='Helm3 not installed on the machine')
raise CLIError(error_helm_installed.decode("ascii"))
except FileNotFoundError:
raise CLIError("Helm is not installed or requires elevated permissions. " +
Expand All @@ -268,11 +331,17 @@ def check_helm_version(kube_config, kube_context):
response_helm_version = Popen(cmd_helm_version, stdout=PIPE, stderr=PIPE)
output_helm_version, error_helm_version = response_helm_version.communicate()
if response_helm_version.returncode != 0:
telemetry.set_exception(exception=error_helm_version.decode('ascii'), fault_type='helm-version-check-error',
summary='Unable to determine helm version')
raise CLIError("Unable to determine helm version: " + error_helm_version.decode("ascii"))
if "v2" in output_helm_version.decode("ascii"):
telemetry.set_user_fault()
telemetry.set_exception(exception='Helm 3 not found', fault_type='helm-not-updated-error',
summary='Helm3 not found on the machine')
raise CLIError("Helm version 3+ is required. " +
"Ensure that you have installed the latest version of Helm. " +
"Learn more at https://aka.ms/arc/k8s/onboarding-helm-install")
return output_helm_version.decode('ascii')


def resource_group_exists(ctx, resource_group_name, subscription_id=None):
Expand Down Expand Up @@ -307,9 +376,13 @@ def get_helm_registery(profile, location):
try:
response = requests.post(get_chart_location_url, params=query_parameters, headers=header_parameters)
Comment thread
akashkeshari marked this conversation as resolved.
except Exception as e:
telemetry.set_exception(exception=e, fault_type='helm-registery-path-fetch-error',
summary='Error while fetching helm chart registery path')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: registry spelling

raise CLIError("Error while fetching helm chart registery path: " + str(e))
if response.status_code == 200:
return response.json().get('repositoryPath')
telemetry.set_exception(exception=str(response.json()), fault_type='helm-registery-path-fetch-error',
summary='Error while fetching helm chart registery path')
raise CLIError("Error while fetching helm chart registery path: {}".format(str(response.json())))


Expand All @@ -320,6 +393,8 @@ def pull_helm_chart(registery_path, kube_config, kube_context):
response_helm_chart_pull = subprocess.Popen(cmd_helm_chart_pull, stdout=PIPE, stderr=PIPE)
_, error_helm_chart_pull = response_helm_chart_pull.communicate()
if response_helm_chart_pull.returncode != 0:
telemetry.set_exception(exception=error_helm_chart_pull.decode("ascii"), fault_type='helm-chart-pull-error',
summary='Unable to pull helm chart from the registery')
raise CLIError("Unable to pull helm chart from the registery '{}': ".format(registery_path) + error_helm_chart_pull.decode("ascii"))


Expand All @@ -331,6 +406,8 @@ def export_helm_chart(registery_path, chart_export_path, kube_config, kube_conte
response_helm_chart_export = subprocess.Popen(cmd_helm_chart_export, stdout=PIPE, stderr=PIPE)
_, error_helm_chart_export = response_helm_chart_export.communicate()
if response_helm_chart_export.returncode != 0:
telemetry.set_exception(exception=error_helm_chart_export.decode("ascii"), fault_type='helm-chart-export-error',
summary='Unable to export helm chart from the registery')

@raunakpandya raunakpandya May 11, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registery [](start = 78, length = 9)

Nit: Typo in registry #Closed

raise CLIError("Unable to export helm chart from the registery '{}': ".format(registery_path) + error_helm_chart_export.decode("ascii"))


Expand All @@ -352,6 +429,8 @@ def get_node_count(configuration):
api_response = api_instance.list_node()
return len(api_response.items)
except Exception as e: # pylint: disable=broad-except
telemetry.set_exception(exception=e, fault_type='kubernetes-get-nodes-error',
summary='Exception while fetching nodes')
logger.warning("Exception while fetching nodes: %s\n", e)

@raunakpandya raunakpandya May 11, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused method #Closed



Expand All @@ -361,6 +440,8 @@ def get_server_version(configuration):
api_response = api_instance.get_code()
return api_response.git_version
except Exception as e: # pylint: disable=broad-except
telemetry.set_exception(exception=e, fault_type='kubernetes-get-version-error',
summary='Unable to fetch kubernetes version')
logger.warning("Unable to fetch kubernetes version: %s\n", e)


Expand All @@ -370,15 +451,12 @@ def get_agent_version(configuration):
api_response = api_instance.read_namespaced_config_map('azure-clusterconfig', 'azure-arc')
return api_response.data["AZURE_ARC_AGENT_VERSION"]
except Exception as e: # pylint: disable=broad-except
telemetry.set_exception(exception=e, fault_type='get-agent-version-error',
summary='Unable to fetch agent version')
logger.warning("Unable to read ConfigMap 'azure-clusterconfig' in 'azure-arc' namespace: %s\n", e)


def generate_request_payload(configuration, location, public_key, tags):
# Fetch cluster info
total_node_count = get_node_count(configuration)
kubernetes_version = get_server_version(configuration)
azure_arc_agent_version = get_agent_version(configuration)

# Create connected cluster resource object
aad_profile = ConnectedClusterAADProfile(
tenant_id="",
Expand All @@ -395,9 +473,6 @@ def generate_request_payload(configuration, location, public_key, tags):
identity=identity,
agent_public_key_certificate=public_key,
aad_profile=aad_profile,
kubernetes_version=kubernetes_version,
total_node_count=total_node_count,
agent_version=azure_arc_agent_version,
tags=tags
)
return cc
Expand Down