This is an automated email from the ASF dual-hosted git repository.
ash pushed a commit to branch v1-10-stable
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v1-10-stable by this push:
new 66067a2 Don't exit upgrade_check with code 1 if there are no problems
(#14740)
66067a2 is described below
commit 66067a27cfc974d3e42c68167fab409f8bc968f6
Author: Marian Cepok <[email protected]>
AuthorDate: Fri Mar 12 14:48:39 2021 +0100
Don't exit upgrade_check with code 1 if there are no problems (#14740)
Co-authored-by: Marian Cepok <[email protected]>
---
airflow/upgrade/checker.py | 5 +++--
airflow/upgrade/problem.py | 4 ++++
tests/upgrade/test_problem.py | 5 +++++
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/airflow/upgrade/checker.py b/airflow/upgrade/checker.py
index 7bd24ba..cd81f45 100644
--- a/airflow/upgrade/checker.py
+++ b/airflow/upgrade/checker.py
@@ -115,8 +115,9 @@ def run(args):
# We want to show only output of upgrade_check command
logging.disable(logging.ERROR)
- all_problems = check_upgrade(formatter, rules)
- if all_problems:
+ all_rule_statuses = check_upgrade(formatter, rules)
+ any_problems = any(rule.is_problem for rule in all_rule_statuses)
+ if any_problems:
sys.exit(1)
diff --git a/airflow/upgrade/problem.py b/airflow/upgrade/problem.py
index e26b020..96787b1 100644
--- a/airflow/upgrade/problem.py
+++ b/airflow/upgrade/problem.py
@@ -33,6 +33,10 @@ class RuleStatus(NamedTuple(
def is_success(self):
return len(self.messages) == 0
+ @property
+ def is_problem(self):
+ return not self.skipped and not self.is_success
+
@classmethod
def from_rule(cls, rule):
# type: (BaseRule) -> RuleStatus
diff --git a/tests/upgrade/test_problem.py b/tests/upgrade/test_problem.py
index 87ea020..d8c0c0e 100644
--- a/tests/upgrade/test_problem.py
+++ b/tests/upgrade/test_problem.py
@@ -25,6 +25,11 @@ class TestRuleStatus:
assert RuleStatus(rule=mock.MagicMock(), messages=[],
skipped=False).is_success is True
assert RuleStatus(rule=mock.MagicMock(), messages=["aaa"],
skipped=False).is_success is False
+ def test_is_problem(self):
+ assert RuleStatus(rule=mock.MagicMock(), messages=[],
skipped=False).is_problem is False
+ assert RuleStatus(rule=mock.MagicMock(), messages=["aaa"],
skipped=False).is_problem is True
+ assert RuleStatus(rule=mock.MagicMock(), messages=["aaa"],
skipped=True).is_problem is False
+
def test_rule_status_from_rule(self):
msgs = ["An interesting problem to solve"]
rule = mock.MagicMock()