-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Add AzureRM Service Bus Queue resource #14631
Add AzureRM Service Bus Queue resource #14631
Conversation
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 @iljaskevic
Thanks for all the work here - I have left you some comments to think about
Thanks
Paul
|
||
"enable_batched_operations": { | ||
Type: schema.TypeBool, | ||
Optional: true, |
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.
We should provide a default here. We have a known bug in Terraform that if you specify a value of true
then change back to false
then terraform won't get that change
this is because of d.GetOk("false") believing that the value doesn't exist as the default value for a bool is false
}, | ||
|
||
"enable_express": { | ||
Type: schema.TypeBool, |
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.
Same default value point
|
||
"enable_partitioning": { | ||
Type: schema.TypeBool, | ||
Optional: true, |
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.
Same default value point
}, | ||
|
||
"requires_duplicate_detection": { | ||
Type: schema.TypeBool, |
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.
Same default value point
}, | ||
|
||
"support_ordering": { | ||
Type: schema.TypeBool, |
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.
Same default value point
d.Set("namespace_name", namespaceName) | ||
d.Set("location", azureRMNormalizeLocation(*resp.Location)) | ||
|
||
props := resp.QueueProperties |
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 think we should check that QueueProperties
is not nil before trying to get values from it - otherwise this could panic
d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) | ||
d.Set("default_message_ttl", props.DefaultMessageTimeToLive) | ||
|
||
if props.DuplicateDetectionHistoryTimeWindow != nil && *props.DuplicateDetectionHistoryTimeWindow != "" { |
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.
d.Set will safely do this check for you
// if the queue is in a premium namespace and partitioning is enabled then the | ||
// max size returned by the API will be 16 times greater than the value set | ||
if *props.EnablePartitioning { | ||
namespace, err := meta.(*ArmClient).serviceBusNamespacesClient.Get(resGroup, namespaceName) |
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.
Why do you need to make another Get request 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.
It needs to retrieve the parent Namespace resource where the queue is running to get the size (Basic, Standard or Premium) to be able to re-calculate the max size property differently for Basic and Standard sizes than for Premium size, when getting the queue info from Azure.
In Azure Service Bus, if partitioning is enabled and maximum queue size is set to N megabytes, when getting the max size property of an existing queue we get N MB for Premium and N*16 MB for Basic and Standard. That is because Basic and Standard are running on shared resources and it creates 16 copies/partitions, which means that total max size is 16 times the value that was set. However, Premium runs on dedicated resources and partitioning is always enabled with 2 partitions with max size split between the them. This means that each partition has max size of N/2 MB and the total max size remains N MB.
So to avoid a problem of discrepancy between the value of the property we set when creating the queue and the value of that property we get when we retrieve it from Azure after it was created, it needs to divide the property value by 16 for queues running in Basic and Standard namespaces.
The extra API call makes sense now - thanks for explaining that. Please can you just touch up the other points I made around d.Set and default values for bools and then we can get this merged Thanks Paul |
…erties for Premium queues, as well as, updated acceptance tests and docs.
…m-servicebus-queue
Hi @iljaskevic The code LGTM to me, looks like there is a test failure:
Please can you look into the tests? Thanks Paul |
Hi @stack72
|
Hey @iljaskevic Since this PR was opened the AzureRM Provider has been moved out of this repository as part of the Provider Split in Terraform 0.10. Due to this the PR needed to be moved to the new split out repository - I hope you don't mind but I've gone ahead and done this (and retained your authorship for the original commit), and fixed the failing test that @stack72 identified and opened PR hashicorp/terraform-provider-azurerm#151 As such - I'm going to close this PR in favour of the split-out one - but I'd like to thank you for your contribution :) Thanks! |
* Importing the work from hashicorp/terraform#14631 by @iljaskevic * Refactoring the tests * Formatting * Importing the docs * Refactoring * Making `duplicate_detection_history_time_window` computed * Refactoring the tests * Fixing the formatting
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This PR adds Azure RM - Service Bus Queue resource. Any ideas on how to improve this are welcome.