samraj2k commented on code in PR #74915:
URL: https://github.com/apache/airflow/pull/74915#discussion_r4370515481
##########
airflow-core/src/airflow/dag_processing/bundles/manager.py:
##########
@@ -387,40 +498,49 @@ def _extract_and_sign_template(bundle_name: str) ->
tuple[str | None, dict]:
self.log.debug("Signed URL template for bundle %s",
bundle_name)
return new_template_, new_params_
- stored = {b.name: b for b in
session.scalars(select(DagBundleModel)).all()}
+ stored = {
+ b.name: b
+ for b in
session.scalars(select(DagBundleModel).options(selectinload(DagBundleModel.teams))).all()
+ }
bundle_to_team = {
bundle.name: bundle.teams[0].name if len(bundle.teams) == 1 else
None
for bundle in stored.values()
}
+ requested_teams = {config.team_name for config in
self._bundle_config.values() if config.team_name}
+ teams = {
+ team.name: team for team in
session.scalars(select(Team).where(Team.name.in_(requested_teams)))
+ }
+
for name, config in self._bundle_config.items():
team: Team | None = None
if config.team_name:
- team = session.scalars(select(Team).where(Team.name ==
config.team_name)).one_or_none()
+ team = teams.get(config.team_name)
if not team:
raise _bundle_item_exc(f"Team '{config.team_name}' does
not exist")
- try:
- new_template, new_params = _extract_and_sign_template(name)
- except Exception as e:
- self.log.exception("Error creating bundle '%s': %s", name, e)
- continue
-
- if bundle := stored.pop(name, None):
- bundle.active = True
+ bundle = stored.pop(name, None)
+ update_template = bundle_instances is None or name in
bundle_instances
+ if update_template:
+ try:
+ new_template, new_params = _extract_and_sign_template(name)
+ except Exception as e:
+ self.log.exception("Error creating bundle '%s': %s", name,
e)
+ if bundle is None and bundle_instances is None:
+ continue
+ update_template = False
Review Comment:
Thanks, to solve this, we retain failed template updates in
_pending_template_updates
--
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]