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_eventhub_cluster #7306

Merged
merged 11 commits into from Jun 16, 2020
Merged

New Resource: azurerm_eventhub_cluster #7306

merged 11 commits into from Jun 16, 2020

Conversation

mbfrahry
Copy link
Member

Fixes #6808

@mbfrahry mbfrahry changed the title New Resource: azurerm_eventhub_cluster [WIP] New Resource: azurerm_eventhub_cluster Jun 12, 2020
@mbfrahry mbfrahry added the service/event-hubs EventHubs label Jun 12, 2020
@mbfrahry mbfrahry added this to the v2.15.0 milestone Jun 12, 2020
@mbfrahry mbfrahry changed the title [WIP] New Resource: azurerm_eventhub_cluster New Resource: azurerm_eventhub_cluster Jun 12, 2020
@mbfrahry mbfrahry requested a review from a team June 12, 2020 20:20
Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Thanks @mbfrahry
Couple questions and comments below, but otherwise LGTM 👍
Thanks!

}

if err := future.WaitForCompletionRef(ctx, client.Client); err != nil {
return resource.NonRetryableError(fmt.Errorf("creating eventhub cluster: %+v", err))
Copy link
Member

Choose a reason for hiding this comment

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

typo here?

Suggested change
return resource.NonRetryableError(fmt.Errorf("creating eventhub cluster: %+v", err))
return resource.NonRetryableError(fmt.Errorf("deleting eventhub cluster: %+v", err))

website/docs/r/eventhub_cluster.html.markdown Outdated Show resolved Hide resolved
Comment on lines 108 to 114
id, err := azure.ParseAzureResourceID(d.Id())
if err != nil {
return err
}

resourceGroup := id.ResourceGroup
name := id.Path["clusters"]
Copy link
Member

Choose a reason for hiding this comment

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

Worth a custom ID parser here?

if response.WasNotFound(future.Response()) {
return nil
}
if strings.Contains(err.Error(), "Cluster cannot be deleted until four hours after its creation time") {
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth a 429 check here too given the length of time this operation could be running for?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Creating/deleting clusters is actually quite fast. It's just that once created you can't delete it for the first 4 hours. I don't think a case where TF would wait for 4 hours makes sense?

Copy link
Member

Choose a reason for hiding this comment

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

Hi @favoretti
In this case, if the delete operation is requested before the 4 hour minimum lifetime (say as part of a daily build, or acceptance test), the provider is capable of performing the operation without error or intervention (whilst honouring any custom timeouts). If the request is sent after that minimum interval this section of code won't trigger and will, as you point out, complete quickly.

mbfrahry and others added 2 commits June 15, 2020 09:03
Co-authored-by: Steve <11830746+jackofallops@users.noreply.github.com>
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.

Aside from one comment about upgrading all the resources to the new api looks good @mbfrahry

@@ -2,17 +2,22 @@ package client

import (
"github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub"
previewEventhub "github.com/Azure/azure-sdk-for-go/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason we can't upgrade the rest of the resources to this api version

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call! The preview version was a little wonky when I started but it seems to have evened out with this latest version. It's been taken care of and tests look good

Copy link
Contributor

@ArcturusZhang ArcturusZhang left a comment

Choose a reason for hiding this comment

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

Thanks @mbfrahry I have left some question and minor comments, please have a look

Comment on lines 28 to 30
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we also check the ID before the import?


future, err := client.Put(ctx, resourceGroup, name, cluster)
if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should put some custom error messages here?


read, err := client.Get(ctx, resourceGroup, name)
if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should put some custom error messages here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

client := meta.(*clients.Client).Eventhub.ClusterClient
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()
id, err := parse.NamespaceAuthorizationRuleID(d.Id())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why here we are parsing this ID as a namespace authorization rule instead of cluster?

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.

aside from a few minor remarks LGTM 👍


read, err := client.Get(ctx, resourceGroup, name)
if err != nil {
return err
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

Comment on lines 75 to 76
name := rs.Primary.Attributes["name"]
resourceGroup := rs.Primary.Attributes["resource_group_name"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should use the parse id function here on the id

Comment on lines 103 to 104
name := rs.Primary.Attributes["name"]
resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

and parse id again here

}

resource "azurerm_eventhub_cluster" "test" {
name = "acctesteventhubcluster-%d"
Copy link
Collaborator

Choose a reason for hiding this comment

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

can capitals be used here?

@mbfrahry mbfrahry merged commit f0e1d1c into master Jun 16, 2020
@mbfrahry mbfrahry deleted the f-eventhub-dedicated branch June 16, 2020 17:40
mbfrahry added a commit that referenced this pull request Jun 16, 2020
@ghost
Copy link

ghost commented Jun 19, 2020

This has been released in version 2.15.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.15.0"
}
# ... other configuration ...

@djsly
Copy link
Contributor

djsly commented Jun 19, 2020

@mbfrahry how can I assign eventhub_namespaces to eventhub_cluster ?

@favoretti
Copy link
Collaborator

@djsly Yeah... That's what we're discussing here: #7347

@ghost
Copy link

ghost commented Jul 17, 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 Jul 17, 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.

Support for dedicated eventhub clusters
7 participants