Source:
public synchronized Collection<NodeProvisioner.PlannedNode> provision(@CheckForNull final Label label, final int excessWorkload) { try { Set<String> allInProvisioning = InProvisioning.getAllInProvisioning(label); LOGGER.log(Level.FINE, () -> "In provisioning : " + allInProvisioning); int toBeProvisioned = Math.max(0, excessWorkload - allInProvisioning.size()); LOGGER.log(Level.INFO, "Excess workload after pending Kubernetes agents: {0}", toBeProvisioned); List<NodeProvisioner.PlannedNode> plannedNodes = new ArrayList<>(); for (PodTemplate podTemplate: getTemplatesFor(label)) { LOGGER.log(Level.INFO, "Template for label {0}: {1}", new Object[] { label, podTemplate.getName() }); for (int i = 0; i < toBeProvisioned; i++) { if (!addProvisionedSlave(podTemplate, label, i, allInProvisioning.size())) { break; } plannedNodes.add(PlannedNodeBuilderFactory.createInstance().cloud(this).template(podTemplate).label(label).build()); } LOGGER.log(Level.FINEST, "Planned Kubernetes agents for template \"{0}\": {1}", new Object[] { podTemplate.getName(), plannedNodes.size() }); if (plannedNodes.size() > 0) { return plannedNodes; } } return plannedNodes; } catch (KubernetesClientException e) { Throwable cause = e.getCause(); if (cause instanceof SocketTimeoutException || cause instanceof ConnectException || cause instanceof UnknownHostException) { LOGGER.log(Level.WARNING, "Failed to connect to Kubernetes at {0}: {1}", new String[] { serverUrl, cause.getMessage() }); } else { LOGGER.log(Level.WARNING, "Failed to count the # of live instances on Kubernetes", cause != null ? cause : e); } } catch (ConnectException e) { LOGGER.log(Level.WARNING, "Failed to connect to Kubernetes at {0}", serverUrl); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to count the # of live instances on Kubernetes", e); } return Collections.emptyList(); }

Target:
public synchronized Collection<NodeProvisioner.PlannedNode> provision(@CheckForNull final Label label, final int excessWorkload) { try { Set<String> allInProvisioning = InProvisioning.getAllInProvisioning(label); LOGGER.log(Level.FINE, () -> "In provisioning : " + allInProvisioning); int toBeProvisioned = Math.max(0, excessWorkload - allInProvisioning.size()); LOGGER.log(Level.INFO, "Excess workload after pending Kubernetes agents: {0}", toBeProvisioned); List<NodeProvisioner.PlannedNode> plannedNodes = new ArrayList<>(); for (PodTemplate podTemplate: getTemplatesFor(label)) { LOGGER.log(Level.INFO, "Template for label {0}: {1}", new Object[] { label, podTemplate.getName() }); for (int i = 0; i < toBeProvisioned; i++) { if (!addProvisionedSlave(podTemplate, label, i + allInProvisioning.size())) { break; } plannedNodes.add(PlannedNodeBuilderFactory.createInstance().cloud(this).template(podTemplate).label(label).build()); } LOGGER.log(Level.FINEST, "Planned Kubernetes agents for template \"{0}\": {1}", new Object[] { podTemplate.getName(), plannedNodes.size() }); if (plannedNodes.size() > 0) { return plannedNodes; } } return plannedNodes; } catch (KubernetesClientException e) { Throwable cause = e.getCause(); if (cause instanceof SocketTimeoutException || cause instanceof ConnectException || cause instanceof UnknownHostException) { LOGGER.log(Level.WARNING, "Failed to connect to Kubernetes at {0}: {1}", new String[] { serverUrl, cause.getMessage() }); } else { LOGGER.log(Level.WARNING, "Failed to count the # of live instances on Kubernetes", cause != null ? cause : e); } } catch (ConnectException e) { LOGGER.log(Level.WARNING, "Failed to connect to Kubernetes at {0}", serverUrl); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to count the # of live instances on Kubernetes", e); } return Collections.emptyList(); }