This is an automated email from the ASF dual-hosted git repository.

dstandish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 70f868e867 Print stderr from helm test failures (#39698)
70f868e867 is described below

commit 70f868e86704ac7810762df97190aa2575fea7d2
Author: Daniel Standish <[email protected]>
AuthorDate: Sat May 18 08:54:14 2024 -0700

    Print stderr from helm test failures (#39698)
    
    Previously you would not see the error message; you'd only see that the 
command failed.  Now you'll see it.
---
 tests/charts/helm_template_generator.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tests/charts/helm_template_generator.py 
b/tests/charts/helm_template_generator.py
index 2cdcce72ce..d3a8ed954b 100644
--- a/tests/charts/helm_template_generator.py
+++ b/tests/charts/helm_template_generator.py
@@ -102,6 +102,11 @@ def validate_k8s_object(instance, kubernetes_version):
     validate.validate(instance)
 
 
+class HelmFailedError(subprocess.CalledProcessError):
+    def __str__(self):
+        return f"Helm command failed. Args: {self.args}\nStderr: 
\n{self.stderr.decode('utf-8')}"
+
+
 def render_chart(
     name="release-name",
     values=None,
@@ -135,7 +140,10 @@ def render_chart(
         if show_only:
             for i in show_only:
                 command.extend(["--show-only", i])
-        templates = subprocess.check_output(command, stderr=subprocess.PIPE, 
cwd=chart_dir)
+        result = subprocess.run(command, capture_output=True, cwd=chart_dir)
+        if result.returncode:
+            raise HelmFailedError(result.returncode, result.args, 
result.stdout, result.stderr)
+        templates = result.stdout
         k8s_objects = yaml.full_load_all(templates)
         k8s_objects = [k8s_object for k8s_object in k8s_objects if k8s_object] 
 # type: ignore
         for k8s_object in k8s_objects:

Reply via email to