jedcunningham commented on code in PR #46253:
URL: https://github.com/apache/airflow/pull/46253#discussion_r1934521846
##########
airflow/dag_processing/bundles/git.py:
##########
@@ -151,10 +151,14 @@ def initialize(self) -> None:
def _clone_repo_if_required(self) -> None:
if not os.path.exists(self.repo_path):
self.log.info("Cloning repository to %s from %s", self.repo_path,
self.bare_repo_path)
- Repo.clone_from(
- url=self.bare_repo_path,
- to_path=self.repo_path,
- )
+ try:
+ Repo.clone_from(
+ url=self.bare_repo_path,
+ to_path=self.repo_path,
+ )
+ except NoSuchPathError as e:
+ # Protection should the path be removed manually
Review Comment:
```suggestion
# Protection should the bare repo be removed manually
```
##########
airflow/dag_processing/bundles/git.py:
##########
@@ -163,12 +167,18 @@ def _clone_bare_repo_if_required(self) -> None:
raise AirflowException(f"Connection {self.git_conn_id} doesn't
have a host url")
if not os.path.exists(self.bare_repo_path):
self.log.info("Cloning bare repository to %s", self.bare_repo_path)
- Repo.clone_from(
- url=self.repo_url,
- to_path=self.bare_repo_path,
- bare=True,
- env=self.hook.env,
- )
+ try:
+ Repo.clone_from(
+ url=self.repo_url,
+ to_path=self.bare_repo_path,
+ bare=True,
+ env=self.hook.env,
+ )
+ except GitCommandError as e:
+ # log the error to appear in dag-processor stdout and raise
exception to appear
+ # in the dag-processor logs
+ self.log.info("Error cloning repository %s: %s",
self.repo_url, e)
+ raise AirflowException("Error cloning repository: %s", e)
Review Comment:
```suggestion
raise AirflowException("Error cloning repository") from e
```
This is probably all we need? Worth testing it out though.
##########
airflow/dag_processing/bundles/git.py:
##########
@@ -163,12 +167,18 @@ def _clone_bare_repo_if_required(self) -> None:
raise AirflowException(f"Connection {self.git_conn_id} doesn't
have a host url")
if not os.path.exists(self.bare_repo_path):
self.log.info("Cloning bare repository to %s", self.bare_repo_path)
- Repo.clone_from(
- url=self.repo_url,
- to_path=self.bare_repo_path,
- bare=True,
- env=self.hook.env,
- )
+ try:
+ Repo.clone_from(
+ url=self.repo_url,
+ to_path=self.bare_repo_path,
+ bare=True,
+ env=self.hook.env,
+ )
+ except GitCommandError as e:
+ # log the error to appear in dag-processor stdout and raise
exception to appear
+ # in the dag-processor logs
Review Comment:
fyi, these will be combined here soon - since it's no longer a standalone
component, it'll all end up in stdout/stderr. Let's leave the log part out in
prep.
--
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]