-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Site recovery support #4003
Site recovery support #4003
Conversation
…port site recovery.
…n order to support site recovery.
…n order to support site recovery.
…ppings' in order to support site recovery.
…der to support site recovery.
05bcd13
to
8f7c65b
Compare
8f7c65b
to
c1a8e8a
Compare
force-pushed to fix the lint errors that I had missed. |
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.
Hi @martenbohlin,
Thank you for all these new resources! I've given this a first pass and its off to a great start. In addition to the comments i've left inline could we get some docs added for all the resources? As well as most of the errors need a little more detail added so when they happen we know what is erroring where.
thanks!
|
||
d.Set("name", resp.Name) | ||
d.Set("resource_group_name", resGroup) | ||
d.Set("location", resp.Properties.FriendlyName) // Crazy? yes. But the location comes back in the friendly name |
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.
wow lol
There wil need to be a nil check here:
d.Set("location", resp.Properties.FriendlyName) // Crazy? yes. But the location comes back in the friendly name | |
if props := resp.Properties; props != nil { | |
d.Set("location", props.FriendlyName) // Crazy? yes. But the location comes back in the friendly name | |
} |
ForceNew: true, | ||
ValidateFunc: validate.NoEmptyStrings, | ||
}, | ||
"name": { |
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.
Could we put this at the tope before any other properties for consistency with the rest of the provider?
return &schema.Resource{ | ||
Create: resourceArmRecoveryNetworkMappingCreate, | ||
Read: resourceArmRecoveryNetworkMappingRead, | ||
Update: nil, |
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 can just be left blank
Update: nil, |
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.
Fixed
ForceNew: true, | ||
ValidateFunc: validate.NoEmptyStrings, | ||
}, | ||
"name": { |
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.
Could we put this property up top as the first?
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.
Fixed
existing, err := client.Get(ctx, name) | ||
if err != nil { | ||
if !utils.ResponseWasNotFound(existing.Response) { | ||
return fmt.Errorf("Error checking for presence of existing recovery services fabric: %+v", err) |
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.
For this (and all other error messages) could e be a little more clear about what is erroring:
return fmt.Errorf("Error checking for presence of existing recovery services fabric: %+v", err) | |
return fmt.Errorf("Error checking for presence of existing recovery services fabric %s (vault %s): %+v", name, vaultName, err) |
|
||
future, err := client.Create(ctx, fabricName, name, parameters) | ||
if err != nil { | ||
return fmt.Errorf("Error creating recovery services protection container1: %+v", err) |
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.
As with all errors could we add a bit more detail:
return fmt.Errorf("Error creating recovery services protection container1: %+v", err) | |
return fmt.Errorf("Error creating recovery services protection container %s (fabric %s): %+v", name, fabricName, err) |
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: validate.NoEmptyStrings, |
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.
COuld we validate this is an ID?
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: validate.NoEmptyStrings, |
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.
COuld we validate this is an ID?
Thanks @katbyte for the quick feedback. I have fixed all your comments about the code, and I will start to look at the documentation now. It would be great if you could double check commit 63dcc2e where I upgrade the azure-sdk-for-go dependency, I am not sure if I updated the files under vendor correctly. |
…d redundant parameter source_network_name.
All requested changes has now been made. |
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.
Thanks for the revisions @martenbohlin,
I've left a couple more comments inline. WRT the sdk upgrade, we do that as a separate PR, i can open and get that merged for you once 1.33 is out.
I am seeing a few test failures thou:
------- Stdout: -------
=== RUN TestAccAzureRMRecoveryReplicationPolicy_basic
=== PAUSE TestAccAzureRMRecoveryReplicationPolicy_basic
=== CONT TestAccAzureRMRecoveryReplicationPolicy_basic
------- Stderr: -------
panic: Invalid address to set: []string{"location"}
looks like you are setting location, despite it not being part of the schema.
d.Set("name", resp.Name) | ||
d.Set("resource_group_name", resGroup) | ||
if props := resp.Properties; props != nil { | ||
d.Set("location", props.FriendlyName) // Crazy? yes. But the location comes back in the friendly name |
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.
It might make sense to open an azure sdk bug for this one? 🤔
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 found the correct way to get the location now that I have worked a bit more with the API.
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: validate.NoEmptyStrings, | ||
DiffSuppressFunc: suppress.CaseDifference, |
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.
Now that we are fixing this at the d.Set(id) level can we remove this?
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: validate.NoEmptyStrings, | ||
DiffSuppressFunc: suppress.CaseDifference, |
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.
as above
@@ -1,7 +1,7 @@ | |||
module github.com/terraform-providers/terraform-provider-azurerm | |||
|
|||
require ( | |||
github.com/Azure/azure-sdk-for-go v31.0.0+incompatible | |||
github.com/Azure/azure-sdk-for-go v31.1.0+incompatible |
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.
If we need to update the SDK that should be done in a separate PR, i can open that and get it merged for you once 1.33 goes out 🙂
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.
Thanks, that sounds great!
About the test failures, I can not reproduce that. I ran |
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.
The error is because you are setting a property that doesn't exist in schema. i've marked them with some comments. This behaviour is not yet enabled by default, but you can with the environment variable: TF_SCHEMA_PANIC_ON_ERROR=1
} | ||
|
||
d.Set("name", resp.Name) | ||
d.Set("location", resp.Location) |
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.
You are setting location here and it doesn't exist in the schema
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.
Aha, now I get it. Fixed.
d.Set("name", resp.Name) | ||
d.Set("resource_group_name", resGroup) | ||
d.Set("recovery_vault_name", vaultName) | ||
d.Set("location", resp.Location) |
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.
And 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.
Thanks for the fix @martenbohlin! LGTM now 🚀
Super appreciative of the work on this and excited to try this out. Sorry to chime in out of nowhere but are these typos intentional? |
@sean-nixon thanks for pointing that out. I have created pull request #4123 to fix the spelling mistakes. |
This has been released in version 1.33.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 = "~> 1.33.0"
}
# ... other configuration ... |
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! |
This pull request adds 6 new resources needed to support site recovery (Azure to Azure).
This fixes issue #3480
Let me know if I can improve the code in any way.