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

Support for Azure Batch - Account #2428

Merged
merged 13 commits into from
Dec 14, 2018

Conversation

jcorioland
Copy link
Contributor

@jcorioland jcorioland commented Dec 3, 2018

This PR will brings support for Azure Batch Account.
Will partially fix #2427. Needs to be merged before #2461

Azure Batch Account:

  • Data Source
  • Resource
  • Tests
  • Examples
  • Website documentation

@ghost ghost added size/XXL and removed size/M labels Dec 3, 2018
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @jcorioland

Thanks for opening this PR - whilst I appreciate this is still a WIP I took a look through and left a few comments inline, but this is off to a good start 👍

Thanks!

ValidateFunc: validation.StringInSlice([]string{
string(batch.BatchService),
string(batch.UserSubscription),
}, true),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this field should just have Type+Computed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I am not sure to understand why this field should be marked as Computed? It should be specified in the configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok sorry, I was looking on the resource, not the datasource :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

so this is specific to the Data Source where whilst this information will be returned it can't be set (since we only obtain the Batch Account using the Name & Resource Group - the other fields are outputs)

azurerm/resource_arm_batch_account.go Outdated Show resolved Hide resolved
azurerm/resource_arm_batch_account.go Outdated Show resolved Hide resolved
azurerm/resource_arm_batch_account.go Show resolved Hide resolved
azurerm/resource_arm_batch_account.go Show resolved Hide resolved
azurerm/resource_arm_batch_account.go Outdated Show resolved Hide resolved
@ghost ghost added the dependencies label Dec 5, 2018
@tombuildsstuff
Copy link
Contributor

@jcorioland rathe than combining multiple resources into a single PR could we split these out into two different PR's, one for the Account and one for the Pool?

@jcorioland jcorioland changed the title [WIP] Support for Azure Batch [WIP] Support for Azure Batch - Account Dec 6, 2018
@jcorioland jcorioland mentioned this pull request Dec 6, 2018
5 tasks
@jcorioland
Copy link
Contributor Author

jcorioland commented Dec 6, 2018

@tombuildsstuff I was actually thinking the same to keep merge operations simple. I've created a new PR #2461 for Azure Batch pool. Not sure I did it well, tell me if I am wrong.

@ghost ghost added the documentation label Dec 10, 2018
@jcorioland jcorioland changed the title [WIP] Support for Azure Batch - Account Support for Azure Batch - Account Dec 10, 2018
@tombuildsstuff tombuildsstuff self-assigned this Dec 10, 2018
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @jcorioland

Thanks for pushing those changes - I've taken a look through and left some minor comments in-line but this is mostly looking good, if we can fix those up we should be able to run the tests and get this merged 👍

Thanks!

azurerm/data_source_batch_account.go Outdated Show resolved Hide resolved
azurerm/data_source_batch_account.go Outdated Show resolved Hide resolved
azurerm/resource_arm_batch_account.go Outdated Show resolved Hide resolved
azurerm/resource_arm_batch_account.go Show resolved Hide resolved
log.Printf("[INFO] preparing arguments for Azure Batch account update.")

resourceGroupName := d.Get("resource_group_name").(string)
name := d.Get("name").(string)
Copy link
Contributor

Choose a reason for hiding this comment

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

outside of the Create function we should parse these from the ID - as such can we make this:

id, err := parseAzureResourceID(d.Id())
if err != nil {
  return err
}
name := id.Path["batchAccounts"]
resourceGroupName := id.ResourceGroup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

