jedcunningham commented on a change in pull request #15671:
URL: https://github.com/apache/airflow/pull/15671#discussion_r626637797



##########
File path: airflow/example_dags/example_kubernetes_executor_config.py
##########
@@ -61,12 +61,17 @@ def test_volume_mount():
             """
             Tests whether the volume has been mounted.
             """
-            with open('/foo/volume_mount_test.txt', 'w') as foo:
-                foo.write('Hello')
-
-            return_code = os.system("cat /foo/volume_mount_test.txt")
-            if return_code != 0:
-                raise ValueError(f"Error when checking volume mount. Return 
code {return_code}")
+            for i in range(5):
+                try:
+                    return_code = os.system("cat /foo/volume_mount_test.txt")
+                    if return_code != 0:
+                        raise ValueError(f"Error when checking volume mount. 
Return code {return_code}")
+                    else:
+                        with open('/foo/volume_mount_test.txt', 'w') as foo:
+                            foo.write('Hello')
+                except ValueError as e:
+                    if i > 4:
+                        raise e

Review comment:
       ```suggestion
                   except ValueError:
                       if i > 3:
                           raise
   ```
   
   `range` starts at 0. 

##########
File path: airflow/example_dags/example_kubernetes_executor_config.py
##########
@@ -61,12 +61,17 @@ def test_volume_mount():
             """
             Tests whether the volume has been mounted.
             """
-            with open('/foo/volume_mount_test.txt', 'w') as foo:
-                foo.write('Hello')
-
-            return_code = os.system("cat /foo/volume_mount_test.txt")
-            if return_code != 0:
-                raise ValueError(f"Error when checking volume mount. Return 
code {return_code}")
+            for i in range(5):
+                try:
+                    return_code = os.system("cat /foo/volume_mount_test.txt")
+                    if return_code != 0:
+                        raise ValueError(f"Error when checking volume mount. 
Return code {return_code}")
+                    else:
+                        with open('/foo/volume_mount_test.txt', 'w') as foo:
+                            foo.write('Hello')

Review comment:
       ```suggestion
                       with open('/foo/volume_mount_test.txt', 'w') as foo:
                               foo.write('Hello')
   
                       return_code = os.system("cat /foo/volume_mount_test.txt")
                       if return_code != 0:
                           raise ValueError(f"Error when checking volume mount. 
Return code {return_code}")    
   ```
   
   We still need to write the file first. Chicken-egg problem here as the cat 
always fails, until we write the file, which won't happen until the cat 
succeeds?




-- 
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.

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


Reply via email to