Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix null pointer exceptions. #89

Merged
merged 1 commit into from
Nov 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -586,19 +586,22 @@ private boolean addProvisionedSlave(PodTemplate template, Label label) throws Ex

KubernetesClient client = connect();
PodList slaveList = client.pods().withLabels(POD_LABEL).list();
List<Pod> slaveListItems = slaveList.getItems();

Map<String, String> labelsMap = getLabelsMap(template.getLabelSet());
PodList namedList = client.pods().withLabels(labelsMap).list();
List<Pod> namedListItems = namedList.getItems();

if (containerCap < slaveList.getItems().size()) {
if (slaveListItems != null && containerCap < slaveListItems.size()) {
LOGGER.log(Level.INFO, "Total container cap of {0} reached, not provisioning: {1} running in namespace {2}",
new Object[] { containerCap, slaveList.getItems().size(), client.getNamespace() });
new Object[] { containerCap, slaveListItems.size(), client.getNamespace() });
return false;
}

if (template.getInstanceCap() < namedList.getItems().size()) {
if (namedListItems != null && slaveListItems != null && template.getInstanceCap() < namedListItems.size()) {
LOGGER.log(Level.INFO,
"Template instance cap of {0} reached for template {1}, not provisioning: {2} running in namespace {3} with label {4}",
new Object[] { template.getInstanceCap(), template.getName(), slaveList.getItems().size(),
new Object[] { template.getInstanceCap(), template.getName(), slaveListItems.size(),
client.getNamespace(), label.toString() });
return false; // maxed out
}
Expand Down