This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new 93e924d Enable configurable git sync depth (#9094)
93e924d is described below
commit 93e924d3fab6137fda097716a9078705621eb358
Author: mgorsk1 <[email protected]>
AuthorDate: Tue Jun 2 06:36:03 2020 +0000
Enable configurable git sync depth (#9094)
Enable configurable git sync depth
---
airflow/config_templates/config.yml | 8 ++++++++
airflow/config_templates/default_airflow.cfg | 4 ++++
airflow/executors/kubernetes_executor.py | 2 ++
airflow/kubernetes/worker_configuration.py | 2 +-
.../kubernetes/app/templates/configmaps.template.yaml | 1 +
5 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/airflow/config_templates/config.yml
b/airflow/config_templates/config.yml
index 31e3e9d..da675cb 100644
--- a/airflow/config_templates/config.yml
+++ b/airflow/config_templates/config.yml
@@ -1945,6 +1945,14 @@
type: string
example: ~
default: ""
+ - name: git_sync_depth
+ description: |
+ Use a shallow clone with a history truncated to the specified number
of commits.
+ 0 - do not use shallow clone.
+ version_added: 1.10.11
+ type: string
+ example: ~
+ default: "1"
- name: git_subpath
description: |
Subpath of git repo to be pulled for DAGs. This allows users to
maintain multiple DAG
diff --git a/airflow/config_templates/default_airflow.cfg
b/airflow/config_templates/default_airflow.cfg
index f6a5698..5b8cf6d 100644
--- a/airflow/config_templates/default_airflow.cfg
+++ b/airflow/config_templates/default_airflow.cfg
@@ -937,6 +937,10 @@ git_repo =
# using release branches.
git_branch =
+# Use a shallow clone with a history truncated to the specified number of
commits.
+# 0 - do not use shallow clone.
+git_sync_depth = 1
+
# Subpath of git repo to be pulled for DAGs. This allows users to maintain
multiple DAG
# repositories in a single git repo.
git_subpath =
diff --git a/airflow/executors/kubernetes_executor.py
b/airflow/executors/kubernetes_executor.py
index d05c556..d8745d7 100644
--- a/airflow/executors/kubernetes_executor.py
+++ b/airflow/executors/kubernetes_executor.py
@@ -130,6 +130,8 @@ class KubeConfig: # pylint:
disable=too-many-instance-attributes
self.git_repo = conf.get(self.kubernetes_section, 'git_repo')
# The branch of the repository to be checked out
self.git_branch = conf.get(self.kubernetes_section, 'git_branch')
+ # Clone depth for git sync
+ self.git_sync_depth = conf.get(self.kubernetes_section,
'git_sync_depth')
# Optionally, the directory in the git repository containing the dags
self.git_subpath = conf.get(self.kubernetes_section, 'git_subpath')
# Optionally, the root directory for git operations
diff --git a/airflow/kubernetes/worker_configuration.py
b/airflow/kubernetes/worker_configuration.py
index 47cbaaa..732d5ac 100644
--- a/airflow/kubernetes/worker_configuration.py
+++ b/airflow/kubernetes/worker_configuration.py
@@ -73,7 +73,7 @@ class WorkerConfiguration(LoggingMixin):
value=self.kube_config.git_sync_rev
), k8s.V1EnvVar(
name='GIT_SYNC_DEPTH',
- value='1'
+ value=self.kube_config.git_sync_depth
), k8s.V1EnvVar(
name='GIT_SYNC_ONE_TIME',
value='true'
diff --git
a/scripts/ci/in_container/kubernetes/app/templates/configmaps.template.yaml
b/scripts/ci/in_container/kubernetes/app/templates/configmaps.template.yaml
index aed42e6..8525b7b 100644
--- a/scripts/ci/in_container/kubernetes/app/templates/configmaps.template.yaml
+++ b/scripts/ci/in_container/kubernetes/app/templates/configmaps.template.yaml
@@ -166,6 +166,7 @@ data:
dags_in_image = False
git_repo = https://github.com/{{CONFIGMAP_GIT_REPO}}.git
git_branch = {{CONFIGMAP_BRANCH}}
+ git_sync_depth = "1"
git_subpath = airflow/example_dags/
git_user =
git_password =