PodOnUnknownNodeGcController extends BaseGcController<V1Pod> { @VisibleForTesting boolean isPodOnUnknownNode(V1Pod pod, Set<String> knownNodeNames) { if (pod == null || pod.getSpec() == null) { return false; } String nodeName = pod.getSpec().getNodeName(); return StringExt.isNotEmpty(nodeName) && !knownNodeNames.contains(nodeName); } @Inject  PodOnUnknownNodeGcController(
            TitusRuntime titusRuntime,
            LocalScheduler scheduler,
            @Named(POD_ON_UNKNOWN_NODE_GC_CONTROLLER) FixedIntervalTokenBucketConfiguration tokenBucketConfiguration,
            @Named(POD_ON_UNKNOWN_NODE_GC_CONTROLLER) ControllerConfiguration controllerConfiguration,
            KubeApiFacade kubeApiFacade
    ); @Override boolean shouldGc(); @Override List<V1Pod> getItemsToGc(); @Override boolean gcItem(V1Pod item); static final String POD_ON_UNKNOWN_NODE_GC_CONTROLLER; static final String POD_ON_UNKNOWN_NODE_GC_CONTROLLER_DESCRIPTION; }
@Test void podIsOnUnknownNode() { V1Pod pod = new V1Pod() .metadata(new V1ObjectMeta().name(POD_NAME)) .spec(new V1PodSpec().nodeName(NODE_NAME)) .status(null); Assertions.assertThat(podGcController.isPodOnUnknownNode(pod, Collections.emptySet())).isTrue(); }
@Test void podIsOnKnownNode() { V1Pod pod = new V1Pod() .metadata(new V1ObjectMeta().name(POD_NAME)) .spec(new V1PodSpec().nodeName(NODE_NAME)) .status(null); Assertions.assertThat(podGcController.isPodOnUnknownNode(pod, Collections.singleton(NODE_NAME))).isFalse(); }