Added additional checks for null label
This commit is contained in:
parent
505d414aff
commit
c1248683b7
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
/bin
|
||||
/target
|
||||
/work
|
||||
|
||||
*.idea
|
||||
*.settings
|
||||
|
@ -215,7 +215,7 @@ public class AzureCloud extends Cloud {
|
||||
LOGGER.info("Azure Cloud: provision: slave node "+slaveNode.getLabelString());
|
||||
LOGGER.info("Azure Cloud: provision: slave template "+slaveTemplate.getLabels());
|
||||
|
||||
if (!slaveNode.isDeleteSlave() && slaveNode.getLabelString().equalsIgnoreCase(slaveTemplate.getLabels())) {
|
||||
if (isNodeEligibleForReuse(slaveNode, slaveTemplate)) {
|
||||
try {
|
||||
if(AzureManagementServiceDelegate.isVirtualMachineExists(slaveNode)) {
|
||||
LOGGER.info("Found existing node, starting VM "+slaveNode.getNodeName());
|
||||
@ -317,6 +317,28 @@ public class AzureCloud extends Cloud {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if node configuration matches with template definition.
|
||||
*/
|
||||
private static boolean isNodeEligibleForReuse(AzureSlave slaveNode, AzureSlaveTemplate slaveTemplate) {
|
||||
|
||||
// Do not reuse slave if it is marked for deletion.
|
||||
if (slaveNode.isDeleteSlave()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for null label and mode.
|
||||
if (AzureUtil.isNull(slaveNode.getLabelString()) && (slaveNode.getMode() == Node.Mode.NORMAL)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (AzureUtil.isNotNull(slaveNode.getLabelString()) &&slaveNode.getLabelString().equalsIgnoreCase(slaveTemplate.getLabels())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void markSlaveForDeletion(AzureSlave slave, String message) {
|
||||
slave.setTemplateStatus(Constants.TEMPLATE_STATUS_DISBALED, message);
|
||||
if (slave.toComputer() != null) {
|
||||
|
@ -1536,11 +1536,6 @@ public class AzureManagementServiceDelegate {
|
||||
return errors;
|
||||
}
|
||||
|
||||
//Verify labels
|
||||
if (isNullOrEmpty(labels)) {
|
||||
errors.add(Messages.Azure_GC_Template_Label_Null_Or_Empty());
|
||||
}
|
||||
|
||||
//Verify number of parallel jobs
|
||||
if (returnOnSingleError) {
|
||||
validationResult = verifyNoOfExecutors(noOfParallelJobs);
|
||||
|
@ -32,7 +32,6 @@ Azure_GC_Template_JNLP_Not_Supported=The JNLP launch method is supported only fo
|
||||
Azure_GC_Template_UN_Null_Or_Empty=Missing admin user name.
|
||||
Azure_GC_Template_PWD_Null_Or_Empty=Missing admin password.
|
||||
Azure_GC_Template_PWD_Not_Valid=Not a valid password. Refer to the rules in the help.
|
||||
Azure_GC_Template_Label_Null_Or_Empty=Missing labels. Refer to the help for the details.
|
||||
Azure_GC_Template_VirtualNetwork_Null_Or_Empty=Missing virtual network name.
|
||||
Azure_GC_Template_VirtualNetwork_NotFound=The virtual network {0} does not exist in this subscription.
|
||||
Azure_GC_Template_subnet_NotFound=The subnet {0} does not belong to the specified virtual network.
|
||||
|
Loading…
Reference in New Issue
Block a user