Skip to content

Commit 2cbd0ec

Browse files
authored
Merge pull request #163 from Qubinode/copilot/replace-manual-ssh-commands
Replace manual SSH commands with SSHOperator in Airflow DAGs
2 parents 98c6e02 + 13f1ee1 commit 2cbd0ec

File tree

10 files changed

+976
-333
lines changed

10 files changed

+976
-333
lines changed

.github/workflows/airflow-dag-ci.yml

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,44 @@ jobs:
3737
uses: actions/setup-python@v6
3838
with:
3939
python-version: ${{ env.PYTHON_VERSION }}
40-
cache: 'pip'
4140

42-
- name: Install Airflow and dependencies
41+
- name: Install Airflow and initialize database
4342
run: |
43+
# Use the CI setup script for consistent environment
44+
chmod +x ./airflow/scripts/ci-setup.sh
45+
46+
# Install dependencies
4447
python -m pip install --upgrade pip
45-
pip install "apache-airflow[postgres,celery]==${{ env.AIRFLOW_VERSION }}"
46-
pip install pytest pytest-asyncio
48+
echo "Installing Apache Airflow ${{ env.AIRFLOW_VERSION }}..."
49+
# Use constraints to ensure compatible package versions
50+
PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
51+
CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${{ env.AIRFLOW_VERSION }}/constraints-${PYTHON_VERSION}.txt"
52+
echo "Using constraints: $CONSTRAINT_URL"
53+
54+
pip install "apache-airflow[postgres,celery]==${{ env.AIRFLOW_VERSION }}" --constraint "$CONSTRAINT_URL"
55+
echo "Installing SSH provider..."
56+
pip install "apache-airflow-providers-ssh" --constraint "$CONSTRAINT_URL"
57+
pip install pytest pytest-asyncio pyyaml
58+
echo "Airflow packages installed successfully"
4759
4860
# Install project dependencies
4961
if [ -f requirements.txt ]; then
5062
pip install -r requirements.txt
5163
fi
5264
53-
- name: Initialize Airflow Database
54-
run: |
65+
# Setup PATH and initialize DB
66+
SCRIPTS_DIR=$(python3 -c "import sysconfig; print(sysconfig.get_path('scripts'))")
67+
export PATH="$SCRIPTS_DIR:$PATH"
68+
echo "$SCRIPTS_DIR" >> $GITHUB_PATH
69+
70+
# Verify airflow is available
71+
which airflow
72+
airflow version
73+
5574
export AIRFLOW_HOME=${{ env.AIRFLOW_HOME }}
5675
airflow db init
5776
58-
- name: Install PyYAML for Registry Validation
59-
run: |
60-
pip install pyyaml
77+
echo "[OK] Airflow installed and database initialized"
6178
6279
- name: Validate DAG Registry (ADR-0046)
6380
run: |
@@ -192,6 +209,10 @@ jobs:
192209
mkdir -p ${{ env.AIRFLOW_HOME }}/dags
193210
cp -r airflow/dags/* ${{ env.AIRFLOW_HOME }}/dags/ || true
194211
212+
# Add scripts directory to PATH
213+
SCRIPTS_DIR=$(python3 -c "import sysconfig; print(sysconfig.get_path('scripts'))")
214+
export PATH="$SCRIPTS_DIR:$PATH"
215+
195216
# List and validate DAGs
196217
echo "Listing DAGs..."
197218
airflow dags list || echo "⚠️ No DAGs found or error listing"
@@ -244,6 +265,9 @@ jobs:
244265
- name: Initialize Airflow
245266
run: |
246267
export AIRFLOW_HOME=${{ env.AIRFLOW_HOME }}
268+
# Add scripts directory to PATH for this step
269+
SCRIPTS_DIR=$(python3 -c "import sysconfig; print(sysconfig.get_path('scripts'))")
270+
export PATH="$SCRIPTS_DIR:$PATH"
247271
airflow db init
248272
249273
- name: Validate RAG Ingestion DAG

.github/workflows/airflow-validate.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ jobs:
102102
103103
pip install "apache-airflow==2.10.4" --constraint "$CONSTRAINT_URL"
104104
pip install "apache-airflow-providers-postgres" --constraint "$CONSTRAINT_URL"
105+
pip install "apache-airflow-providers-ssh" --constraint "$CONSTRAINT_URL"
105106
pip install pyyaml
106107
107108
# Find scripts directory
@@ -367,6 +368,7 @@ jobs:
367368
368369
pip install "apache-airflow==2.10.4" --constraint "$CONSTRAINT_URL"
369370
pip install "apache-airflow-providers-postgres" --constraint "$CONSTRAINT_URL"
371+
pip install "apache-airflow-providers-ssh" --constraint "$CONSTRAINT_URL"
370372
pip install openlineage-airflow
371373
pip install pyyaml
372374
pip install httpx # For MCP server testing

airflow/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ RUN pip install --no-cache-dir \
3131
RUN pip install --no-cache-dir \
3232
apache-airflow-providers-hashicorp>=3.0.0
3333

34+
# SSH provider for remote host execution (replaces manual SSH in BashOperator)
35+
# Used for executing commands on host from container (kcli, virsh, ansible)
36+
RUN pip install --no-cache-dir \
37+
apache-airflow-providers-ssh>=3.0.0
38+
3439
# ADR-0038: FastMCP framework for MCP server
3540
# Required for MCP server integration with Claude/AI assistants
3641
RUN pip install --no-cache-dir \

0 commit comments

Comments
 (0)