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

New Resource: azurerm_machine_learning_workspace #5696

Merged
merged 11 commits into from Mar 24, 2020

Conversation

cbellee
Copy link
Contributor

@cbellee cbellee commented Feb 12, 2020

Terraform resource provider to create a basic Azure Machine Learning Workspace.

Test cases successfully passed

=== RUN TestAccAzureRMMachineLearningWorkspace_basic
=== PAUSE TestAccAzureRMMachineLearningWorkspace_basic
=== CONT TestAccAzureRMMachineLearningWorkspace_basic
=== RUN TestAccAzureRMMachineLearningWorkspace_requiresImport
=== PAUSE TestAccAzureRMMachineLearningWorkspace_requiresImport
=== CONT TestAccAzureRMMachineLearningWorkspace_requiresImport
=== RUN TestAccAzureRMMachineLearningWorkspace_withTags
=== PAUSE TestAccAzureRMMachineLearningWorkspace_withTags
=== CONT TestAccAzureRMMachineLearningWorkspace_withTags
=== RUN TestAccAzureRMMachineLearningWorkspace_withContainerRegistry
=== PAUSE TestAccAzureRMMachineLearningWorkspace_withContainerRegistry
=== CONT TestAccAzureRMMachineLearningWorkspace_withContainerRegistry
=== RUN TestAccAzureRMMachineLearningWorkspace_complete
=== PAUSE TestAccAzureRMMachineLearningWorkspace_complete
=== CONT TestAccAzureRMMachineLearningWorkspace_complete
--- PASS: TestAccAzureRMMachineLearningWorkspace_complete (547.09s)
--- PASS: TestAccAzureRMMachineLearningWorkspace_basic (593.96s)
--- PASS: TestAccAzureRMMachineLearningWorkspace_withContainerRegistry (610.00s)
--- PASS: TestAccAzureRMMachineLearningWorkspace_requiresImport (701.89s)
--- PASS: TestAccAzureRMMachineLearningWorkspace_withTags (836.34s)
PASS

@ghost ghost added the size/XXL label Feb 12, 2020
@ghost ghost added the documentation label Feb 12, 2020
@ghost ghost added the dependencies label Feb 12, 2020
@ArcturusZhang
Copy link
Contributor

This PR depends on the SDK v39.0.0

@ArcturusZhang ArcturusZhang force-pushed the f/machine_learning_services branch 3 times, most recently from 863c148 to 228dced Compare February 14, 2020 09:35
@ArcturusZhang ArcturusZhang force-pushed the f/machine_learning_services branch 2 times, most recently from 1d4c4fc to 315fe8c Compare March 2, 2020 04:43
@katbyte katbyte added the sdk/requires-upgrade This is dependent upon upgrading an SDK label Mar 6, 2020
@katbyte
Copy link
Collaborator

katbyte commented Mar 10, 2020

@cbellee, @ArcturusZhang - i've opened a PR (#6049) to upgrade the SDK as we typically do that separately on their own. 2.1 should go out in the next couple days and this will get merged right after.

@ArcturusZhang
Copy link
Contributor

@cbellee, @ArcturusZhang - i've opened a PR (#6049) to upgrade the SDK as we typically do that separately on their own. 2.1 should go out in the next couple days and this will get merged right after.

Sure, I will rebase this PR once PR #6049 get merged

katbyte pushed a commit that referenced this pull request Mar 19, 2020
This PR supersedes #6049 as nested go modules and merge conflicts do not spark joy - but fundamentally this:

- updates github.com/Azure/azure-sdk-for-go to v40.3.0
- updates github.com/Azure/go-autorest to our fork containing Azure/go-autorest#512
- updates github.com/terraform-providers/terraform-provider-azuread to v0.8.0
- code changes needed for v40.3.0 of the Azure SDK - including opting into the old count 429's as requests which should be retried without adding to the total failure count

Enables #5769
Enables #5696
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Hi @cbellee,

thanks for the new resource! this is off to a great start and most of my comments are pretty minor. Once they are addressed this should be good ot merge!

