Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #14 from pjanouse/JENKINS-38412
[JENKINS-38412] Fixed waiting run starvation
  • Loading branch information
scoheb committed Oct 12, 2016
2 parents bc170d4 + 1738418 commit 650612d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/java/com/redhat/foreman/ForemanSharedNodeCloud.java
Expand Up @@ -163,8 +163,15 @@ public boolean canProvision(Label label) {
}
Set<Map.Entry<String, String>> hosts = hostsMap.entrySet();
for (Map.Entry<String, String> host: hosts) {
if (label == null || label.matches(Label.parse(hostsMap.get(host.getKey())))) {
return true;
try {
if ((label == null && Label.parse(hostsMap.get(host.getKey())).isEmpty())
|| (label != null && label.matches(Label.parse(hostsMap.get(host.getKey()))))) {
return true;
}
} catch (Exception e) {
LOGGER.error(e);
e.printStackTrace();
continue;
}
}
return false;
Expand Down Expand Up @@ -316,13 +323,14 @@ private String getHostToReserve(Label label) {
for (Map.Entry<String, String> host: hosts) {
try {
if (getForemanAPI().isHostFree(host.getKey())
&& (label == null || label.matches(Label.parse(hostsMap.get(host.getKey()))))) {
&& ((label == null && Label.parse(hostsMap.get(host.getKey())).isEmpty())
|| (label != null && label.matches(Label.parse(hostsMap.get(host.getKey())))))) {
return host.getKey();
}
} catch (Exception e){
LOGGER.error("Unhandled exception in getHostToReserve: ", e);
e.printStackTrace();
return null;
continue;
}
}
return null;
Expand Down

0 comments on commit 650612d

Please sign in to comment.