Skip to content

Commit

Permalink
Helmupdatefix (#5)
Browse files Browse the repository at this point in the history
* Use userValues.txt instead of --resuse-values in update command

* fix error msg

* fix output file

Co-authored-by: Siri Teja Reddy Kasireddy <[email protected]>
  • Loading branch information
sirireddy12 and sikasire authored Feb 15, 2022
1 parent df27b20 commit 33669c1
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/connectedk8s/azext_connectedk8s/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,17 +884,17 @@ def update_agents(cmd, client, resource_group_name, cluster_name, https_proxy=""
cmd_helm_values.extend(["--kubeconfig", kube_config])
if kube_context:
cmd_helm_values.extend(["--kube-context", kube_context])
cmd_helm_values.extend([">", "userValues.txt"])

response_helm_values_get = Popen(cmd_helm_values, stdout=PIPE, stderr=PIPE)

existing_user_values = open('userValues.txt', '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,
"-f",
"userValues.txt", "--wait", "--output", "json"]
Expand Down Expand Up @@ -926,8 +926,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(existing_user_values.name)
except OSError:
pass
raise CLIInternalError(str.format(consts.Update_Agent_Failure, error_helm_upgrade.decode("ascii")))

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


Expand Down

0 comments on commit 33669c1

Please sign in to comment.