-
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_kubernetes_cluster
- support for upgrade_override_setting
property
#27962
base: main
Are you sure you want to change the base?
azurerm_kubernetes_cluster
- support for upgrade_override_setting
property
#27962
Conversation
feat: implement upgrade settings for container service Revert "feat: implement upgrade settings for container service"
MaxItems: 1, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"effective_until": { |
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.
According to the guideline suggestions, we may make it a top level property.
terraform-provider-azurerm/contributing/topics/schema-design-considerations.md
Lines 75 to 85 in 778c935
Finally there are instances where the addtional fields/properties for a object/feature are optional or few in number, as shown below. | |
Example C. | |
```go | |
type ManagedClusterStorageProfileDiskCSIDriver struct { | |
Enabled *bool `json:"enabled,omitempty"` | |
Version *string `json:"version,omitempty"` | |
} | |
``` | |
In cases like these one option is to flatten the block into two top level properties: |
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.
@wuxu92, totally agree with you here, however it appears that not all of the possible fields have been exposed here as well based on the REST API documentation for this property. We should also drop the _settings
part from the name of the exposed field in the provider, also per the contributing guide. 🙂
- For blocks avoid redundant words in the name that don't add informational value e.g.
firewall_properties can be shortened to firewall, the same can apply to individual properties e.g. email_address to email.
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 only other field in the block is forceUpgrade
as a boolean, which doesn't need to be exposed. So we may only need to expose one property named upgrade_override_until
and keep the expand/flatten logic as it is 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.
I am hesistant to add this as a top level as service team indicated there may be additional properties relevant to upgrade_override_setting
added later. We may, in future, need to wrap around these properties a layer down in upgrade_override_setting
as it doesn't make sense to expose all of them in top level.
I will update the naming to upgrade_override
.
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 @hqhqhqhqhqhqhqhqhqhqhq - this looks mostly good, but I have questions on the schema design and the testing approach if you can take a look?
"upgrade_override_setting": { | ||
Type: pluginsdk.TypeList, | ||
Optional: true, | ||
MaxItems: 1, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"effective_until": { | ||
Type: pluginsdk.TypeString, | ||
Optional: true, | ||
ValidateFunc: validation.IsRFC3339Time, | ||
}, | ||
}, | ||
}, | ||
}, |
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.
Is this the only configurable property in this block? If so, it might be worth flattening this down to a single property, for example upgrade_override_until
?
What happens to this value when the specified point in time passes, is it removed from the response, or still returned?
Should we also validate that the supplied time is in the future?
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.
- There is only one property that user should configure, but service team indicated more may be added later.
- When the value is in the past in time, it will stay in the response
- I prefer not to add this check because if the time is in the past, users don't need to update it every single time; they can leave it as is (and it will not have any impact).
if isUpgradeOverrideSettingEnabled { | ||
upgradeOverrideSetting = ` | ||
upgrade_override_setting { | ||
effective_until = "2024-01-01T00:00:00Z" |
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.
Does it make sense to be testing a time in the past here? It's unlikely this will be representative of user input? Could we generate a value for this based on time.Now()
plus some realistic duration?
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.
Updated
Hi @jackofallops @WodansSon |
@hqhqhqhqhqhqhqhqhqhqhq, Thanks for pushing those changes, this LGTM 🚀 |
when will this merge? |
Hi @andyliuliming , Hashicorp team scheduled a final official review on 19th of December. If everything is good, it will be merged & released soon after.
…________________________________
From: Liming Liu ***@***.***>
Sent: Monday, December 16, 2024 1:55:09 PM
To: hashicorp/terraform-provider-azurerm ***@***.***>
Cc: Harry Qu ***@***.***>; Mention ***@***.***>
Subject: Re: [hashicorp/terraform-provider-azurerm] `azurerm_kubernetes_cluster` - support for `upgrade_override_setting` property (PR #27962)
when will this merge?
—
Reply to this email directly, view it on GitHub<#27962 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BJC4MBYVM6XQAMCBYDD36XL2FY6I3AVCNFSM6AAAAABRQ2PIMSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBUGQZTINJWGU>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
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.
@hqhqhqhqhqhqhqhqhqhqhq , thanks for pushing those changes. This looks pretty good, one last suggestion in the documentation, after that's fix I think this PR will be good to go! 🚀
Co-authored-by: Wodans Son <[email protected]>
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.
So sorry, I missed this one in the last review. 😞
Co-authored-by: Wodans Son <[email protected]>
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 pushing those changes @hqhqhqhqhqhqhqhqhqhqhq . This LGTM now! 🚀
…hub.com/hqhqhqhqhqhqhqhqhqhqhq/terraform-provider-azurerm into feat/container_service-upgrade-settings
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.
@hqhqhqhqhqhqhqhqhqhqhq , this is getting very close, however I have left a couple of new comments I would like to see addressed. Once that is done, and the tests pass. I think this should be good to go and get merged! 🚀
if d.HasChange("upgrade_override") { | ||
upgradeOverrideSettingRaw := d.Get("upgrade_override").([]interface{}) | ||
|
||
err = validateKubernetesClusterUpgradeOverrideSetting(d.GetChange("upgrade_override")) |
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.
Would it make more sense to put this logic inline rather than in a helper function to be more consistent with the other resources in the provider? I might be wrong but I believe this is the only place this function is called, so to me it would make more sense to make that logic inline, here in the update
fuction, to be more readable for future maintainers is they need to modify this code.
|
||
newOverrideSetting, canConvert := new.([]interface{}) | ||
if !canConvert || len(newOverrideSetting) == 0 { | ||
return fmt.Errorf("upgrade_override cannot be unset") |
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 here...
return fmt.Errorf("upgrade_override cannot be unset") | |
return fmt.Errorf("`upgrade_override` cannot be unset") |
@@ -2531,6 +2568,19 @@ func resourceKubernetesClusterUpdate(d *pluginsdk.ResourceData, meta interface{} | |||
return resourceKubernetesClusterRead(d, meta) | |||
} | |||
|
|||
func validateKubernetesClusterUpgradeOverrideSetting(_, new interface{}) error { |
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.
Can we remove this function and make it inline in the update
function? I think we should be able to use something like d.GetRawConfig
so we could compare the old
values of the fields against the new
values of the fields.
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.
Updated to inline function, but left it as d.Get("upgrade_override")
rather than d.GetRawConfig
because it is easier to work with the expand function below (easier to parse to []interface{}).
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.
One last thing, it appears the annotation for Notes has a new contributor docs guideline page dedicated to it so I added one more comment to address this in this PR as well. 🙂
Co-authored-by: Wodans Son <[email protected]>
Co-authored-by: Wodans Son <[email protected]>
…hub.com/hqhqhqhqhqhqhqhqhqhqhq/terraform-provider-azurerm into feat/container_service-upgrade-settings
Community Note
Description
Support for
upgrade_override_setting
property inazurerm_kubernetes_cluster
.PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Changes to existing Resource / Data Source
Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_resource
- support for thething1
property [GH-00000]This is a (please select all that apply):
Related Issue(s)
Note
If this PR changes meaningfully during the course of review please update the title and description as required.