From 33669c1ef301722fefaeaf3e68d6081f16c4e4d5 Mon Sep 17 00:00:00 2001 From: siriteja <32883500+sirireddy12@users.noreply.github.com> Date: Tue, 15 Feb 2022 21:48:43 +0530 Subject: [PATCH] Helmupdatefix (#5) * Use userValues.txt instead of --resuse-values in update command * fix error msg * fix output file Co-authored-by: Siri Teja Reddy Kasireddy --- src/connectedk8s/azext_connectedk8s/custom.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/connectedk8s/azext_connectedk8s/custom.py b/src/connectedk8s/azext_connectedk8s/custom.py index 368a617c2aa..71882ffa7af 100644 --- a/src/connectedk8s/azext_connectedk8s/custom.py +++ b/src/connectedk8s/azext_connectedk8s/custom.py @@ -884,9 +884,9 @@ 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")): @@ -894,7 +894,7 @@ def update_agents(cmd, client, resource_group_name, cluster_name, https_proxy="" 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"] @@ -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)