Skip to content

Commit

Permalink
Track onboarding sources using correlation_id parameter (#5008)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirireddy12 authored Jun 21, 2022
1 parent fdb1a56 commit ea925ec
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/connectedk8s/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Release History
===============
1.2.9
++++++

* Add correlation-id parameter to internally track onboarding sources

1.2.8
++++++

Expand Down
2 changes: 2 additions & 0 deletions src/connectedk8s/azext_connectedk8s/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
PublicCloud_OriginalName = 'AZURECLOUD'
USGovCloud_OriginalName = 'AZUREUSGOVERNMENT'
Dogfood_RMEndpoint = 'https://api-dogfood.resources.windows-int.net/'
Client_Request_Id_Header = 'x-ms-client-request-id'
Default_Onboarding_Source_Tracking_Guid = "77ade16b-0f55-403b-b7d2-739554a897f2"
Helm_Environment_File_Fault_Type = 'helm-environment-file-error'
Invalid_Location_Fault_Type = 'location-validation-error'
Load_Kubeconfig_Fault_Type = 'kubeconfig-load-error'
Expand Down
2 changes: 2 additions & 0 deletions src/connectedk8s/azext_connectedk8s/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# pylint: disable=line-too-long

import os.path
from ._validators import override_client_request_id_header
from argcomplete.completers import FilesCompleter
from azure.cli.core.commands.parameters import get_location_type, get_enum_type, file_type, tags_type
from azure.cli.core.commands.validators import get_default_location_from_resource_group
Expand Down Expand Up @@ -36,6 +37,7 @@ def load_arguments(self, _):
c.argument('cl_oid', options_list=['--custom-locations-oid'], help="OID of 'custom-locations' app")
c.argument('onboarding_timeout', options_list=['--onboarding-timeout'], arg_group='Timeout', help='Time required (in seconds) for the arc-agent pods to be installed on the kubernetes cluster. Override this value if the hardware/network constraints on your cluster requires more time for installing the arc-agent pods.')
c.argument('no_wait', options_list=['--no-wait'], arg_group='Timeout', help="Do not wait for the long-running operation to finish.")
c.argument('correlation_id', options_list=['--correlation-id'], help='A guid that is used to internally track the source of cluster onboarding. Please do not modify it unless advised', validator=override_client_request_id_header)

with self.argument_context('connectedk8s update') as c:
c.argument('cluster_name', options_list=['--name', '-n'], id_part='name', help='The name of the connected cluster.')
Expand Down
8 changes: 8 additions & 0 deletions src/connectedk8s/azext_connectedk8s/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
import azext_connectedk8s._constants as consts


def example_name_or_id_validator(cmd, namespace):
Expand All @@ -17,3 +18,10 @@ def example_name_or_id_validator(cmd, namespace):
type='storageAccounts',
name=namespace.storage_account
)


def override_client_request_id_header(cmd, namespace):
if namespace.correlation_id is not None:
cmd.cli_ctx.data['headers'][consts.Client_Request_Id_Header] = namespace.correlation_id
else:
cmd.cli_ctx.data['headers'][consts.Client_Request_Id_Header] = consts.Default_Onboarding_Source_Tracking_Guid
2 changes: 1 addition & 1 deletion src/connectedk8s/azext_connectedk8s/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
# pylint: disable=line-too-long


def create_connectedk8s(cmd, client, resource_group_name, cluster_name, https_proxy="", http_proxy="", no_proxy="", proxy_cert="", location=None,
def create_connectedk8s(cmd, client, resource_group_name, cluster_name, correlation_id=None, https_proxy="", http_proxy="", no_proxy="", proxy_cert="", location=None,
kube_config=None, kube_context=None, no_wait=False, tags=None, distribution='auto', infrastructure='auto',
disable_auto_upgrade=False, cl_oid=None, onboarding_timeout="600"):
logger.warning("This operation might take a while...\n")
Expand Down
2 changes: 1 addition & 1 deletion src/connectedk8s/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.

VERSION = '1.2.8'
VERSION = '1.2.9'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down

0 comments on commit ea925ec

Please sign in to comment.