Don't WARN on KDC workers if cpus == 1 and KRB5KDC_ARGS is empty
This commit is contained in:
parent
db8c61d390
commit
e2e1b502ed
110
0003-kdc-Don-t-return-a-WARNING-if-there-are-no-ARGS-and-.patch
Normal file
110
0003-kdc-Don-t-return-a-WARNING-if-there-are-no-ARGS-and-.patch
Normal file
@ -0,0 +1,110 @@
|
||||
From 56e784db02c0635ae3e2e8fb49159ba731840a23 Mon Sep 17 00:00:00 2001
|
||||
From: Rob Crittenden <rcritten@redhat.com>
|
||||
Date: Mon, 6 Jun 2022 09:16:40 -0400
|
||||
Subject: [PATCH] kdc: Don't return a WARNING if there are no ARGS and cpus ==
|
||||
1
|
||||
|
||||
If there is only a single CPU at installation time then
|
||||
KRB5KDC_ARGS is nnot set and it may contain an empty value like:
|
||||
|
||||
KRB5KDC_ARSG=
|
||||
|
||||
Treat this as a successful execution.
|
||||
|
||||
Related: https://github.com/freeipa/freeipa-healthcheck/issues/258
|
||||
|
||||
Signed-off-by: Rob Crittenden <rcritten@redhat.com>
|
||||
---
|
||||
src/ipahealthcheck/ipa/kdc.py | 15 ++++++++-----
|
||||
tests/test_ipa_kdc.py | 42 ++++++++++++++++++++++++++++++++++-
|
||||
2 files changed, 51 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/ipahealthcheck/ipa/kdc.py b/src/ipahealthcheck/ipa/kdc.py
|
||||
index c5c056e..614c131 100644
|
||||
--- a/src/ipahealthcheck/ipa/kdc.py
|
||||
+++ b/src/ipahealthcheck/ipa/kdc.py
|
||||
@@ -40,11 +40,16 @@ class KDCWorkersCheck(IPAPlugin):
|
||||
args_read = True
|
||||
sline = sline.split('=', maxsplit=1)[1]
|
||||
if sline.find("-w") == -1:
|
||||
- yield Result(self, constants.WARNING, key=key,
|
||||
- sysconfig=SYSCONFIG,
|
||||
- msg='No KDC workers defined in '
|
||||
- '{sysconfig}')
|
||||
- return
|
||||
+ if cpus == 1:
|
||||
+ # -w is not configured when cpus == 1
|
||||
+ yield Result(self, constants.SUCCESS, key=key)
|
||||
+ return
|
||||
+ else:
|
||||
+ yield Result(self, constants.WARNING, key=key,
|
||||
+ sysconfig=SYSCONFIG,
|
||||
+ msg='No KDC workers defined in '
|
||||
+ '{sysconfig}')
|
||||
+ return
|
||||
|
||||
# Making an assumption that this line is not misconfigured
|
||||
# otherwise the KDC wouldn't start at all.
|
||||
diff --git a/tests/test_ipa_kdc.py b/tests/test_ipa_kdc.py
|
||||
index 33a5262..46a1609 100644
|
||||
--- a/tests/test_ipa_kdc.py
|
||||
+++ b/tests/test_ipa_kdc.py
|
||||
@@ -14,7 +14,7 @@ from ipahealthcheck.ipa.kdc import KDCWorkersCheck
|
||||
class TestKDCWorkers(BaseTest):
|
||||
@patch('ipahealthcheck.ipa.kdc.get_contents')
|
||||
@patch('os.sysconf')
|
||||
- def test_no_workers(self, mock_sysconf, mock_sysconfig):
|
||||
+ def test_no_workers_noargs(self, mock_sysconf, mock_sysconfig):
|
||||
mock_sysconf.return_value = 1
|
||||
mock_sysconfig.return_value = ""
|
||||
framework = object()
|
||||
@@ -33,6 +33,46 @@ class TestKDCWorkers(BaseTest):
|
||||
assert result.kw.get('sysconfig') == '/etc/sysconfig/krb5kdc'
|
||||
assert result.kw.get('msg') == 'KRB5KDC_ARGS is not set in {sysconfig}'
|
||||
|
||||
+ @patch('ipahealthcheck.ipa.kdc.get_contents')
|
||||
+ @patch('os.sysconf')
|
||||
+ def test_no_workers_empty_noargs(self, mock_sysconf, mock_sysconfig):
|
||||
+ mock_sysconf.return_value = 1
|
||||
+ mock_sysconfig.return_value = ("KRB5KDC_ARGS=",)
|
||||
+ framework = object()
|
||||
+ registry.initialize(framework, config.Config)
|
||||
+ f = KDCWorkersCheck(registry)
|
||||
+
|
||||
+ self.results = capture_results(f)
|
||||
+
|
||||
+ assert len(self.results) == 1
|
||||
+
|
||||
+ result = self.results.results[0]
|
||||
+ assert result.result == constants.SUCCESS
|
||||
+ assert result.source == 'ipahealthcheck.ipa.kdc'
|
||||
+ assert result.check == 'KDCWorkersCheck'
|
||||
+ assert result.kw.get('key') == 'workers'
|
||||
+
|
||||
+ @patch('ipahealthcheck.ipa.kdc.get_contents')
|
||||
+ @patch('os.sysconf')
|
||||
+ def test_with_workers_empty_noargs(self, mock_sysconf, mock_sysconfig):
|
||||
+ mock_sysconf.return_value = 2
|
||||
+ mock_sysconfig.return_value = ("KRB5KDC_ARGS=",)
|
||||
+ framework = object()
|
||||
+ registry.initialize(framework, config.Config)
|
||||
+ f = KDCWorkersCheck(registry)
|
||||
+
|
||||
+ self.results = capture_results(f)
|
||||
+
|
||||
+ assert len(self.results) == 1
|
||||
+
|
||||
+ result = self.results.results[0]
|
||||
+ assert result.result == constants.WARNING
|
||||
+ assert result.source == 'ipahealthcheck.ipa.kdc'
|
||||
+ assert result.check == 'KDCWorkersCheck'
|
||||
+ assert result.kw.get('key') == 'workers'
|
||||
+ assert result.kw.get('sysconfig') == '/etc/sysconfig/krb5kdc'
|
||||
+ assert result.kw.get('msg') == 'No KDC workers defined in {sysconfig}'
|
||||
+
|
||||
@patch('ipahealthcheck.ipa.kdc.get_contents')
|
||||
@patch('os.sysconf')
|
||||
def test_workers_match_single(self, mock_sysconf, mock_sysconfig):
|
||||
--
|
||||
2.35.1
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
Name: %{prefix}-healthcheck
|
||||
Version: 0.11
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Summary: Health check tool for %{productname}
|
||||
BuildArch: noarch
|
||||
License: GPLv3
|
||||
@ -27,6 +27,7 @@ Source1: ipahealthcheck.conf
|
||||
|
||||
Patch0001: 0001-Remove-ipaclustercheck.patch
|
||||
Patch0002: 0002-Disable-two-failing-tests.patch
|
||||
Patch0003: 0003-kdc-Don-t-return-a-WARNING-if-there-are-no-ARGS-and-.patch
|
||||
|
||||
Requires: %{name}-core = %{version}-%{release}
|
||||
Requires: %{prefix}-server
|
||||
@ -156,6 +157,9 @@ PYTHONPATH=src PATH=$PATH:$RPM_BUILD_ROOT/usr/bin pytest-3 tests/test_*
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Jun 06 2022 Rob Crittenden <rcritten@redhat.com> - 0.11-2
|
||||
- Don't WARN on KDC workers if cpus == 1 and KRB5KDC_ARGS is empty
|
||||
|
||||
* Thu Jun 02 2022 Rob Crittenden <rcritten@redhat.com> - 0.11-1
|
||||
- Update to 0.11 release
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user