jason810496 commented on code in PR #64209:
URL: https://github.com/apache/airflow/pull/64209#discussion_r2998940810


##########
scripts/in_container/run_check_default_configuration.py:
##########
@@ -36,23 +36,41 @@
 
 if __name__ == "__main__":
     with tempfile.TemporaryDirectory() as tmp_dir:
+        # We need to explicitly set the logging level to ERROR to avoid debug 
logs from "airflow config lint" command that can spoil the output and make the 
test fail.
+        # This is needed in case the default config has logging level set to 
DEBUG, but it does not hurt to set it explicitly in any case to avoid any 
unexpected debug logs from the command.
+        env = os.environ.copy()
+        env["AIRFLOW__LOGGING__LOGGING_LEVEL"] = "ERROR"
+
         # Write default config cmd output to a temporary file
         default_config_file = os.path.join(tmp_dir, "airflow.cfg")
         with open(default_config_file, "w") as f:
-            result = subprocess.run(list_default_config_cmd, check=False, 
stdout=f)
+            result = subprocess.run(
+                list_default_config_cmd, check=False, stdout=f, 
stderr=subprocess.PIPE, env=env
+            )
         if result.returncode != 0:
             print(f"\033[0;31mERROR: when running `{' 
'.join(list_default_config_cmd)}`\033[0m\n")
+            if result.stderr:
+                print(result.stderr.decode())
+            print(f"Default config (if any) was written to: 
{default_config_file}")
             exit(1)
         # Run airflow config lint to check the default config
-        env = os.environ.copy()
         env["AIRFLOW_HOME"] = tmp_dir
         env["AIRFLOW_CONFIG"] = default_config_file
         result = subprocess.run(lint_config_cmd, check=False, 
capture_output=True, env=env)
 
-    output: str = result.stdout.decode().strip()
-    if result.returncode != 0 or expected_output not in output:
-        print(f"\033[0;31mERROR: when running `{' 
'.join(lint_config_cmd)}`\033[0m\n")
-        print(output)
-        exit(1)
-    print(output)
-    exit(0)
+        output: str = result.stdout.decode().strip()
+        if result.returncode != 0 or expected_output not in output:
+            print(f"\033[0;31mERROR: when running `{' 
'.join(lint_config_cmd)}`\033[0m\n")
+            print(output)
+            # log the stderr as well if available
+            if result.stderr:
+                print(f"\033[0;31mERROR: stderr from `{' 
'.join(lint_config_cmd)}`\033[0m\n")
+                print(result.stderr.decode())
+            # log the default config that was generated for debugging
+            print("\033[0;31mGenerated default config for debugging:\033[0m\n")
+            with open(default_config_file) as f:
+                print(f.read())
+            exit(1)
+        else:
+            print(output)
+            exit(0)

Review Comment:
   Addressed in 
https://github.com/apache/airflow/commit/1bebd1cb4b3bbc7f55cbbac019aef1c2136b5a77



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to