amoghrajesh commented on PR #47946:
URL: https://github.com/apache/airflow/pull/47946#issuecomment-2740266522

   To try that hybrid scenario:
   
   Do not set workers secrets backend config, but set for secrets backend:
   
   ```
   root@2480ed297606:/opt/airflow# airflow config get-value workers 
secrets_backend
   
   root@2480ed297606:/opt/airflow# airflow config get-value secrets backend
   airflow.secrets.local_filesystem.LocalFilesystemBackend
   root@2480ed297606:/opt/airflow# airflow config get-value secrets 
backend_kwargs
   {"connections_file_path": "/files/conn.json", "variables_file_path": 
"/files/var.json"}
   ```
   
   conn.json btw:
   ```
   {
       "CONN_API_SERVER_A": "mysql://host_a"
   }
   ```
   
   
   Now try this dag:
   ```
   from __future__ import annotations
   
   from airflow.models.baseoperator import BaseOperator
   from airflow import DAG
   from airflow.sdk.definitions.connection import Connection
   
   class CustomOperator(BaseOperator):
       def execute(self, context):
           c = Connection.get(conn_id="CONN_API_SERVER_A")
           print("The connection is", c)
   
           # print("Connection attributes are", vars(c))
   
   
   with DAG("example_get_connection_from_secrets", schedule=None, 
catchup=False, tags=["secrets_backend"]) as dag:
       CustomOperator(task_id="print_conn")
   
   ```
   
   
   <img width="1715" alt="image" 
src="https://github.com/user-attachments/assets/9a1e435f-a4d8-41d0-acdb-226680614f50";
 />
   
   The above test shows that we get the config as fallback from secrets backend 
of API server and function if not provided for workers.


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