website/docs/d/batch_account.html.markdown Outdated Show resolved Hide resolved
website/docs/r/batch_account.html.markdown Outdated Show resolved Hide resolved
website/docs/r/batch_account.html.markdown Outdated Show resolved Hide resolved
website/docs/r/batch_account.html.markdown Show resolved Hide resolved
},
"pool_allocation_mode": {
Type: schema.TypeString,
Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is the Data Source this field isn't set-able, so we can remove the Optional here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@jcorioland
Copy link
Contributor Author

@tombuildsstuff - thanks for the review! I have done the updates.

@ghost ghost removed the waiting-response label Dec 12, 2018
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 @jcorioland,

Thank you for the quick updates! I've taken a look through and left some additional minor/stylistic comments. It also seems like you may have missed some of tom's in the previous review, github can be sneaky and hide them under a "14 hidden conversations / Learn More" banner.

azurerm/data_source_batch_account_test.go Show resolved Hide resolved
azurerm/data_source_batch_account_test.go Outdated Show resolved Hide resolved
azurerm/data_source_batch_account_test.go Outdated Show resolved Hide resolved
azurerm/resource_arm_batch_account.go Outdated Show resolved Hide resolved
azurerm/resource_arm_batch_account.go Outdated Show resolved Hide resolved

err = future.WaitForCompletionRef(ctx, client.Client)
// if the error is not that the Batch account was not found
if err != nil && future.Response().StatusCode != http.StatusNotFound {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same

if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {
  if !response.WasNotFound(future.Response()) {
    return fmt.Errorf("Error waiting for deletion of Batch account %q (Resource Group %q): %+v", name, resourceGroupName, err)
  }
}

azurerm/resource_arm_batch_account.go Outdated Show resolved Hide resolved
azurerm/resource_arm_batch_account_test.go Show resolved Hide resolved
azurerm/resource_arm_batch_account_test.go Outdated Show resolved Hide resolved
website/docs/r/batch_account.html.markdown Show resolved Hide resolved
@katbyte katbyte added this to the 1.21.0 milestone Dec 12, 2018
@jcorioland
Copy link
Contributor Author

@katbyte @tombuildsstuff - thank you both for the reviews and sorry for missing a huge part of Tom's review the other day :) Should be good now!

@ghost ghost removed the waiting-response label Dec 13, 2018
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 quick updates again @jcorioland, aside from some minor indentation issues this LGTM 👍

(looks like i don't have permission to push to the branch)

azurerm/data_source_batch_account_test.go Outdated Show resolved Hide resolved
azurerm/resource_arm_batch_account_test.go Outdated Show resolved Hide resolved
azurerm/resource_arm_batch_account_test.go Outdated Show resolved Hide resolved
@katbyte katbyte self-assigned this Dec 13, 2018
@jcorioland
Copy link
Contributor Author

jcorioland commented Dec 14, 2018

@katbyte - thanks for having approved this PR. I've done the few updates you've asked for. It's weird that you were not able to push on the branch, I've checked and the Allow edit from maintainers option is enabled.

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @jcorioland

Thanks for pushing those changes - ignoring a couple of minor comments (which I'm going to push a commit for) this now LGTM 👍 - I'll kick off the tests shortly :)

Thanks!

})
}

func TestAccAzureRMBatchAccount_noStorageAccount_basic(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should update this:

Suggested change
func TestAccAzureRMBatchAccount_noStorageAccount_basic(t *testing.T) {
func TestAccAzureRMBatchAccount_basic(t *testing.T) {


* `pool_allocation_mode` - (Optional) Specifies the mode to use for pool allocation. Possible values are `BatchService` or `UserSubscription`. Defaults to `BatchService`.

* `storage_account_id` - (Optional) Specifies the storage account to use for the Batch account. If not specified, Azure Batch will manage the storage.
Copy link
Contributor

Choose a reason for hiding this comment

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

we can remove this, since it's specified in the argument reference above

Suggested change
* `storage_account_id` - (Optional) Specifies the storage account to use for the Batch account. If not specified, Azure Batch will manage the storage.


* `id` - The Batch account ID.

* `pool_allocation_mode` - (Optional) Specifies the mode to use for pool allocation. Possible values are `BatchService` or `UserSubscription`. Defaults to `BatchService`.
Copy link
Contributor

Choose a reason for hiding this comment

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

we can remove this since it's specified in the argument reference above

Suggested change
* `pool_allocation_mode` - (Optional) Specifies the mode to use for pool allocation. Possible values are `BatchService` or `UserSubscription`. Defaults to `BatchService`.

@jcorioland
Copy link
Contributor Author

Hi @tombuildsstuff awesome, thank you!

@tombuildsstuff
Copy link
Contributor

Resource Tests pass:

screenshot 2018-12-14 at 10 37 44

Data Source tests pass:

screenshot 2018-12-14 at 10 38 24

@tombuildsstuff tombuildsstuff merged commit 95ecb63 into hashicorp:master Dec 14, 2018
tombuildsstuff added a commit that referenced this pull request Dec 14, 2018
@ghost
Copy link

ghost commented Jan 28, 2019

Hello @tombuildsstuff @jcorioland
Good work on the Batch Account support.
Judging from the PR, the tests only covered BatchService pool_allocation_mode, not UserSubscription. This failed when I specified UserSubscription. From manual inspection, there is a KeyVault requirement, but I cannot see this support in the golang, and I don't know what other code to provide to TF when I specify UserSubscription to get Batch deployed successfully in that case. Any commentary appreciated.

@katbyte
Copy link
Collaborator

katbyte commented Jan 28, 2019

Hi @phosphre,

Thanks for bringing this to our attention, but could you open a issue please? It was only by chance i happened to see this comment as we don't usually review closed PRs/

Thanks!

@ghost
Copy link

ghost commented Mar 5, 2019

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!

@ghost ghost locked and limited conversation to collaborators Mar 5, 2019
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.

Feature Request: Azure Batch
3 participants