-
Notifications
You must be signed in to change notification settings - Fork 4.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
azurerm_service_fabric_cluster
- support for specifying the cluster code version
#1945
azurerm_service_fabric_cluster
- support for specifying the cluster code version
#1945
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 @steve-hawkins,
Thank you for adding this property, it looks great outside aside from a couple minor comments I've left inline.
Look forward to getting this merged soon
.gitattributes
Outdated
@@ -0,0 +1,2 @@ | |||
# make sure all .go files stay LF, this will help developers on Windows |
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 file is outside of the scope of this PR.
func testAccAzureRMServiceFabricCluster_manualClusterCodeVersion(rInt int, location, clusterCodeVersion string) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%[1]d" |
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.
Very minor but could we align these assignments?
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.
sorry copy and paste job
I must be doing something wrong in the acceptance test as I get the following:-
forgive me as I have only just started learning GoLang and contributing to this project I get that it appears to not find the attribute key cluster_code_version or a value, but I can't figure out how the TestCheckResourceAttr function in testing.go actually checks the resource? I know my change works as I have tested it manually, but I cannot figure out how to get the acceptance test working any help appreciated |
What is happening is on import, the |
@@ -423,6 +433,7 @@ func resourceArmServiceFabricClusterRead(d *schema.ResourceData, meta interface{ | |||
d.Set("management_endpoint", props.ManagementEndpoint) | |||
d.Set("reliability_level", string(props.ReliabilityLevel)) | |||
d.Set("upgrade_mode", string(props.UpgradeMode)) | |||
d.Set("cluster_code_version ", props.ClusterCodeVersion) |
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 believe the test failure here is because there's a space at the end of this string (so the d.Set
can't find a matching property in the schema called cluster_code_version
[note the space] - so the Set fails)?
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.
@steve-hawkins since this PR otherwise LGTM - I hope you don't mind but I've pushed a commit to remove the extra space (and will kick off the tests now)
@@ -372,6 +381,7 @@ func resourceArmServiceFabricClusterUpdate(d *schema.ResourceData, meta interfac | |||
NodeTypes: nodeTypes, | |||
ReliabilityLevel: servicefabric.ReliabilityLevel1(reliabilityLevel), | |||
UpgradeMode: servicefabric.UpgradeMode1(upgradeMode), | |||
ClusterCodeVersion: utils.String(clusterCodeVersion), |
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've run the test suite here and this fails because the ClusterCodeVersion
is an empty string when it's not specified (so this fails on the API Validation):
* azurerm_service_fabric_cluster.test: Error creating Service Fabric Cluster "acctest-9043244035322992792" (Resource Group "acctestRG-9043244035322992792"): servicefabric.ClustersClient#Create: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="InvalidRequestFormat" Message="Cannot parse the request." Details=[{"code":"InvalidRequestFormat","message":"Error parsing version string:. Path 'properties.clusterCodeVersion', line 1, position 115."}]
could we update this to only set the field if it's got a value? e.g.
if clusterCodeVersion != "" {
parameters.ClusterPropertiesUpdateParameters.ClusterCodeVersion = utils.String(clusterCodeVersion)
}
(we also need to update the Create above to do the same thing)
…ve-hawkins/terraform-provider-azurerm into feature/cluster_code_version
Hi @tombuildsstuff and @katbyte , I'm having some trouble with the conditional logic on ClusterCodeVersion in the resourceArmServiceFabricClusterRead function. I have all the current acceptance tests working with the following:- upgradeMode := string(props.UpgradeMode)
d.Set("upgrade_mode", upgradeMode)
if upgradeMode == "Manual" {
d.Set("cluster_code_version", props.ClusterCodeVersion)
} This however will fail if UpgradeMode is Manual and no version is specified:-
I could make it so the cluster_code_version has to be specified if the upgrade_mode is set to Manual, would that be acceptable? I might need some help if we want this to work with upgrade_mode to Manual and no cluster_code_version specified |
Might i suggest always reading in d.Set("cluster_code_version", v) //d.Set will handle nil values and then adding computed to the |
``` $ acctests azurerm TestAccAzureRMServiceFabricCluster_manualLatest === RUN TestAccAzureRMServiceFabricCluster_manualLatest --- PASS: TestAccAzureRMServiceFabricCluster_manualLatest (96.07s) PASS ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 97.192s ```
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.
hey @steve-hawkins
This however will fail if UpgradeMode is Manual and no version is specified:-
So in order to fix this we can make the field Computed
, which means if a value isn't specified then it'll use the default value from the API. Since this PR otherwise LGTM I'm going to push a commit to fix this and get this merged as a part of v1.16 (I hope you don't mind!)
Thanks!
|
||
if upgradeMode == "Manual" { | ||
d.Set("cluster_code_version", props.ClusterCodeVersion) | ||
} |
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 can remove the upgradeMode == "Manual"
check here - and ensure this value is always set (since this information is always useful) - instead we can make this field Computed
in the schema (above), which will allow this value to be optional & have whatever default value is specified by the Azure API
azurerm_service_fabric_cluster
- support for specifying the cluster code version
Thanks @katbyte @tombuildsstuff I knew I would have been missing something obvious Much appreciated and looking forward to contributing more |
@tombuildsstuff any chance this could make it into 1.16.0? |
@steve-hawkins it's been merged so it'll go out as a part of that release - we're looking to ship v1.16 once #1987 has been merged :) |
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 should resolve #1906