forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AIRFLOW-2424] Add dagrun status endpoint and increased k8s test cove…
…rage [AIRFLOW-2424] Add dagrun status endpoint and increase k8s test coverage [AIRFLOW-2424] Added minikube fixes by @kimoonkim [AIRFLOW-2424] modify endpoint to remove 'status' Closes apache#3320 from dimberman/add-kubernetes-test
- Loading branch information
Showing
11 changed files
with
359 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from airflow.exceptions import AirflowException | ||
from airflow.models import DagBag | ||
|
||
|
||
def get_dag_run_state(dag_id, execution_date): | ||
"""Return the task object identified by the given dag_id and task_id.""" | ||
|
||
dagbag = DagBag() | ||
|
||
# Check DAG exists. | ||
if dag_id not in dagbag.dags: | ||
error_message = "Dag id {} not found".format(dag_id) | ||
raise AirflowException(error_message) | ||
|
||
# Get DAG object and check Task Exists | ||
dag = dagbag.get_dag(dag_id) | ||
|
||
# Get DagRun object and check that it exists | ||
dagrun = dag.get_dagrun(execution_date=execution_date) | ||
if not dagrun: | ||
error_message = ('Dag Run for date {} not found in dag {}' | ||
.format(execution_date, dag_id)) | ||
raise AirflowException(error_message) | ||
|
||
return {'state': dagrun.get_state()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ cd /usr/local/lib/python2.7/dist-packages/airflow && \ | |
cp -R example_dags/* /root/airflow/dags/ && \ | ||
airflow initdb && \ | ||
alembic upgrade heads && \ | ||
airflow create_user -u airflow -l airflow -f jon -e [email protected] -r Admin -p airflow | ||
(airflow create_user -u airflow -l airflow -f jon -e [email protected] -r Admin -p airflow || true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# This script was based on one made by @kimoonkim for kubernetes-hdfs | ||
|
||
# Helper bash functions. | ||
|
||
# Wait for Kubernetes resources to be up and ready. | ||
function _wait_for_ready () { | ||
local count="$1" | ||
shift | ||
local evidence="$1" | ||
shift | ||
local attempts=40 | ||
echo "Waiting till ready (count: $count): $@" | ||
while [[ "$count" != $("$@" 2>&1 | tail -n +2 | grep -c $evidence) ]]; | ||
do | ||
if [[ "$attempts" = "1" ]]; then | ||
echo "Last run: $@" | ||
"$@" || true | ||
local command="$@" | ||
command="${command/get/describe}" | ||
$command || true | ||
fi | ||
((attempts--)) || return 1 | ||
sleep 5 | ||
done | ||
"$@" || true | ||
} | ||
|
||
# Wait for all expected number of nodes to be ready | ||
function k8s_all_nodes_ready () { | ||
local count="$1" | ||
shift | ||
_wait_for_ready "$count" "-v NotReady" kubectl get nodes | ||
_wait_for_ready "$count" Ready kubectl get nodes | ||
} | ||
|
||
function k8s_single_node_ready () { | ||
k8s_all_nodes_ready 1 | ||
} | ||
|
||
# Wait for all expected number of pods to be ready. This works only for | ||
# pods with up to 4 containers, as we check "1/1" to "4/4" in | ||
# `kubectl get pods` output. | ||
function k8s_all_pods_ready () { | ||
local count="$1" | ||
shift | ||
local evidence="-e 1/1 -e 2/2 -e 3/3 -e 4/4" | ||
_wait_for_ready "$count" "$evidence" kubectl get pods "$@" | ||
} | ||
|
||
function k8s_single_pod_ready () { | ||
k8s_all_pods_ready 1 "$@" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.