This is an automated email from the ASF dual-hosted git repository.

Miretpl pushed a commit to branch chart/v1-2x-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/chart/v1-2x-test by this push:
     new 9cfa002ec8e Add option to expose git-sync metrics port (#69703)
9cfa002ec8e is described below

commit 9cfa002ec8ee106778e838535bf0f0d484e75b52
Author: Preetham Sanji <[email protected]>
AuthorDate: Thu Jul 16 02:57:58 2026 +0530

    Add option to expose git-sync metrics port (#69703)
---
 chart/templates/_helpers.yaml                      | 11 +++++
 chart/values.schema.json                           | 12 +++++
 chart/values.yaml                                  |  5 +++
 .../helm_tests/other/test_git_sync_scheduler.py    | 51 ++++++++++++++++++++++
 4 files changed, 79 insertions(+)

diff --git a/chart/templates/_helpers.yaml b/chart/templates/_helpers.yaml
index fd5c0c5153b..6354eea000b 100644
--- a/chart/templates/_helpers.yaml
+++ b/chart/templates/_helpers.yaml
@@ -317,12 +317,23 @@ If release name contains chart name it will be used as a 
full name.
       value: ":{{ .Values.dags.gitSync.httpPort }}"
     - name: GITSYNC_HTTP_BIND
       value: ":{{ .Values.dags.gitSync.httpPort }}"
+    {{- if .Values.dags.gitSync.metrics.enabled }}
+    - name: GIT_SYNC_HTTP_METRICS
+      value: "true"
+    - name: GITSYNC_HTTP_METRICS
+      value: "true"
+    {{- end }}
     {{- end }}
     {{- with .Values.dags.gitSync.env }}
     {{- toYaml . | nindent 4 }}
     {{- end }}
   resources: {{ toYaml .Values.dags.gitSync.resources | nindent 4 }}
   {{- if not .is_init }}
+  {{- if .Values.dags.gitSync.metrics.enabled }}
+  ports:
+    - name: gitsync-metrics
+      containerPort: {{ .Values.dags.gitSync.httpPort }}
+  {{- end }}
   {{- if .Values.dags.gitSync.startupProbe.enabled }}
   startupProbe:
     httpGet:
diff --git a/chart/values.schema.json b/chart/values.schema.json
index ff6e7bdc2a5..aa2f0563020 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -12099,6 +12099,18 @@
                             "type": "integer",
                             "default": 1234
                         },
+                        "metrics": {
+                            "description": "Expose the git-sync metrics 
endpoint by adding a named container port and enabling metrics on the git-sync 
http server.",
+                            "type": "object",
+                            "additionalProperties": false,
+                            "properties": {
+                                "enabled": {
+                                    "description": "Enable the git-sync 
metrics port.",
+                                    "type": "boolean",
+                                    "default": false
+                                }
+                            }
+                        },
                         "recommendedProbeSetting": {
                             "description": "Setting this to true, will remove 
readiness probe usage and configure liveness probe to use a dedicated Git-Sync 
liveness service.",
                             "type": "boolean",
diff --git a/chart/values.yaml b/chart/values.yaml
index ef45f9244cb..55b34bd32ac 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -4494,6 +4494,11 @@ dags:
     # default one and old one will be removed
     recommendedProbeSetting: false
 
+    # Expose git-sync metrics by adding a named container port.
+    # Requires the git-sync http server, which is bound on httpPort.
+    metrics:
+      enabled: false
+
     startupProbe:
       enabled: true
       timeoutSeconds: 1
diff --git a/helm-tests/tests/helm_tests/other/test_git_sync_scheduler.py 
b/helm-tests/tests/helm_tests/other/test_git_sync_scheduler.py
index 4d05600af91..9cbfb2bd100 100644
--- a/helm-tests/tests/helm_tests/other/test_git_sync_scheduler.py
+++ b/helm-tests/tests/helm_tests/other/test_git_sync_scheduler.py
@@ -17,6 +17,7 @@
 from __future__ import annotations
 
 import jmespath
+import pytest
 from chart_utils.helm_template_generator import render_chart
 
 
@@ -122,6 +123,56 @@ class TestGitSyncSchedulerTest:
             },
         }
 
+    @pytest.mark.parametrize(
+        ("executor", "show_only", "extra_values"),
+        [
+            ("LocalExecutor", "templates/scheduler/scheduler-deployment.yaml", 
{}),
+            ("CeleryExecutor", "templates/workers/worker-deployment.yaml", {}),
+            ("CeleryExecutor", 
"templates/triggerer/triggerer-deployment.yaml", {}),
+            (
+                "KubernetesExecutor",
+                "templates/dag-processor/dag-processor-deployment.yaml",
+                {"dagProcessor": {"enabled": True}},
+            ),
+        ],
+    )
+    def test_metrics_port_added_when_metrics_enabled(self, executor, 
show_only, extra_values):
+        values = {
+            "executor": executor,
+            "dags": {"gitSync": {"enabled": True, "metrics": {"enabled": 
True}}},
+            **extra_values,
+        }
+        docs = render_chart(values=values, show_only=[show_only])
+
+        container = 
jmespath.search("spec.template.spec.containers[?name=='git-sync']", docs[0])[0]
+        assert container["ports"] == [{"name": "gitsync-metrics", 
"containerPort": 1234}]
+        assert {"name": "GITSYNC_HTTP_METRICS", "value": "true"} in 
container["env"]
+        assert {"name": "GIT_SYNC_HTTP_METRICS", "value": "true"} in 
container["env"]
+
+    def test_metrics_port_follows_http_port(self):
+        docs = render_chart(
+            values={
+                "executor": "LocalExecutor",
+                "dags": {"gitSync": {"enabled": True, "httpPort": 8080, 
"metrics": {"enabled": True}}},
+            },
+            show_only=["templates/scheduler/scheduler-deployment.yaml"],
+        )
+
+        container = 
jmespath.search("spec.template.spec.containers[?name=='git-sync']", docs[0])[0]
+        assert container["ports"] == [{"name": "gitsync-metrics", 
"containerPort": 8080}]
+
+    def test_no_metrics_port_by_default(self):
+        docs = render_chart(
+            values={
+                "executor": "LocalExecutor",
+                "dags": {"gitSync": {"enabled": True}},
+            },
+            show_only=["templates/scheduler/scheduler-deployment.yaml"],
+        )
+
+        container = 
jmespath.search("spec.template.spec.containers[?name=='git-sync']", docs[0])[0]
+        assert "ports" not in container
+
     def test_validate_the_git_sync_container_spec_if_wait_specified(self):
         docs = render_chart(
             values={

Reply via email to