jedcunningham commented on code in PR #32604:
URL: https://github.com/apache/airflow/pull/32604#discussion_r1270908162


##########
airflow/configuration.py:
##########
@@ -1664,6 +1785,61 @@ def remove_all_read_configurations(self):
         for section in self.sections():
             self.remove_section(section)
 
+    @property
+    def providers_configuration_loaded(self) -> bool:
+        """Checks if providers have been loaded."""
+        return self._providers_configuration_loaded
+
+    def load_providers_configuration(self):
+        """
+        Loads configuration for providers.
+
+        This should be done after initial configuration have been performed. 
Initializing and discovering
+        providers is an expensive operation and cannot be performed when we 
load configuration for the first
+        time when airflow starts, because we initialize configuration very 
early, during importing of the
+        `airflow` package and the module is not yet ready to be used when it 
happens and until configuration
+        and settings are loaded. Therefore, in order to reload provider 
configuration we need to additionally
+        load provider - specific configuration.
+        """
+        log.debug("Loading providers configuration")
+        from airflow.providers_manager import ProvidersManager
+
+        self.restore_core_default_configuration()
+        for provider, config in 
ProvidersManager().already_initialized_provider_configs:
+            for provider_section, provider_section_content in config.items():
+                provider_options = provider_section_content["options"]
+                section_in_current_config = 
self.configuration_description.get(provider_section)
+                if not section_in_current_config:
+                    self.configuration_description[provider_section] = 
deepcopy(provider_section_content)
+                    section_in_current_config = 
self.configuration_description.get(provider_section)
+                    section_in_current_config["source"] = f"default-{provider}"
+                    for option in provider_options:
+                        section_in_current_config["options"][option]["source"] 
= f"default-{provider}"
+                else:
+                    section_source = section_in_current_config.get("source", 
"Airflow's core package").split(
+                        "default-"
+                    )[-1]
+                    raise AirflowConfigException(
+                        f"The provider {provider} is attempting to contribute "
+                        f"configuration section {provider_section} that "
+                        f"has already been added before. The source of it: 
{section_source}."
+                        "This is forbidden. A provider can only add new 
sections but it"
+                        "cannot contribute options to existing ones or 
override other "

Review Comment:
   ```suggestion
                           "This is forbidden. A provider can only add new 
sections. It"
                           "cannot contribute options to existing sections or 
override other "
   ```



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