Comment on lines 317 to 318
_, err = client.Update(ctx, id.ResourceGroup, id.Name, update)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we merge these two lines?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

Comment on lines 335 to 336
_, err = client.Delete(ctx, id.ResourceGroup, id.Name)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we merge these two lines?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done


* `friendly_name` - (Optional) Friendly name for this Machine Learning Workspace.

* `sku_name` - (Optional) SKU/edition of the Machine Learning Workspace, possible values are `Basic` for a basic workspace or `Enterprise` for a feature rich workspace. Default to `Basic`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* `sku_name` - (Optional) SKU/edition of the Machine Learning Workspace, possible values are `Basic` for a basic workspace or `Enterprise` for a feature rich workspace. Default to `Basic`.
* `sku_name` - (Optional) SKU/edition of the Machine Learning Workspace, possible values are `Basic` for a basic workspace or `Enterprise` for a feature rich workspace. Defaults to `Basic`.

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

})
}

func TestAccAzureRMMachineLearningWorkspace_withTags(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can just merge this with the complete test (and i notice that test isn't setting the tags, it should set as many of the properties as possible)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure

Comment on lines 304 to 305
description := d.Get("description").(string)
update.WorkspacePropertiesUpdateParameters.Description = &description
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor these could be

Suggested change
description := d.Get("description").(string)
update.WorkspacePropertiesUpdateParameters.Description = &description
update.WorkspacePropertiesUpdateParameters.Description = &utils.String(d.Get("description").(string))

Copy link
Contributor

Choose a reason for hiding this comment

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

Done, and I also changed some other field assignment with similar pattern

@ArcturusZhang
Copy link
Contributor

Hi @katbyte I have resolved your comments.
As for the acc test, for this resource we cannot do an update test by basic -> complete -> basic, because the complete test set the container_registry_id attribute which is ForceNew, this may make the update stop making sense. Therefore I added an update step for both the basic and complete test.

And according to Tom's comments in other PR that I spotted recently, I have removed the features.ShouldResourcesBeImported() and d.IsNewResource() check in Create function.

Plus, since I am neither the author of this PR nor reviewer, I cannot resolve those comment thread, hope you do not mind.

@ghost ghost removed the waiting-response label Mar 21, 2020
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks for the revisions @ArcturusZhang,

In addition to the comments i've left inline we have a test failure:

Test Failed

------- Stdout: -------
=== RUN   TestAccDataSourceAzureRMMachineLearningWorkspace_basic
=== PAUSE TestAccDataSourceAzureRMMachineLearningWorkspace_basic
=== CONT  TestAccDataSourceAzureRMMachineLearningWorkspace_basic
--- FAIL: TestAccDataSourceAzureRMMachineLearningWorkspace_basic (332.82s)
    testing.go:640: Step 1 error: 11 problems:
        
        - Provider produced invalid object: Provider "azurerm" planned an invalid value for data.azurerm_machine_learning_workspace.test during refresh: unsupported attribute "identity".
        
        This is a bug in the provider, which should be reported in the provider's own issue tracker.
        - Provider produced invalid object: Provider "azurerm" planned an invalid value for data.azurerm_machine_learning_workspace.test during refresh: unsupported attribute "key_vault_id".
        
        This is a bug in the provider, which should be reported in the provider's own issue tracker.
        - Provider produced invalid object: Provider "azurerm" planned an invalid value for data.azurerm_machine_learning_workspace.test during refresh: unsupported attribute "application_insights_id".
        
        This is a bug in the provider, which should be reported in the provider's own issue tracker.
        - Provider produced invalid object: Provider "azurerm" planned an invalid value for data.azurerm_machine_learning_workspace.test during refresh: unsupported attribute "description".
        
        This is a bug in the provider, which should be reported in the provider's own issue tracker.
        - Provider produced invalid object: Provider "azurerm" planned an invalid value for data.azurerm_machine_learning_workspace.test during refresh: unsupported attribute "sku_name".
        
        This is a bug in the provider, which should be reported in the provider's own issue tracker.
        - Provider produced invalid object: Provider "azurerm" planned an invalid value for data.azurerm_machine_learning_workspace.test during refresh: unsupported attribute "friendly_name".
        
        This is a bug in the provider, which should be reported in the provider's own issue tracker.
        - Provider produced invalid object: Provider "azurerm" planned an invalid value for data.azurerm_machine_learning_workspace.test during refresh: unsupported attribute "storage_account_id".
        
        This is a bug in the provider, which should be reported in the provider's own issue tracker.
        - Provider produced invalid object: Provider "azurerm" planned an invalid value for data.azurerm_machine_learning_workspace.test during refresh: unsupported attribute "container_registry_id".
        
        This is a bug in the provider, which should be reported in the provider's own issue tracker.
        - Provider produced invalid object: Provider "azurerm" planned an invalid value for data.azurerm_machine_learning_workspace.test during refresh: .timeouts: unsupported attribute "update".
        
        This is a bug in the provider, which should be reported in the provider's own issue tracker.
        - Provider produced invalid object: Provider "azurerm" planned an invalid value for data.azurerm_machine_learning_workspace.test during refresh: .timeouts: unsupported attribute "create".
        
        This is a bug in the provider, which should be reported in the provider's own issue tracker.
        - Provider produced invalid object: Provider "azurerm" planned an invalid value for data.azurerm_machine_learning_workspace.test during refresh: .timeouts: unsupported attribute "delete".
        
        This is a bug in the provider, which should be reported in the provider's own issue tracker.

Location: &location,
Tags: tags.Expand(t),
Sku: &machinelearningservices.Sku{Name: utils.String(skuName)},
Identity: identity,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that this is always required, i think we could

Suggested change
Identity: identity,
Identity: utils.String(d.Get("identity.0.type").(string)),

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, identity is a block, therefore I bring the definition of identity here in the struct initialization

"sku_name": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we put default just before the validation function?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

%s

resource "azurerm_machine_learning_workspace" "test" {
name = "acctestworkspace-%d"
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we include capitals in every property that allows them:

Suggested change
name = "acctestworkspace-%d"
name = "acctest-MLW-%d"

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

@katbyte katbyte added waiting-response and removed sdk/requires-upgrade This is dependent upon upgrading an SDK labels Mar 23, 2020
@ArcturusZhang
Copy link
Contributor

Hi @katbyte I have resolved the new comments, and find I missed the provider block in acc test configs and example usage in docs (already added them)
The test failure has been fixed now. Please have a look, thanks!

@ghost ghost removed the waiting-response label Mar 24, 2020
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks for the fixed @ArcturusZhang, tests pass now! LGTM 👍

Comment on lines +382 to +396
func expandArmMachineLearningWorkspaceIdentity(input []interface{}) *machinelearningservices.Identity {
if len(input) == 0 {
return nil
}

v := input[0].(map[string]interface{})

identityType := machinelearningservices.ResourceIdentityType(v["type"].(string))

identity := machinelearningservices.Identity{
Type: identityType,
}

return &identity
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It was more if you did the complex d.Get you could have removed this entire function simplifying the code. minor so not going to block the PR on it

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, thank you!

@katbyte katbyte changed the title F/machine learning services New Resource: azurerm_machine_learning_workspace Mar 24, 2020
@katbyte katbyte added this to the v2.3.0 milestone Mar 24, 2020
@katbyte katbyte merged commit f903b2f into hashicorp:master Mar 24, 2020
katbyte added a commit that referenced this pull request Mar 24, 2020
@ArcturusZhang ArcturusZhang deleted the f/machine_learning_services branch March 24, 2020 05:51
@ghost
Copy link

ghost commented Mar 27, 2020

This has been released in version 2.3.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.3.0"
}
# ... other configuration ...

@tombuildsstuff tombuildsstuff linked an issue Apr 1, 2020 that may be closed by this pull request
@ghost
Copy link

ghost commented Apr 23, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@hashicorp hashicorp locked and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Resource: Azure Machine Learning Service
3 participants