-
Notifications
You must be signed in to change notification settings - Fork 4k
Implement Get-AzureBatchPoolNodeCounts and Start-AzureBatchComputeNodeServiceLogUpload cmdlets #6075
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
Conversation
…d Add-AzureBatchComputeNodeServiceLogs cmdlets
…unts on getting PoolNodeCounts
@antoniowmsft - You probably should consider collapsing some commits so that the history is a bit cleaner (I suspect the powershell guys will request that too so I'm just beating them to the punch =P) |
@@ -111,7 +111,8 @@ CmdletsToExport = 'Remove-AzureRmBatchAccount', 'Get-AzureRmBatchAccount', | |||
'Enable-AzureBatchTask', 'Set-AzureBatchTask', 'Stop-AzureBatchTask', | |||
'Get-AzureBatchComputeNode', 'Get-AzureBatchJobSchedule', | |||
'New-AzureBatchJobSchedule', 'Remove-AzureBatchJobSchedule', | |||
'Get-AzureBatchTaskCounts' | |||
'Get-AzureBatchTaskCounts', 'Get-AzureBatchPoolNodeCounts', | |||
'Add-AzureBatchComputeNodeServiceLogs' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should've raised this on the cmdlet review but it didn't occurr to me. Should this be Start-AzureBatchComputeNodeServiceLogUpload
? It doesn't really feel like an Add
to me. Start
is more inline with Pool resize and other long running operations we do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, the cmdlet would wait for the upload, and allow the user to pass -AsJob to have this occur in the background
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add-AzureBatchComputeNodeServiceLogs renamed to Start-AzureBatchComputeNodeServiceLogUpload. Add exception to Get-AzureBatchPoolNodeCounts.
@@ -27,6 +27,10 @@ | |||
## Version 4.0.5 | |||
* Fix issue with Default Resource Group in CloudShell | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: Combine these two sections as they are duplicated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
addComputeNodeServiceLogsCommand.BatchContext = context; | ||
addComputeNodeServiceLogsCommand.PoolId = "pool"; | ||
addComputeNodeServiceLogsCommand.ComputeNodeId = "tvm"; | ||
addComputeNodeServiceLogsCommand.ContainerUrl = "https://containerUrl?sv=="; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: If this SAS value is reused in multiple places maybe just make it a const at the class level?
getComputeNodeCommand.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor1 }; | ||
|
||
getComputeNodeCommand.ExecuteCmdlet(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor extra spaces here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
var poolNodeCounts1 = new ProxyModels.PoolNodeCounts() | ||
{ | ||
PoolId = "Pool1", | ||
Dedicated = new ProxyModels.NodeCounts( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use named parameters here (i.e. running: 1
) to make it more clear what is being set to what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for all the below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
``` | ||
|
||
### -ComputeNode | ||
{{Fill ComputeNode Description}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to fill this out
``` | ||
|
||
### -ContainerUrl | ||
The container url to Azure Storage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be updated along with the "HelpText" field I flagged in the other comment above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Accept wildcard characters: False | ||
``` | ||
|
||
### -EndTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as in Powershell code, don't need optional here and update the text
``` | ||
|
||
### -StartTime | ||
The start time of service log to be added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update text as per previous comment
``` | ||
|
||
### -MaxCount | ||
{{Fill MaxCount Description}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fill this description and the others below
@@ -97,6 +97,12 @@ | |||
<SpecificVersion>False</SpecificVersion> | |||
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft you can remove the Microsoft.Rest.*
references added in this file since they are already referenced from a common targets file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -19,6 +19,8 @@ | |||
<package id="Microsoft.Data.Services.Client" version="5.6.4" targetFramework="net45" /> | |||
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.28.3" targetFramework="net45" /> | |||
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" /> | |||
<package id="Microsoft.Rest.ClientRuntime" version="2.3.11" targetFramework="net452" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft same comment about removing these added references
@@ -57,10 +57,22 @@ | |||
<Reference Include="Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | |||
<HintPath>..\..\..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft you can remove the NuGet references added in this file since they are already referenced in a common targets file
<package id="Microsoft.Azure.Management.Batch" version="4.2.0" targetFramework="net452" /> | ||
<package id="Microsoft.Data.Edm" version="5.6.4" targetFramework="net452" /> | ||
<package id="Microsoft.Data.OData" version="5.6.4" targetFramework="net452" /> | ||
<package id="Microsoft.Data.Services.Client" version="5.6.4" targetFramework="net452" /> | ||
<package id="Microsoft.Rest.ClientRuntime" version="2.3.11" targetFramework="net452" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft same comment about removing these added references
$sasToken = New-AzureStorageContainerSASToken -Name "contosocontainer" -Context $storageContext | ||
$containerUrl = "https://contosogeneral.blob.core.windows.net/contosocontainer" + $sasToken | ||
$batchContext = Get-AzureRmBatchAccountKeys -AccountName "contosobatch" | ||
Start-AzureBatchComputeNodeServiceLogUpload -BatchContext $batchContext -PoolId "contosopool" -ComputeNodeId "tvm-1612030122_1-20180405t234700z" -ContainerUrl $containerUrl -StartTime "2018-01-01 00:00:00Z" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft for each of these examples, would you also provide the corresponding output that the user would see?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
namespace Microsoft.Azure.Commands.Batch | ||
{ | ||
[Cmdlet(VerbsCommon.Get, Constants.AzureBatchPoolNodeCounts, DefaultParameterSetName = Constants.AzureBatchPoolNodeCounts), OutputType(typeof(PSPoolNodeCounts))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft PowerShell guidelines discourage the user of plural nouns in the name of cmdlets and parameters; see this snippet for more information.
I think we should change the name of this cmdlet to Get-AzureBatchPoolNodeCount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get-AzureBatchPoolNodeCounts always return node state counts in multiple, so no. This will use plural nouns.
public PSCloudPool Pool { get; set; } | ||
|
||
[Parameter(ParameterSetName = Constants.ODataFilterParameterSet)] | ||
public int MaxCount { get; set; } = defaultMaxCount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft we should add the ValidateRange
attribute to this parameter to limit the values that the user can provide
|
||
namespace Microsoft.Azure.Commands.Batch | ||
{ | ||
[Cmdlet(VerbsCommon.Get, Constants.AzureBatchPoolNodeCounts, DefaultParameterSetName = Constants.AzureBatchPoolNodeCounts), OutputType(typeof(PSPoolNodeCounts))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft nit: I would make the default parameter set one of the sets you defined -- specifically Constants.ParentObjectParameterSet
|
||
namespace Microsoft.Azure.Commands.Batch | ||
{ | ||
[Cmdlet(VerbsLifecycle.Start, Constants.AzureBatchComputeNodeServiceLogUpload, DefaultParameterSetName = Constants.AzureBatchComputeNodeServiceLogUpload, SupportsShouldProcess = true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft nit: same comment as Get-AzureBatchNodeCount
about making the default parameter set one of the existing parameter sets in this cmdlet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start-AzureBatchComputeNodeServiceLogUpload is using singular noun.
this.EndTime, | ||
this.AdditionalBehaviors); | ||
|
||
WriteObject(BatchClient.StartComputeNodeServiceLogUpload(parameters)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft is this upload a long-running operation? If so, you should add the AsJob
parameter to this cmdlet to allow users to run this in the background of the PowerShell process
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a long running task but in fact it is not. Our backend doesn't allow file upload progress to be queried so it doesn't make sense to make cmdlet run as job.
[ValidateNotNullOrEmpty] | ||
public PSCloudPool Pool { get; set; } | ||
|
||
[Parameter(ParameterSetName = Constants.ODataFilterParameterSet), ValidateRange(1, 100)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we allow up to 1000 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, as we spoke we do not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultMaxCount = 10 matches up with server settings.
@cormacpayne Please squash the changes into 1 commit when you merge the changes. Please use this title: "Implement Get-AzureBatchPoolNodeCounts and Start-AzureBatchComputeNodeServiceLogUpload cmdlets" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft a few minor comments, otherwise LGTM
Also, you will need to regenerate the markdown files for the new cmdlets once they have been updated with the requested changes
@@ -22,6 +22,8 @@ | |||
## Version 4.0.7 | |||
* Set minimum dependency of module to PowerShell 5.0 | |||
* Updated New-AzureBatchPool documentation to remove deprecated example | |||
* Release new cmdlet Get-AzureBatchPoolNodeCounts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft please move the snippet that you added to below the ## Current Release
header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I asked earlier if I need to edit changelog.md. 👍
@@ -61,6 +61,12 @@ | |||
<HintPath>..\..\..\packages\WindowsAzure.Storage.6.2.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath> | |||
<Private>True</Private> | |||
</Reference> | |||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft please remove the references to Newtonsoft.Json
and System.Management.Automation
added in this file as they are already referenced in a separate common targets file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
[ValidateNotNullOrEmpty] | ||
public DateTime StartTime { get; set; } | ||
|
||
[Parameter(Position = 4, Mandatory = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft please remove the Position
property from this parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
[ValidateNotNullOrEmpty] | ||
public string ComputeNodeId { get; set; } | ||
|
||
[Parameter(Position = 1, ParameterSetName = Constants.ParentObjectParameterSet, ValueFromPipeline = true)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft I believe this should be mandatory in its given parameter set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
[ValidateNotNullOrEmpty] | ||
public string PoolId { get; set; } | ||
|
||
[Parameter(Position = 0, ParameterSetName = Constants.ParentObjectParameterSet, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoniowmsft for the two parameters in this file, please remove the Position
property (optional positional parameters are discouraged)
help files regenerated. |
Description
Checklist
CONTRIBUTING.md
platyPS
module