@Override
    public void doRun() {
        if (isServerInPreflightMode.get()) {
            // we don't want to automatically trigger CSRs during preflight, don't run it if the preflight is still not finished or skipped
            LOG.debug("Datanode still in preflight mode, skipping cert renewal task");
            return;
        }

        // always check if there are any certificates that we can accept
        getRenewalPolicy()
                .filter(this::needsNewCertificate)
                .ifPresent(renewalPolicy -> {
                    switch (renewalPolicy.mode()) {
                        case AUTOMATIC -> automaticRenewal();
                        case MANUAL -> manualRenewal();
                    }
                });

    }
@Test
    void testExpiringSoon() throws Exception {
        final DatanodeKeystore datanodeKeystore = datanodeKeystore(Duration.ofMinutes(1));
        final CsrRequester csrRequester = Mockito.mock(CsrRequester.class);
        final DataNodeCertRenewalPeriodical periodical = new DataNodeCertRenewalPeriodical(datanodeKeystore, autoRenewalPolicy("PT1M"), csrRequester, () -> false);
        periodical.doRun();
        Mockito.verify(csrRequester, Mockito.times(1)).triggerCertificateSigningRequest();
    }