Skip to content
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

Machine Learning Compute: Add -IncludeAllResources Paramter for Remove cmdlet #5206

Merged
merged 9 commits into from
Jan 8, 2018

Conversation

shutchings
Copy link
Contributor

@shutchings shutchings commented Jan 2, 2018

Description

Added a parameter to include all resources when removing an operationalization cluster.


This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • Pull request includes test coverage for the included changes.
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThru parameter.

Cmdlet Parameter Guidelines

  • Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

@shutchings
Copy link
Contributor Author

@maddieclayton I've started this PR so that you can take a look at the code changes while I'm waiting for the .NET SDK PR to be completed and the new package to be created. Once that's done I'll remove the local nuget package I added and make sure the build works.

Copy link
Contributor

@maddieclayton maddieclayton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few initial comments. Please let me know when the SDK changes have been merged and the PR is updated. Also, please be sure to resolve the merge conflict that has come up.

var clusterToDelete = MachineLearningComputeManagementClient.OperationalizationClusters.Get(ResourceGroupName, Name);
var managedByResourceGroup = new ResourceIdentifier(clusterToDelete.ContainerRegistry.ResourceId).ResourceGroupName;

shouldProcessMessage += $" and supporting resource group {managedByResourceGroup}";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the supporting resource group the only additional resource that will be deleted when -IncludeAllResources is specified?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it deletes that cluster and the supporting resource group only. The supporting resource group has a bunch of resources in it, I could change it to list them all out but it will include things like network security groups, nics, vms, disks, etc. It seemed too verbose to list all those resources individually so I think just warning that that resource group will be deleted should be enough.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I agree that this message would make the most sense. Maybe it would be useful to also add in the message that all resources in the supporting resource group will be deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion.

</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these three references: they are already imported by the common dependencies target.

@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.Management.MachineLearningCompute" version="0.2.0" targetFramework="net452" />
<package id="Microsoft.Azure.Management.MachineLearningCompute" version="0.3.0" targetFramework="net452" />
<package id="Microsoft.Rest.ClientRuntime" version="2.3.10" targetFramework="net452" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about removing the three duplicate references.

Remove-AzureRmMlOpCluster -ResourceGroupName $resourceGroupName -Name $clusterName -IncludeAllResources

Assert-Throws ( Get-AzureRmResourceGroup -ResourceGroupName $managedByResourceGroupName )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this throw? Shouldn't it complete the operation successfully and delete both the managed resource group and the cluster? And if it is supposed to throw, I would think you'd want another test with the command running successfully.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This throws because after a successful remove call with -IncludeAllResources the resource group I'm trying to get should not exist. So by expecting the throw I can verify that the -IncludeAllResources worked correctly.

Copy link
Contributor

@maddieclayton maddieclayton Jan 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that makes sense - I did not expect that a Get would throw when the resource is not found, but if that is the behavior then this test makes sense. Thanks.

@maddieclayton
Copy link
Contributor

@shutchings I'll take a look once the merge conflict has been resolved - please feel free to assign the PR back to me once this is done and you are ready for me to take a look.

@shutchings
Copy link
Contributor Author

@maddieclayton I fixed the merge conflict and removed the local package since I got the latest one published to nuget. From the looks of it it's failing static analysis and should regen the installer. Is that correct?

@maddieclayton
Copy link
Contributor

@shutchings The issue is that the parameter you added is plural (which is okay since it is a SwitchParameter). Please copy the message (the issue with severity 1) from SignatureIssues.csv (found in the build) in breakingchanges.csv. This should resolve the issue, please let me know if you have any more questions.

@maddieclayton maddieclayton removed their assignment Jan 4, 2018
@shutchings
Copy link
Contributor Author

@maddieclayton I added in the exception but it is still failing. The other issues were severity 2 so I assume they aren't failing the build. Is there something else missing?

@maddieclayton
Copy link
Contributor

@shutchings No, the issue is still the plural parameter name. Can you try following the format of the lines above Microsoft.Azure.Commands.Compute:

"d:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Sql\Microsoft.Azure.Commands.Sql.dll","Microsoft.Azure.Commands.Sql.Database.Cmdlet.SetAzureSqlDatabase","Set-AzureRmSqlDatabase","0","2100","The parameter 'Tags' in cmdlet 'Set-AzureRmSqlDatabase' is no longer in the parameter set '__AllParameterSets'.","Add parameter 'Tags' back to the parameter set '__AllParameterSets'."

It looks like the format you used only works for compute for reason - if this does not fix the issue I'll look into it further.

@shutchings
Copy link
Contributor Author

@maddieclayton I think I have it in the right format now but it's still giving issues.

@maddieclayton
Copy link
Contributor

@shutchings Oh no, this is my fault. It should go in tool/Exception/SignatureIssues.csv, not breakingchanges. I apologize for the confusion, but that should work. Don't use the new format that you switched to, just copy paste again into the csv file.

@shutchings
Copy link
Contributor Author

@maddieclayton Yep, that did it!

@maddieclayton
Copy link
Contributor

@shutchings Great! If you are ready for another review please assign the PR back to me.

Copy link
Contributor

@maddieclayton maddieclayton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two very small comments then looks good to me.

* Add IncludeAllResources parameter to Remove-AzureRmMlOpCluster cmdlet
- Using this switch parameter will remove all resources that were created with the cluster originally

## Version 0.3.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't modify this - just add your snippet after the snippets about ResourceGroup and Location completers. We will automatically modify this file during release.

Copy link
Contributor Author

@shutchings shutchings Jan 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I looked at the version number in the .psd1 file and it shows 0.3.1 which is below the current release so that's why I thought the version numbers are off. But maybe I'm misunderstanding? Is it that the bullets below current release are slated for the next version to be released?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Current release" actually means the upcoming release: it will be displayed as the current release notes in the next release.

@@ -58,26 +58,47 @@ public class RemoveAzureRmMlOpCluster : MachineLearningComputeCmdletBase
HelpMessage = ResourceIdParameterHelpMessage)]
public string ResourceId { get; set; }

[Parameter(ParameterSetName = ObjectParameterSet,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the parameter is in all of the parameter sets you don't need a parameter attribute for each parameter set, all you need is:

[Parameter(Mandatory = false, HelpMessage = IncludeAllResourcesParameterHelpMessage)]
public SwitchParameter IncludeAllResources { get; set; }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know!

@maddieclayton
Copy link
Contributor

maddieclayton commented Jan 5, 2018

maddieclayton
maddieclayton previously approved these changes Jan 5, 2018
@shutchings
Copy link
Contributor Author

@maddieclayton Is it possible to start a package job?

@maddieclayton
Copy link
Contributor

Yup, here is it:https://azuresdkci.westus2.cloudapp.azure.com/view/PowerShell/job/posh-pack/42/. Let me know when you are ready to merge.

@maddieclayton
Copy link
Contributor

@shutchings is this ready to merge? I wasn't sure if you were running testing on the package job or needed it for another reason.

@shutchings
Copy link
Contributor Author

@maddieclayton I found a typo in the parameter name in the help document while testing the package job. Must have been from when I regenerated the help and then made changes to the parameter name. After this build feel free to merge it.

@maddieclayton maddieclayton merged commit fe1c530 into Azure:preview Jan 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants