Skip to content

Commit 9ffe713

Browse files
committed
mgr/cephadm: adding new debug flag for testing purposes only
Signed-off-by: Redouane Kachach <[email protected]>
1 parent 81c54dd commit 9ffe713

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/pybind/mgr/cephadm/module.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,12 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
410410
default=False,
411411
desc='Log all refresh metadata. Includes daemon, device, and host info collected regularly. Only has effect if logging at debug level'
412412
),
413+
Option(
414+
'certificate_check_debug_mode',
415+
type='bool',
416+
default=False,
417+
desc='FOR TESTING ONLY: This flag forces the certificate check instead of waiting for certificate_check_period.',
418+
),
413419
Option(
414420
'certificate_automated_rotation_enabled',
415421
type='bool',
@@ -576,6 +582,7 @@ def __init__(self, *args: Any, **kwargs: Any):
576582
self.certificate_duration_days = 0
577583
self.certificate_renewal_threshold_days = 0
578584
self.certificate_automated_rotation_enabled = False
585+
self.certificate_check_debug_mode = False
579586
self.certificate_check_period = 0
580587

581588
self.notify(NotifyType.mon_map, None)

src/pybind/mgr/cephadm/serve.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,20 @@ def _check_certificates(self) -> None:
148148

149149
# Check certificates if:
150150
# - This is the first time (startup, last_certificates_check is None)
151+
# - We are running in certificates check debug mode (for testing only)
151152
# - Or the elapsed time is greater than or equal to the configured check period
152-
check_certificates = False
153-
if self.last_certificates_check is None:
154-
check_certificates = True
155-
else:
156-
elapsed_time = datetime_now() - self.last_certificates_check
157-
check_certificates = elapsed_time.days >= self.mgr.certificate_check_period
153+
check_certificates = (
154+
self.last_certificates_check is None
155+
or self.mgr.certificate_check_debug_mode
156+
or (datetime_now() - self.last_certificates_check).days >= self.mgr.certificate_check_period
157+
)
158158

159159
if check_certificates:
160160
self.log.debug('_check_certificates')
161161
self.last_certificates_check = datetime_now()
162162
services_to_reconfig, _ = self.mgr.cert_mgr.check_services_certificates(fix_issues=True)
163163
for svc in services_to_reconfig:
164-
logger.info(f'certmgr: certificate has changed, reconfiguring service {svc}')
164+
self.log.info(f'certmgr: certificate has changed, reconfiguring service {svc}')
165165
self.mgr.service_action('reconfig', svc)
166166

167167
def _serve_sleep(self) -> None:

0 commit comments

Comments
 (0)