diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b1e8261..e451523 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,23 +30,29 @@ jobs: python-version: '3.8' - name: Setup database - run: docker-compose -f tests/docker-compose.yml up -d + run: docker compose -f tests/docker-compose.yml up -d - name: Install Airflow - run: pip install "apache-airflow == ${{ matrix.airflow-version }}" mysqlclient==1.4.6 wtforms==2.3.3 + run: pip install "apache-airflow == ${{ matrix.airflow-version }}" mysqlclient==1.4.6 + + - name: Install airflow-exporter for 2.6.1 + if: matrix.airflow-version == '2.6.1' + run: pip install '.[airflow-2.6.1]' - name: Install airflow-exporter + if: matrix.airflow-version != '2.6.1' run: pip install . - name: Init Airflow DB run: | airflow db init - airflow db init - name: Prepare DAG statuses run: | airflow dags list + airflow dags reserialize + airflow dags unpause dummy_dag airflow dags unpause slow_dag diff --git a/airflow_exporter/prometheus_exporter.py b/airflow_exporter/prometheus_exporter.py index ec24cca..c55d768 100644 --- a/airflow_exporter/prometheus_exporter.py +++ b/airflow_exporter/prometheus_exporter.py @@ -15,7 +15,7 @@ from airflow.utils.state import State # Importing base classes that we need to derive -from prometheus_client import generate_latest, REGISTRY +from prometheus_client import generate_latest, REGISTRY, CONTENT_TYPE_LATEST from prometheus_client.core import GaugeMetricFamily, Metric from prometheus_client.samples import Sample @@ -467,7 +467,7 @@ class RBACMetrics(FABBaseView): @FABexpose('/') def list(self): - return Response(generate_latest(), mimetype='text') + return Response(generate_latest(), mimetype=CONTENT_TYPE_LATEST) # Metrics View for Flask app builder used in airflow with rbac enabled diff --git a/setup.py b/setup.py index efac0db..ffdf6d0 100644 --- a/setup.py +++ b/setup.py @@ -32,9 +32,20 @@ "apache-airflow>=2.6.1", "prometheus_client>=0.4.2", ], + extras_require={ + # NOTE: airflow==2.6.1 has no upper bound on several dependencies. A + # new installation brings newer versions which contain breaking + # changes, requiring us to explicitly pin these dependencies to + # compatible versions. + "airflow-2.6.1": [ + "apache-airflow==2.6.1", + "pydantic<2.0.0", + "pendulum<3.0.0", + "Flask-Session<0.6.0", + "connexion<3.0", + ], + }, entry_points={ - "airflow.plugins": [ - "AirflowPrometheus = airflow_exporter.prometheus_exporter:AirflowPrometheusPlugins" - ] + "airflow.plugins": ["AirflowPrometheus = airflow_exporter.prometheus_exporter:AirflowPrometheusPlugins"] }, )