@Test public void testResolver() { String node1Name = "node1"; String node2Name = "node2"; V1Node node1 = newNode(node1Name); V1Node node2 = newNode(node2Name); KubeApiFacade kubeApiFacade = TestDataFactory.mockKubeApiFacade(node1, node2); KubernetesNodeDataResolver resolver = new KubernetesNodeDataResolver(configuration, kubeApiFacade, node -> true); Map<String, Node> resolved = resolver.resolve(); assertThat(resolved).hasSize(2); assertThat(resolver.resolve().get(node1Name).isRelocationRequired()).isFalse(); assertThat(resolver.resolve().get(node1Name).isRelocationRequiredImmediately()).isFalse(); assertThat(resolver.resolve().get(node1Name).isRelocationNotAllowed()).isFalse(); assertThat(resolver.resolve().get(node1Name).isInBadCondition()).isFalse(); addNodeTaint(node1, "required.titus.com/decommissioning", "true", TAINT_EFFECT_NO_EXECUTE); node1.getMetadata().getLabels().put(RelocationAttributes.RELOCATION_REQUIRED, "true"); assertThat(resolver.resolve().get(node1Name).isRelocationRequired()).isTrue(); assertThat(resolver.resolve().get(node1Name).isRelocationRequiredImmediately()).isFalse(); assertThat(resolver.resolve().get(node1Name).isRelocationNotAllowed()).isFalse(); addNodeTaint(node1, "immediately.titus.com/decommissioning", "true", TAINT_EFFECT_NO_EXECUTE); assertThat(resolver.resolve().get(node1Name).isRelocationRequiredImmediately()).isTrue(); assertThat(resolver.resolve().get(node1Name).isRelocationNotAllowed()).isFalse(); addNodeCondition(node2, "CorrectableMemoryFailure", "True"); assertThat(resolver.resolve().get(node2Name)).isNotNull(); assertThat(resolver.resolve().get(node2Name).isInBadCondition()).isTrue(); addNodeCondition(node1, "CorrectableMemoryFailure", "False"); assertThat(resolver.resolve().get(node1Name)).isNotNull(); assertThat(resolver.resolve().get(node1Name).isInBadCondition()).isFalse(); }
@Override public Map<String, Node> resolve() { List<V1Node> k8sNodes = nodeInformer.getIndexer().list().stream().filter(nodeFilter).collect(Collectors.toList()); Map<String, Node> result = new HashMap<>(); k8sNodes.forEach(k8Node -> toReconcilerNode(k8Node).ifPresent(node -> result.put(node.getId(), node))); return result; }
KubernetesNodeDataResolver implements NodeDataResolver { @Override public Map<String, Node> resolve() { List<V1Node> k8sNodes = nodeInformer.getIndexer().list().stream().filter(nodeFilter).collect(Collectors.toList()); Map<String, Node> result = new HashMap<>(); k8sNodes.forEach(k8Node -> toReconcilerNode(k8Node).ifPresent(node -> result.put(node.getId(), node))); return result; } }
KubernetesNodeDataResolver implements NodeDataResolver { @Override public Map<String, Node> resolve() { List<V1Node> k8sNodes = nodeInformer.getIndexer().list().stream().filter(nodeFilter).collect(Collectors.toList()); Map<String, Node> result = new HashMap<>(); k8sNodes.forEach(k8Node -> toReconcilerNode(k8Node).ifPresent(node -> result.put(node.getId(), node))); return result; } KubernetesNodeDataResolver(RelocationConfiguration configuration,
                                      KubeApiFacade kubeApiFacade,
                                      Predicate<V1Node> nodeFilter); }
KubernetesNodeDataResolver implements NodeDataResolver { @Override public Map<String, Node> resolve() { List<V1Node> k8sNodes = nodeInformer.getIndexer().list().stream().filter(nodeFilter).collect(Collectors.toList()); Map<String, Node> result = new HashMap<>(); k8sNodes.forEach(k8Node -> toReconcilerNode(k8Node).ifPresent(node -> result.put(node.getId(), node))); return result; } KubernetesNodeDataResolver(RelocationConfiguration configuration,
                                      KubeApiFacade kubeApiFacade,
                                      Predicate<V1Node> nodeFilter); @Override Map<String, Node> resolve(); @Override long getStalenessMs(); }
KubernetesNodeDataResolver implements NodeDataResolver { @Override public Map<String, Node> resolve() { List<V1Node> k8sNodes = nodeInformer.getIndexer().list().stream().filter(nodeFilter).collect(Collectors.toList()); Map<String, Node> result = new HashMap<>(); k8sNodes.forEach(k8Node -> toReconcilerNode(k8Node).ifPresent(node -> result.put(node.getId(), node))); return result; } KubernetesNodeDataResolver(RelocationConfiguration configuration,
                                      KubeApiFacade kubeApiFacade,
                                      Predicate<V1Node> nodeFilter); @Override Map<String, Node> resolve(); @Override long getStalenessMs();  }