potiuk commented on code in PR #28846:
URL: https://github.com/apache/airflow/pull/28846#discussion_r1066655259


##########
airflow/www/app.py:
##########
@@ -131,7 +132,29 @@ def create_app(config=None, testing=False):
 
     init_robots(flask_app)
 
+    # Configure caching
+    webserver_caching_hash_method = conf.get(section="webserver", 
key="CACHING_HASH_METHOD", fallback=None)
     cache_config = {"CACHE_TYPE": "flask_caching.backends.filesystem", 
"CACHE_DIR": gettempdir()}

Review Comment:
   You need to add this new parameter in `airflow/config_templates/config.yml` 
with description and defaults and let pre-commit do the job of updating the 
documentation.



##########
airflow/www/app.py:
##########
@@ -131,7 +132,29 @@ def create_app(config=None, testing=False):
 
     init_robots(flask_app)
 
+    # Configure caching
+    webserver_caching_hash_method = conf.get(section="webserver", 
key="CACHING_HASH_METHOD", fallback=None)
     cache_config = {"CACHE_TYPE": "flask_caching.backends.filesystem", 
"CACHE_DIR": gettempdir()}
+
+    if (
+        webserver_caching_hash_method is not None
+        and webserver_caching_hash_method.casefold() != "md5".casefold()
+    ):
+        if webserver_caching_hash_method.casefold() == "sha512".casefold():
+            cache_config["CACHE_OPTIONS"] = {"hash_method": hashlib.sha512}
+        elif webserver_caching_hash_method.casefold() == "sha384".casefold():
+            cache_config["CACHE_OPTIONS"] = {"hash_method": hashlib.sha384}
+        elif webserver_caching_hash_method.casefold() == "sha256".casefold():
+            cache_config["CACHE_OPTIONS"] = {"hash_method": hashlib.sha256}
+        elif webserver_caching_hash_method.casefold() == "sha224".casefold():

Review Comment:
   Calling casefold (or even lower) should be done where 
`webserver_caching_hash_method` is set. There is no reason to casefold already 
lower-case constants. Additionally probably what you want to do here is to have 
a dict/mapping of the hash name to hashlib algorithm and use it rather than 
sequence of if/elif.



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to