@Test void podIsNotPastDeletionTimestamp() { V1Pod pod = new V1Pod() .metadata( new V1ObjectMeta() .name(POD_NAME) .deletionTimestamp(new DateTime(clock.wallTime())) ) .spec( new V1PodSpec() .nodeName(NODE_NAME) .terminationGracePeriodSeconds(POD_TERMINATION_GRACE_PERIOD_SEC)) .status(null); Assertions.assertThat(podDeletionGcController.isPodPastDeletionTimestamp(pod)).isFalse(); }
@VisibleForTesting boolean isPodPastDeletionTimestamp(V1Pod pod) { V1PodSpec spec = pod.getSpec(); V1ObjectMeta metadata = pod.getMetadata(); if (spec == null || metadata == null) { return false; } Long terminationGracePeriodSeconds = spec.getTerminationGracePeriodSeconds(); DateTime deletionTimestamp = metadata.getDeletionTimestamp(); if (terminationGracePeriodSeconds == null || deletionTimestamp == null) { return false; } long terminationGracePeriodMs = terminationGracePeriodSeconds * 1000L; return clock.isPast(deletionTimestamp.getMillis() + terminationGracePeriodMs + kubeControllerConfiguration.getPodsPastTerminationGracePeriodMs()); }
PodDeletionGcController extends BaseGcController<V1Pod> { @VisibleForTesting boolean isPodPastDeletionTimestamp(V1Pod pod) { V1PodSpec spec = pod.getSpec(); V1ObjectMeta metadata = pod.getMetadata(); if (spec == null || metadata == null) { return false; } Long terminationGracePeriodSeconds = spec.getTerminationGracePeriodSeconds(); DateTime deletionTimestamp = metadata.getDeletionTimestamp(); if (terminationGracePeriodSeconds == null || deletionTimestamp == null) { return false; } long terminationGracePeriodMs = terminationGracePeriodSeconds * 1000L; return clock.isPast(deletionTimestamp.getMillis() + terminationGracePeriodMs + kubeControllerConfiguration.getPodsPastTerminationGracePeriodMs()); } }
PodDeletionGcController extends BaseGcController<V1Pod> { @VisibleForTesting boolean isPodPastDeletionTimestamp(V1Pod pod) { V1PodSpec spec = pod.getSpec(); V1ObjectMeta metadata = pod.getMetadata(); if (spec == null || metadata == null) { return false; } Long terminationGracePeriodSeconds = spec.getTerminationGracePeriodSeconds(); DateTime deletionTimestamp = metadata.getDeletionTimestamp(); if (terminationGracePeriodSeconds == null || deletionTimestamp == null) { return false; } long terminationGracePeriodMs = terminationGracePeriodSeconds * 1000L; return clock.isPast(deletionTimestamp.getMillis() + terminationGracePeriodMs + kubeControllerConfiguration.getPodsPastTerminationGracePeriodMs()); } @Inject  PodDeletionGcController(
            TitusRuntime titusRuntime,
            LocalScheduler scheduler,
            @Named(POD_DELETION_GC_CONTROLLER) FixedIntervalTokenBucketConfiguration tokenBucketConfiguration,
            @Named(POD_DELETION_GC_CONTROLLER) ControllerConfiguration controllerConfiguration,
            KubeApiFacade kubeApiFacade,
            KubeControllerConfiguration kubeControllerConfiguration
    ); }
PodDeletionGcController extends BaseGcController<V1Pod> { @VisibleForTesting boolean isPodPastDeletionTimestamp(V1Pod pod) { V1PodSpec spec = pod.getSpec(); V1ObjectMeta metadata = pod.getMetadata(); if (spec == null || metadata == null) { return false; } Long terminationGracePeriodSeconds = spec.getTerminationGracePeriodSeconds(); DateTime deletionTimestamp = metadata.getDeletionTimestamp(); if (terminationGracePeriodSeconds == null || deletionTimestamp == null) { return false; } long terminationGracePeriodMs = terminationGracePeriodSeconds * 1000L; return clock.isPast(deletionTimestamp.getMillis() + terminationGracePeriodMs + kubeControllerConfiguration.getPodsPastTerminationGracePeriodMs()); } @Inject  PodDeletionGcController(
            TitusRuntime titusRuntime,
            LocalScheduler scheduler,
            @Named(POD_DELETION_GC_CONTROLLER) FixedIntervalTokenBucketConfiguration tokenBucketConfiguration,
            @Named(POD_DELETION_GC_CONTROLLER) ControllerConfiguration controllerConfiguration,
            KubeApiFacade kubeApiFacade,
            KubeControllerConfiguration kubeControllerConfiguration
    ); @Override boolean shouldGc(); @Override List<V1Pod> getItemsToGc(); @Override boolean gcItem(V1Pod item); }
PodDeletionGcController extends BaseGcController<V1Pod> { @VisibleForTesting boolean isPodPastDeletionTimestamp(V1Pod pod) { V1PodSpec spec = pod.getSpec(); V1ObjectMeta metadata = pod.getMetadata(); if (spec == null || metadata == null) { return false; } Long terminationGracePeriodSeconds = spec.getTerminationGracePeriodSeconds(); DateTime deletionTimestamp = metadata.getDeletionTimestamp(); if (terminationGracePeriodSeconds == null || deletionTimestamp == null) { return false; } long terminationGracePeriodMs = terminationGracePeriodSeconds * 1000L; return clock.isPast(deletionTimestamp.getMillis() + terminationGracePeriodMs + kubeControllerConfiguration.getPodsPastTerminationGracePeriodMs()); } @Inject  PodDeletionGcController(
            TitusRuntime titusRuntime,
            LocalScheduler scheduler,
            @Named(POD_DELETION_GC_CONTROLLER) FixedIntervalTokenBucketConfiguration tokenBucketConfiguration,
            @Named(POD_DELETION_GC_CONTROLLER) ControllerConfiguration controllerConfiguration,
            KubeApiFacade kubeApiFacade,
            KubeControllerConfiguration kubeControllerConfiguration
    ); @Override boolean shouldGc(); @Override List<V1Pod> getItemsToGc(); @Override boolean gcItem(V1Pod item); static final String POD_DELETION_GC_CONTROLLER; static final String POD_DELETION_GC_CONTROLLER_DESCRIPTION; }