-
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
azurerm_log_analytics_workspace
- prevent ForceNew when sku
is LACluster
#19608
Changes from 3 commits
2f558ed
693448e
80d91b1
38db6a6
197ef8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -144,14 +144,13 @@ func resourceLogAnalyticsWorkspaceCustomDiff(ctx context.Context, d *pluginsdk.R | |||||||||||||||||||||||||||
// custom diff here because when you link the workspace to a cluster the | ||||||||||||||||||||||||||||
// cluster changes the sku to LACluster, so we need to ignore the change | ||||||||||||||||||||||||||||
// if it is LACluster else invoke the ForceNew as before... | ||||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||||
// NOTE: Since LACluster is not in our enum the value is returned as "" | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if d.HasChange("sku") { | ||||||||||||||||||||||||||||
old, new := d.GetChange("sku") | ||||||||||||||||||||||||||||
log.Printf("[INFO] Log Analytics Workspace SKU: OLD: %q, NEW: %q", old, new) | ||||||||||||||||||||||||||||
// If the old value is not LACluster(e.g. "") return ForceNew because they are | ||||||||||||||||||||||||||||
// really changing the sku... | ||||||||||||||||||||||||||||
if !strings.EqualFold(old.(string), "") { | ||||||||||||||||||||||||||||
if !strings.EqualFold(old.(string), string(workspaces.WorkspaceSkuNameEnumLACluster)) && !strings.EqualFold(old.(string), "") { | ||||||||||||||||||||||||||||
d.ForceNew("sku") | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
@@ -198,7 +197,7 @@ func resourceLogAnalyticsWorkspaceCreateUpdate(d *pluginsdk.ResourceData, meta i | |||||||||||||||||||||||||||
if err == nil { | ||||||||||||||||||||||||||||
if resp.Model != nil && resp.Model.Properties != nil { | ||||||||||||||||||||||||||||
if azSku := resp.Model.Properties.Sku; azSku != nil { | ||||||||||||||||||||||||||||
if strings.EqualFold(string(azSku.Name), "lacluster") { | ||||||||||||||||||||||||||||
if strings.EqualFold(string(azSku.Name), string(workspaces.WorkspaceSkuNameEnumLACluster)) { | ||||||||||||||||||||||||||||
isLACluster = true | ||||||||||||||||||||||||||||
log.Printf("[INFO] Log Analytics Workspace %q (Resource Group %q): SKU is linked to Log Analytics cluster", name, resourceGroup) | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
@@ -221,7 +220,7 @@ func resourceLogAnalyticsWorkspaceCreateUpdate(d *pluginsdk.ResourceData, meta i | |||||||||||||||||||||||||||
t := d.Get("tags").(map[string]interface{}) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if isLACluster { | ||||||||||||||||||||||||||||
sku.Name = "lacluster" | ||||||||||||||||||||||||||||
sku.Name = workspaces.WorkspaceSkuNameEnumLACluster | ||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this maybe a breaking change depending on how the new enum cases the value. In the previous version we used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll need to do a state migration and fix it on read perhapes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ziyeqf - Are you able to check if this is an issue (i.e. build one with a released version, then manage it with your updated code) and add the state migration if needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My test steps:
My explain is: For the casing change here, it's only between provider and service, we used to use Code ref: terraform-provider-azurerm/internal/services/loganalytics/log_analytics_workspace_resource.go Lines 382 to 394 in 4ce0783
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @ziyeqf - I think you should test with a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jackofallops I don't think there will be a config with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
sorry for typo, it's "not" allowed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. previous versions allowed lacluster - we'll need to account for that as we don't know what version someone will be upgrading from so we can't make that asausmption There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So.. we need to allow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apologies for the back and forth @ziyeqf. Your implementation here is correct. We are only setting |
||||||||||||||||||||||||||||
} else if skuName == "" { | ||||||||||||||||||||||||||||
// Default value if sku is not defined | ||||||||||||||||||||||||||||
sku.Name = workspaces.WorkspaceSkuNameEnumPerGBTwoZeroOneEight | ||||||||||||||||||||||||||||
|
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 this worked before this means you are going to affect peoples configurations?
How come this is needed now?
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.
Per the description in #17069, it used to make it not "force new", but still changed. then, due to SDK upgraded, it becomes "force new" again. fix this workaround only to make it not "force new", "ignore_changes" is still needed.
I have no idea what's this acctest status before sdk upgradtion, because it has been skipped on TC...But on current
main
branch we can see it fails and the property shows "force replcement"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.
again, we shouldn't need to ignore changes, its a sign something is wrong with the resource.
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 this seems to be a separate issue from the one being fixed in this PR, I'm going to remove this until we dedicate some more time to looking into it