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

Customcert and fix for non escaping values in helm #4428

Merged
merged 35 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4b7aadf
Use userValues.txt instead of --resuse-values in update command
sikasire Feb 11, 2022
e8297ad
fix error msg
sikasire Feb 11, 2022
64531ce
added custom cert
Anumita Sep 29, 2021
75101fd
change setup.py
Anumita Nov 11, 2021
df27b20
Helmupdatefix (#4)
Anumita Feb 15, 2022
02014ea
fix output file
sikasire Feb 15, 2022
55283c9
Merge branch 'customcert' of https://github.com/Anumita/azure-cli-ext…
sikasire Feb 15, 2022
33669c1
Helmupdatefix (#5)
sirireddy12 Feb 15, 2022
159e3bb
place values file in .azure folder
sikasire Feb 16, 2022
c18d3df
place values file in .azure folder
sikasire Feb 16, 2022
bc79fea
Merge branch 'customcert' into helmupdatefix
sirireddy12 Feb 16, 2022
58a545a
Helmupdatefix (#6)
sirireddy12 Feb 16, 2022
84c1148
place values file in .azure folder
sikasire Feb 16, 2022
f96aad8
Merge branch 'helmupdatefix' of https://github.com/sirireddy12/azure-…
sikasire Feb 16, 2022
b8b5d00
Merge branch 'customcert' into helmupdatefix
sirireddy12 Feb 16, 2022
f44f00d
Merge pull request #7 from sirireddy12/helmupdatefix
sirireddy12 Feb 16, 2022
ddf86c8
nit
sikasire Feb 16, 2022
95f2f5a
Merge branch 'helmupdatefix' of https://github.com/sirireddy12/azure-…
sikasire Feb 16, 2022
3e42bb3
Merge pull request #8 from sirireddy12/helmupdatefix
sirireddy12 Feb 16, 2022
e0d6b31
nit
sikasire Feb 16, 2022
b5b2730
Merge pull request #9 from sirireddy12/helmupdatefix
sirireddy12 Feb 16, 2022
dc6cabf
nit
sikasire Feb 16, 2022
6a527f4
Merge pull request #10 from sirireddy12/helmupdatefix
sirireddy12 Feb 16, 2022
670ace0
setp.py and history.rst updates
sikasire Feb 16, 2022
b740402
Merge pull request #11 from sirireddy12/helmupdatefix
sirireddy12 Feb 16, 2022
86783a9
modify the way of fetching userValues.txt path
sikasire Feb 21, 2022
02b176f
Merge pull request #12 from sirireddy12/helmupdatefix
sirireddy12 Feb 21, 2022
d3500d2
Waiting for LRO to complete before moving ahead with agent installati…
sikasire Feb 21, 2022
08d489e
Merge pull request #13 from sirireddy12/helmupdatefix
sirireddy12 Feb 21, 2022
2252380
update history.rst
sikasire Feb 21, 2022
3824c2c
Merge pull request #14 from sirireddy12/helmupdatefix
sirireddy12 Feb 21, 2022
82989ab
fix
sikasire Feb 21, 2022
cc6006f
Merge pull request #15 from sirireddy12/helmupdatefix
sirireddy12 Feb 21, 2022
a1f6a96
fix location variable
sikasire Feb 21, 2022
b4f43c4
Merge pull request #16 from sirireddy12/helmupdatefix
sirireddy12 Feb 21, 2022
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
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.4
++++++

* Custom cert changes, using "userValues.txt" for existing values in update command instead of --reuse-values

1.2.3
++++++

Expand Down
2 changes: 1 addition & 1 deletion src/connectedk8s/azext_connectedk8s/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def load_arguments(self, _):
c.argument('https_proxy', options_list=['--proxy-https'], arg_group='Proxy', help='Https proxy URL to be used.')
c.argument('http_proxy', options_list=['--proxy-http'], arg_group='Proxy', help='Http proxy URL to be used.')
c.argument('no_proxy', options_list=['--proxy-skip-range'], arg_group='Proxy', help='List of URLs/CIDRs for which proxy should not to be used.')
c.argument('proxy_cert', options_list=['--proxy-cert'], arg_group='Proxy', type=file_type, completer=FilesCompleter(), help='Path to the certificate file for proxy')
c.argument('proxy_cert', options_list=['--proxy-cert'], arg_group='Proxy', type=file_type, completer=FilesCompleter(), help='Path to the any additional certificate file (for proxy as well)')
c.argument('disable_proxy', options_list=['--disable-proxy'], arg_group='Proxy', action='store_true', help='Disables proxy settings for agents')
c.argument('auto_upgrade', options_list=['--auto-upgrade'], help='Flag to enable/disable auto upgrade of arc agents. By default, auto upgrade of agents is enabled.', arg_type=get_enum_type(["true", "false"]))

Expand Down
1 change: 1 addition & 0 deletions src/connectedk8s/azext_connectedk8s/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ def helm_install_release(chart_path, subscription_id, kubernetes_distro, kuberne
cmd_helm_install.extend(["--set", "global.noProxy={}".format(no_proxy)])
if proxy_cert:
cmd_helm_install.extend(["--set-file", "global.proxyCert={}".format(proxy_cert)])
cmd_helm_install.extend(["--set", "global.isCustomCert={}".format(True)])
if https_proxy or http_proxy or no_proxy:
cmd_helm_install.extend(["--set", "global.isProxyEnabled={}".format(True)])
if kube_config:
Expand Down
43 changes: 39 additions & 4 deletions src/connectedk8s/azext_connectedk8s/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,8 @@ def update_agents(cmd, client, resource_group_name, cluster_name, https_proxy=""

# Send cloud information to telemetry
send_cloud_telemetry(cmd)
# Fetch OS details
operating_system = platform.system()
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this reqd?

Copy link
Contributor

Choose a reason for hiding this comment

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

Removed it


# Setting kubeconfig
kube_config = set_kube_config(kube_config)
Expand All @@ -801,7 +803,7 @@ def update_agents(cmd, client, resource_group_name, cluster_name, https_proxy=""
if https_proxy == "" and http_proxy == "" and no_proxy == "" and proxy_cert == "" and not disable_proxy and not auto_upgrade:
raise RequiredArgumentMissingError(consts.No_Param_Error)

if (https_proxy or http_proxy or no_proxy or proxy_cert) and disable_proxy:
if (https_proxy or http_proxy or no_proxy) and disable_proxy:
raise MutuallyExclusiveArgumentError(consts.EnableProxy_Conflict_Error)

# Checking whether optional extra values file has been provided.
Expand Down Expand Up @@ -879,9 +881,34 @@ def update_agents(cmd, client, resource_group_name, cluster_name, https_proxy=""
# Get Helm chart path
chart_path = utils.get_chart_path(registry_path, kube_config, kube_context, helm_client_location)

cmd_helm_values = [helm_client_location, "get", "values", "azure-arc", "--namespace", release_namespace]
if kube_config:
cmd_helm_values.extend(["--kubeconfig", kube_config])
if kube_context:
cmd_helm_values.extend(["--kube-context", kube_context])

if(operating_system == 'Windows'):
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of doing this, use python apis which are generic for all OS

chart_export_path = os.path.join(os.path.expanduser('~'), '.azure', 'AzureArcCharts')

Copy link
Contributor

Choose a reason for hiding this comment

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

Done. Thanks

user_values_filepath_string = r'.azure\\userValues.txt'
elif(operating_system == 'Linux' or operating_system == 'Darwin'):
user_values_filepath_string = r'.azure/userValues.txt'
else:
telemetry.set_exception(exception='Unsupported OS', fault_type=consts.Unsupported_Fault_Type,
summary=f'{operating_system} is not supported yet')
raise ClientRequestError(f'The {operating_system} platform is not currently supported.')
user_values_location = os.path.expanduser(os.path.join('~', user_values_filepath_string))
existing_user_values = open(user_values_location, 'w+')
response_helm_values_get = Popen(cmd_helm_values, stdout=existing_user_values, stderr=PIPE)
_, error_helm_get_values = response_helm_values_get.communicate()
if response_helm_values_get.returncode != 0:
if ('forbidden' in error_helm_get_values.decode("ascii") or 'timed out waiting for the condition' in error_helm_get_values.decode("ascii")):
telemetry.set_user_fault()
telemetry.set_exception(exception=error_helm_get_values.decode("ascii"), fault_type=consts.Get_Helm_Values_Failed,
summary='Error while doing helm get values azure-arc')
raise CLIInternalError(str.format(consts.Update_Agent_Failure, error_helm_get_values.decode("ascii")))

cmd_helm_upgrade = [helm_client_location, "upgrade", "azure-arc", chart_path, "--namespace", release_namespace,
"--reuse-values",
"--wait", "--output", "json"]
"-f",
user_values_location, "--wait", "--output", "json"]
if values_file_provided:
cmd_helm_upgrade.extend(["-f", values_file])
if auto_upgrade is not None:
Expand All @@ -898,6 +925,7 @@ def update_agents(cmd, client, resource_group_name, cluster_name, https_proxy=""
cmd_helm_upgrade.extend(["--set", "global.isProxyEnabled={}".format(False)])
if proxy_cert:
cmd_helm_upgrade.extend(["--set-file", "global.proxyCert={}".format(proxy_cert)])
cmd_helm_upgrade.extend(["--set", "global.isCustomCert={}".format(True)])
if kube_config:
cmd_helm_upgrade.extend(["--kubeconfig", kube_config])
if kube_context:
Expand All @@ -909,8 +937,15 @@ def update_agents(cmd, client, resource_group_name, cluster_name, https_proxy=""
telemetry.set_user_fault()
telemetry.set_exception(exception=error_helm_upgrade.decode("ascii"), fault_type=consts.Install_HelmRelease_Fault_Type,
summary='Unable to install helm release')
try:
os.remove(user_values_location)
except OSError:
pass
raise CLIInternalError(str.format(consts.Update_Agent_Failure, error_helm_upgrade.decode("ascii")))

try:
os.remove(user_values_location)
except OSError:
pass
return str.format(consts.Update_Agent_Success, connected_cluster.name)


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.3'
VERSION = '1.2.4'

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