Skip to content

Commit

Permalink
Batch Track 2 SDK for 2024-07-01 API (#42545)
Browse files Browse the repository at this point in the history
* Generate Java SDK from new TypeSpec

* Add force parameter to options where needed

* Add spelling exception

* Update SDK generation

* Fix FileProperties serialization

* Add options bag methods to sync and async client

* Add new unit test coverage

* Fix FileProperties contentLength serialization

* Update Pool Test

* Regenerate SDK

* Add Javadoc comment

* Fix spotless violations

* Updated test recordings

* Update changelog and README for release

* Update sdk/batch/azure-compute-batch/CHANGELOG.md

Co-authored-by: Alan Zimmer <48699787+alzimmermsft@users.noreply.github.com>

---------

Co-authored-by: Alan Zimmer <48699787+alzimmermsft@users.noreply.github.com>
  • Loading branch information
skapur12 and alzimmermsft authored Oct 31, 2024
1 parent 7554add commit 71409ca
Show file tree
Hide file tree
Showing 57 changed files with 6,749 additions and 1,571 deletions.
3 changes: 2 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@
"VMSS",
"reimaged",
"isdirectory",
"SSDLRS"
"SSDLRS",
"VMGUEST"
]
},
{
Expand Down
28 changes: 24 additions & 4 deletions sdk/batch/azure-compute-batch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# Release History

## 1.0.0-beta.3 (Unreleased)
## 1.0.0-beta.3 (2024-10-31)

### Features Added

### Breaking Changes
- Force delete/terminate job or job schedule:
- Added `force` parameter of type Boolean to `DeleteBatchJobOptions`, `TerminateBatchJobOptions`, `DeleteBatchJobScheduleOptions`, and `TerminateBatchJobScheduleOptions`.

### Bugs Fixed
- Support for compute node start/deallocate operations:
- Added `startNode(poolId, nodeId)` and `deallocateNode(poolId, nodeId)` methods to `BatchClient` and `BatchAsyncClient`, along with the options for those methods: `StartBatchNodeOptions` and `DeallocateBatchNodeOptions`.

### Other Changes
- Container task data mount isolation:
- Added `containerHostBatchBindMounts` of type `List<ContainerHostBatchBindMountEntry>` to `BatchTaskContainerSettings`.

- Patch improvements for pool and job:
- Added `displayName`, `vmSize`, `taskSlotsPerNode`, `taskSchedulingPolicy`, `enableInterNodeCommunication`, `virtualMachineConfiguration`, `networkConfiguration`, `userAccounts`, `mountConfiguration`, `upgradePolicy`, and `resourceTags` to `BatchPoolUpdateContent`.
- Added `networkConfiguration` to `BatchJobUpdateContent`.

- Confidential VM support:
- Added `confidentialVM` to `SecurityTypes`.
- Added `securityProfile` of type `VMDiskSecurityProfile` to `ManagedDisk`.

- Support for shared and community gallery images:
- Added `sharedGalleryImageId` and `communityGalleryImageId` to `ImageReference`.

### Breaking Changes

- Removed `getNodeRemoteDesktop(poolId, nodeId)` method from `BatchClient` and `BatchAsyncClient`. Use `getNodeRemoteLoginSettings(poolId, nodeId)` instead to remotely login to a compute node.
- Removed `CloudServiceConfiguration` from pool models and operations. Use `VirtualMachineConfiguration` when creating pools.
- Removed `ApplicationLicenses` from pool models and operations.

## 1.0.0-beta.2 (2024-05-22)

Expand Down
2 changes: 1 addition & 1 deletion sdk/batch/azure-compute-batch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Various documentation is available to help you get started
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-compute-batch</artifactId>
<version>1.0.0-beta.1</version>
<version>1.0.0-beta.3</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion sdk/batch/azure-compute-batch/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/batch/azure-compute-batch",
"Tag": "java/batch/azure-compute-batch_f58320abba"
"Tag": "java/batch/azure-compute-batch_ead064573c"
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
*/
public enum BatchServiceVersion implements ServiceVersion {
/**
* Enum value 2024-02-01.19.0.
* Enum value 2024-07-01.20.0.
*/
V2024_02_01_19_0("2024-02-01.19.0");
V2024_07_01_20_0("2024-07-01.20.0");

private final String version;

Expand All @@ -35,6 +35,6 @@ public String getVersion() {
* @return The latest {@link BatchServiceVersion}.
*/
public static BatchServiceVersion getLatest() {
return V2024_02_01_19_0;
return V2024_07_01_20_0;
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public AutomaticOsUpgradePolicy setOsRollingUpgradeDeferral(Boolean osRollingUpg
/*
* Indicates whether OS upgrades should automatically be applied to scale set instances in a rolling fashion when a
* newer version of the OS image becomes available. <br /><br /> If this is set to true for Windows based pools,
* [WindowsConfiguration.enableAutomaticUpdates](https://learn.microsoft.com/en-us/rest/api/batchservice/pool/add?
* tabs=HTTP#windowsconfiguration) cannot be set to true.
* [WindowsConfiguration.enableAutomaticUpdates](https://learn.microsoft.com/rest/api/batchservice/pool/add?tabs=
* HTTP#windowsconfiguration) cannot be set to true.
*/
@Generated
private Boolean enableAutomaticOsUpgrade;
Expand All @@ -124,7 +124,7 @@ public AutomaticOsUpgradePolicy setOsRollingUpgradeDeferral(Boolean osRollingUpg
* Get the enableAutomaticOsUpgrade property: Indicates whether OS upgrades should automatically be applied to scale
* set instances in a rolling fashion when a newer version of the OS image becomes available. &lt;br /&gt;&lt;br
* /&gt; If this is set to true for Windows based pools,
* [WindowsConfiguration.enableAutomaticUpdates](https://learn.microsoft.com/en-us/rest/api/batchservice/pool/add?tabs=HTTP#windowsconfiguration)
* [WindowsConfiguration.enableAutomaticUpdates](https://learn.microsoft.com/rest/api/batchservice/pool/add?tabs=HTTP#windowsconfiguration)
* cannot be set to true.
*
* @return the enableAutomaticOsUpgrade value.
Expand All @@ -138,7 +138,7 @@ public Boolean isEnableAutomaticOsUpgrade() {
* Set the enableAutomaticOsUpgrade property: Indicates whether OS upgrades should automatically be applied to scale
* set instances in a rolling fashion when a newer version of the OS image becomes available. &lt;br /&gt;&lt;br
* /&gt; If this is set to true for Windows based pools,
* [WindowsConfiguration.enableAutomaticUpdates](https://learn.microsoft.com/en-us/rest/api/batchservice/pool/add?tabs=HTTP#windowsconfiguration)
* [WindowsConfiguration.enableAutomaticUpdates](https://learn.microsoft.com/rest/api/batchservice/pool/add?tabs=HTTP#windowsconfiguration)
* cannot be set to true.
*
* @param enableAutomaticOsUpgrade the enableAutomaticOsUpgrade value to set.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public final class BatchJob implements JsonSerializable<BatchJob> {
private BatchJobExecutionInfo executionInfo;

/*
* Resource usage statistics for the entire lifetime of the Job. This property is populated only if the CloudJob was
* Resource usage statistics for the entire lifetime of the Job. This property is populated only if the BatchJob was
* retrieved with an expand clause including the 'stats' attribute; otherwise it is null. The statistics may not be
* immediately available. The Batch service performs periodic roll-up of statistics. The typical delay is about 30
* minutes.
Expand Down Expand Up @@ -567,7 +567,7 @@ public BatchJobExecutionInfo getExecutionInfo() {

/**
* Get the stats property: Resource usage statistics for the entire lifetime of the Job. This property is populated
* only if the CloudJob was retrieved with an expand clause including the 'stats' attribute; otherwise it is null.
* only if the BatchJob was retrieved with an expand clause including the 'stats' attribute; otherwise it is null.
* The statistics may not be immediately available. The Batch service performs periodic roll-up of statistics. The
* typical delay is about 30 minutes.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public final class BatchJobManagerTask implements JsonSerializable<BatchJobManag
* features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or
* "/bin/sh -c MyCommand" in Linux. If the command line refers to file paths, it should use a relative path
* (relative to the Task working directory), or use the Batch provided environment variable
* (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).
* (https://docs.microsoft.com/azure/batch/batch-compute-node-environment-variables).
*/
@Generated
private final String commandLine;
Expand Down Expand Up @@ -229,7 +229,7 @@ public BatchJobManagerTask setDisplayName(String displayName) {
* to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c
* MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command line refers to file paths, it should use
* a relative path (relative to the Task working directory), or use the Batch provided environment variable
* (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).
* (https://docs.microsoft.com/azure/batch/batch-compute-node-environment-variables).
*
* @return the commandLine value.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,50 +19,40 @@ public final class BatchJobNetworkConfiguration implements JsonSerializable<Batc

/*
* The ARM resource identifier of the virtual network subnet which Compute Nodes running Tasks from the Job will
* join for the duration of the Task. This will only work with a VirtualMachineConfiguration Pool. The virtual
* network must be in the same region and subscription as the Azure Batch Account. The specified subnet should have
* enough free IP addresses to accommodate the number of Compute Nodes which will run Tasks from the Job. This can
* be up to the number of Compute Nodes in the Pool. The 'MicrosoftAzureBatch' service principal must have the
* 'Classic Virtual Machine Contributor' Role-Based Access Control (RBAC) role for the specified VNet so that Azure
* Batch service can schedule Tasks on the Nodes. This can be verified by checking if the specified VNet has any
* associated Network Security Groups (NSG). If communication to the Nodes in the specified subnet is denied by an
* NSG, then the Batch service will set the state of the Compute Nodes to unusable. This is of the form
* join for the duration of the Task. The virtual network must be in the same region and subscription as the Azure
* Batch Account. The specified subnet should have enough free IP addresses to accommodate the number of Compute
* Nodes which will run Tasks from the Job. This can be up to the number of Compute Nodes in the Pool. The
* 'MicrosoftAzureBatch' service principal must have the 'Classic Virtual Machine Contributor' Role-Based Access
* Control (RBAC) role for the specified VNet so that Azure Batch service can schedule Tasks on the Nodes. This can
* be verified by checking if the specified VNet has any associated Network Security Groups (NSG). If communication
* to the Nodes in the specified subnet is denied by an NSG, then the Batch service will set the state of the
* Compute Nodes to unusable. This is of the form
* /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{
* subnet}. If the specified VNet has any associated Network Security Groups (NSG), then a few reserved system ports
* must be enabled for inbound communication from the Azure Batch service. For Pools created with a Virtual Machine
* configuration, enable ports 29876 and 29877, as well as port 22 for Linux and port 3389 for Windows. Port 443 is
* also required to be open for outbound connections for communications to Azure Storage. For more details see:
* https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
* https://docs.microsoft.com/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
*/
@Generated
private final String subnetId;

/**
* Creates an instance of BatchJobNetworkConfiguration class.
*
* @param subnetId the subnetId value to set.
*/
@Generated
public BatchJobNetworkConfiguration(String subnetId) {
this.subnetId = subnetId;
}

/**
* Get the subnetId property: The ARM resource identifier of the virtual network subnet which Compute Nodes running
* Tasks from the Job will join for the duration of the Task. This will only work with a VirtualMachineConfiguration
* Pool. The virtual network must be in the same region and subscription as the Azure Batch Account. The specified
* subnet should have enough free IP addresses to accommodate the number of Compute Nodes which will run Tasks from
* the Job. This can be up to the number of Compute Nodes in the Pool. The 'MicrosoftAzureBatch' service principal
* must have the 'Classic Virtual Machine Contributor' Role-Based Access Control (RBAC) role for the specified VNet
* so that Azure Batch service can schedule Tasks on the Nodes. This can be verified by checking if the specified
* VNet has any associated Network Security Groups (NSG). If communication to the Nodes in the specified subnet is
* denied by an NSG, then the Batch service will set the state of the Compute Nodes to unusable. This is of the form
* Tasks from the Job will join for the duration of the Task. The virtual network must be in the same region and
* subscription as the Azure Batch Account. The specified subnet should have enough free IP addresses to accommodate
* the number of Compute Nodes which will run Tasks from the Job. This can be up to the number of Compute Nodes in
* the Pool. The 'MicrosoftAzureBatch' service principal must have the 'Classic Virtual Machine Contributor'
* Role-Based Access Control (RBAC) role for the specified VNet so that Azure Batch service can schedule Tasks on
* the Nodes. This can be verified by checking if the specified VNet has any associated Network Security Groups
* (NSG). If communication to the Nodes in the specified subnet is denied by an NSG, then the Batch service will set
* the state of the Compute Nodes to unusable. This is of the form
* /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.
* If the specified VNet has any associated Network Security Groups (NSG), then a few reserved system ports must be
* enabled for inbound communication from the Azure Batch service. For Pools created with a Virtual Machine
* configuration, enable ports 29876 and 29877, as well as port 22 for Linux and port 3389 for Windows. Port 443 is
* also required to be open for outbound connections for communications to Azure Storage. For more details see:
* https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
* https://docs.microsoft.com/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
*
* @return the subnetId value.
*/
Expand All @@ -79,6 +69,7 @@ public String getSubnetId() {
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("subnetId", this.subnetId);
jsonWriter.writeBooleanField("skipWithdrawFromVNet", this.skipWithdrawFromVNet);
return jsonWriter.writeEndObject();
}

Expand All @@ -95,16 +86,51 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
public static BatchJobNetworkConfiguration fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
String subnetId = null;
boolean skipWithdrawFromVNet = false;
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("subnetId".equals(fieldName)) {
subnetId = reader.getString();
} else if ("skipWithdrawFromVNet".equals(fieldName)) {
skipWithdrawFromVNet = reader.getBoolean();
} else {
reader.skipChildren();
}
}
return new BatchJobNetworkConfiguration(subnetId);
return new BatchJobNetworkConfiguration(subnetId, skipWithdrawFromVNet);
});
}

/*
* Whether to withdraw Compute Nodes from the virtual network to DNC when the job is terminated or deleted. If true,
* nodes will remain joined to the virtual network to DNC. If false, nodes will automatically withdraw when the job
* ends. Defaults to false.
*/
@Generated
private final boolean skipWithdrawFromVNet;

/**
* Creates an instance of BatchJobNetworkConfiguration class.
*
* @param subnetId the subnetId value to set.
* @param skipWithdrawFromVNet the skipWithdrawFromVNet value to set.
*/
@Generated
public BatchJobNetworkConfiguration(String subnetId, boolean skipWithdrawFromVNet) {
this.subnetId = subnetId;
this.skipWithdrawFromVNet = skipWithdrawFromVNet;
}

/**
* Get the skipWithdrawFromVNet property: Whether to withdraw Compute Nodes from the virtual network to DNC when the
* job is terminated or deleted. If true, nodes will remain joined to the virtual network to DNC. If false, nodes
* will automatically withdraw when the job ends. Defaults to false.
*
* @return the skipWithdrawFromVNet value.
*/
@Generated
public boolean isSkipWithdrawFromVNet() {
return this.skipWithdrawFromVNet;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public final class BatchJobPreparationTask implements JsonSerializable<BatchJobP
* features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or
* "/bin/sh -c MyCommand" in Linux. If the command line refers to file paths, it should use a relative path
* (relative to the Task working directory), or use the Batch provided environment variable
* (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).
* (https://docs.microsoft.com/azure/batch/batch-compute-node-environment-variables).
*/
@Generated
private final String commandLine;
Expand Down Expand Up @@ -176,7 +176,7 @@ public BatchJobPreparationTask setId(String id) {
* to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c
* MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command line refers to file paths, it should use
* a relative path (relative to the Task working directory), or use the Batch provided environment variable
* (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).
* (https://docs.microsoft.com/azure/batch/batch-compute-node-environment-variables).
*
* @return the commandLine value.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public final class BatchJobReleaseTask implements JsonSerializable<BatchJobRelea
* features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or
* "/bin/sh -c MyCommand" in Linux. If the command line refers to file paths, it should use a relative path
* (relative to the Task working directory), or use the Batch provided environment variable
* (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).
* (https://docs.microsoft.com/azure/batch/batch-compute-node-environment-variables).
*/
@Generated
private final String commandLine;
Expand Down Expand Up @@ -155,7 +155,7 @@ public BatchJobReleaseTask setId(String id) {
* to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c
* MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command line refers to file paths, it should use
* a relative path (relative to the Task working directory), or use the Batch provided environment variable
* (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).
* (https://docs.microsoft.com/azure/batch/batch-compute-node-environment-variables).
*
* @return the commandLine value.
*/
Expand Down
Loading

0 comments on commit 71409ca

Please sign in to comment.