Skip to content

Commit

Permalink
Support SSD / premium SSD managed disks (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
timja committed Apr 4, 2021
1 parent bb9943c commit bdb82c5
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 21 deletions.
28 changes: 19 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@
<gitHubRepo>jenkinsci/azure-vm-agents-plugin</gitHubRepo>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<azuresdk.version>1.19.0</azuresdk.version>
<azuresdk.version>1.41.0</azuresdk.version>
<azure-storage.version>6.1.0</azure-storage.version>
<jackson.version>2.10.2</jackson.version>
<jenkins.version>2.266</jenkins.version>
<java.level>8</java.level>
<findbugs.failOnError>true</findbugs.failOnError>
<findbugs.excludeFilterFile>findbugs-exclude.xml</findbugs.excludeFilterFile>
<maven.javadoc.skip>true</maven.javadoc.skip>
<azure-credentials.version>1.6.1</azure-credentials.version>
<azure-credentials.version>177.v816b81058012</azure-credentials.version>
<azure-commons.version>1.1.2</azure-commons.version>
<guava.version>24.1.1-jre</guava.version>
</properties>
Expand All @@ -77,12 +76,12 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-annotations</artifactId>
<version>1.8.0</version>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
Expand Down Expand Up @@ -134,7 +133,7 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-client-runtime</artifactId>
<version>1.5.4</version>
<version>1.7.12</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down Expand Up @@ -168,16 +167,27 @@
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>azure-commons-core</artifactId>
<version>${azure-commons.version}</version>
<exclusions>
<exclusion>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
<version>0.1.55.2</version>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>oauth2-oidc-sdk</artifactId>
<version>7.4</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
Expand Down Expand Up @@ -206,7 +216,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cloud-stats</artifactId>
<version>0.22</version>
<version>0.27</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.microsoft.azure.PagedList;
import com.microsoft.azure.management.Azure;
import com.microsoft.azure.management.compute.AvailabilitySet;
import com.microsoft.azure.management.compute.DiskSkuTypes;
import com.microsoft.azure.management.storage.SkuName;
import com.microsoft.azure.management.storage.StorageAccount;
import com.microsoft.azure.vmagent.builders.AdvancedImage;
Expand Down Expand Up @@ -262,6 +263,8 @@ public int hashCode() {

private String storageAccountType;

private String osDiskStorageAccountType;

private final int noOfParallelJobs;

private Node.Mode usageMode;
Expand Down Expand Up @@ -841,6 +844,18 @@ public String getStorageAccountType() {
return StringUtils.isBlank(storageAccountType) ? SkuName.STANDARD_LRS.toString() : storageAccountType;
}

public String getOsDiskStorageAccountType() {
if (StringUtils.isBlank(osDiskStorageAccountType)) {
return getStorageAccountType();
}
return osDiskStorageAccountType;
}

@DataBoundSetter
public void setOsDiskStorageAccountType(String osDiskStorageAccountType) {
this.osDiskStorageAccountType = osDiskStorageAccountType;
}

public String getStorageAccountName() {
return storageAccountName;
}
Expand Down Expand Up @@ -1357,9 +1372,7 @@ public ListBoxModel doFillAvailabilitySetItems(
return model;
}

public ListBoxModel doFillStorageAccountTypeItems(
@QueryParameter String virtualMachineSize)
throws IOException, ServletException {
public ListBoxModel doFillStorageAccountTypeItems(@QueryParameter String virtualMachineSize) {

ListBoxModel model = new ListBoxModel();
model.add("--- Select Storage Account Type ---", "");
Expand All @@ -1373,6 +1386,21 @@ public ListBoxModel doFillStorageAccountTypeItems(
return model;
}

public ListBoxModel doFillOsDiskStorageAccountTypeItems(@QueryParameter String virtualMachineSize) {

ListBoxModel model = new ListBoxModel();
model.add("--- Select Storage Account Type ---", "");

model.add(DiskSkuTypes.STANDARD_LRS.toString());
model.add(DiskSkuTypes.STANDARD_SSD_LRS.toString());

/*As introduced in Azure Docs, the size contains 'S' supports premium storage*/
if (virtualMachineSize.matches(".*_[a-zA-Z]([0-9]+[Mm]?[Ss]|[Ss][0-9]+).*")) {
model.add(DiskSkuTypes.PREMIUM_LRS.toString());
}
return model;
}


public ListBoxModel doFillUsageModeItems() throws IOException, ServletException {
ListBoxModel model = new ListBoxModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ public AzureVMDeploymentInfo createDeployment(
putVariable(tmp, "jenkinsTag", Constants.AZURE_JENKINS_TAG_VALUE);
putVariable(tmp, "resourceTag", deploymentRegistrar.getDeploymentTag().get());
putVariable(tmp, "cloudTag", cloudName);
putVariable(tmp, "osDiskStorageAccountType", template.getOsDiskStorageAccountType());

// add purchase plan for image if needed in reference configuration
// Image Configuration has four choices, isBasic->Built-in Image, useCustomImage->Custom User Image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
<f:select/>
</f:entry>

<f:entry title="${%OS disk storage account type}" field="osDiskStorageAccountType">
<f:select/>
</f:entry>

<f:entry title="${%Use_Ephemeral_OS_Disk}" field="ephemeralOSDisk">
<f:checkbox/>
</f:entry>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ noOfParallelJobs=Number of Executors

Image_Configuration=Image Configuration
Disk_Type=Choose disks type
Use_Ephemeral_OS_Disk=Use Ephemeral OS Disk
Use_Ephemeral_OS_Disk=Use Ephemeral OS disk
OS_Disk_Size=OS disk size in GB (Optional)
Retention_Strategy=Retention Strategy

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Specifies the storage account type for the managed disk.

This setting only applies if you are using managed disks (recommended).
2 changes: 1 addition & 1 deletion src/main/resources/customImageTemplateWithManagedDisk.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"caching": "[if(bool(variables('ephemeralOSDisk')), 'ReadOnly', json('null'))]",
"diffDiskSettings": "[if(bool(variables('ephemeralOSDisk')), json('{\"option\": \"Local\"}'), json('null'))]",
"managedDisk": {
"storageAccountType": "[variables('storageAccountType')]"
"storageAccountType": "[variables('osDiskStorageAccountType')]"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"caching": "[if(bool(variables('ephemeralOSDisk')), 'ReadOnly', json('null'))]",
"diffDiskSettings": "[if(bool(variables('ephemeralOSDisk')), json('{\"option\": \"Local\"}'), json('null'))]",
"managedDisk": {
"storageAccountType": "[variables('storageAccountType')]"
"storageAccountType": "[variables('osDiskStorageAccountType')]"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"caching": "[if(bool(variables('ephemeralOSDisk')), 'ReadOnly', json('null'))]",
"diffDiskSettings": "[if(bool(variables('ephemeralOSDisk')), json('{\"option\": \"Local\"}'), json('null'))]",
"managedDisk": {
"storageAccountType": "[variables('storageAccountType')]"
"storageAccountType": "[variables('osDiskStorageAccountType')]"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"caching": "[if(bool(variables('ephemeralOSDisk')), 'ReadOnly', json('null'))]",
"diffDiskSettings": "[if(bool(variables('ephemeralOSDisk')), json('{\"option\": \"Local\"}'), json('null'))]",
"managedDisk": {
"storageAccountType": "[variables('storageAccountType')]"
"storageAccountType": "[variables('osDiskStorageAccountType')]"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"caching": "[if(bool(variables('ephemeralOSDisk')), 'ReadOnly', json('null'))]",
"diffDiskSettings": "[if(bool(variables('ephemeralOSDisk')), json('{\"option\": \"Local\"}'), json('null'))]",
"managedDisk": {
"storageAccountType": "[variables('storageAccountType')]"
"storageAccountType": "[variables('osDiskStorageAccountType')]"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"caching": "[if(bool(variables('ephemeralOSDisk')), 'ReadOnly', json('null'))]",
"diffDiskSettings": "[if(bool(variables('ephemeralOSDisk')), json('{\"option\": \"Local\"}'), json('null'))]",
"managedDisk": {
"storageAccountType": "[variables('storageAccountType')]"
"storageAccountType": "[variables('osDiskStorageAccountType')]"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion src/main/webapp/help-storageAccountType.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<div>
Choose the type of storage<br><br>
Choose the type of storage.<br><br>

Premium Storage is available in most regions. DS-series, DSV2-series, GS-series, and Fs-series VMs are supported.<br><br>

Whenever using managed disk, please choose Standard_LRS to avoid huge costs.

Set 'OS Disk Storage Account Type' when using a managed disk to get a better performing disk.
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public void createDeploymentWithAvailabilitySet() throws Exception {
.withExistingResourceGroup(testEnv.azureResourceGroup)
.withFaultDomainCount(2)
.withUpdateDomainCount(4)
.withSku(AvailabilitySetSkuTypes.MANAGED)
.withSku(AvailabilitySetSkuTypes.ALIGNED)
.create();
Assert.assertNotNull("Failed to create availability set in resourceGroup " + testEnv.azureResourceGroup, availabilitySet);
testEnv.availabilityType = AvailabilityType.AVAILABILITY_SET.getName();
Expand Down

0 comments on commit bdb82c5

Please sign in to comment.