Skip to content
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 dependent resources to compute.WindowsVirtualMachineScaleSet and fix conflicts #490

Merged
merged 2 commits into from
Jul 21, 2023

Conversation

turkenf
Copy link
Collaborator

@turkenf turkenf commented Jul 10, 2023

Description of your changes

This PR fixes the conflicting parameters and adds dependent resources to make uptestable to compute.WindowsVirtualMachineScaleSet resource.

Fixes: #487

I have:

  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

Manually and Uptest: https://github.com/upbound/provider-azure/actions/runs/5512679934

NAME                                     READY   SYNCED   EXTERNAL-NAME   AGE
resourcegroup.azure.upbound.io/example   True    True     example         42m

NAME                                                             READY   SYNCED   EXTERNAL-NAME   AGE
windowsvirtualmachinescaleset.compute.azure.upbound.io/example   True    True     example         8m34s

NAME                                              READY   SYNCED   EXTERNAL-NAME   AGE
virtualnetwork.network.azure.upbound.io/example   True    True     example         42m

NAME                                       READY   SYNCED   EXTERNAL-NAME   AGE
subnet.network.azure.upbound.io/internal   True    True     internal        42m

@turkenf
Copy link
Collaborator Author

turkenf commented Jul 10, 2023

/test-examples="examples/compute/windowsvirtualmachinescaleset.yaml"

@@ -36,6 +36,10 @@ func Configure(p *config.Provider) {
"virtual_machine_scale_set_id"},
}
})
p.AddResourceConfigurator("azurerm_windows_virtual_machine_scale_set", func(r *config.Resource) {
// In version 3.21.0 the `scale_in_policy` parameter was removed, and replaced by `scale_in`
config.MoveToStatus(r.TerraformResource, "scale_in_policy")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not move this to status as it would violate the deprecation protocol, i.e., a parameter being deprecated stays available in deprecated state for a series of releases together with a replacement parameter (in this case the scale_in parameter), until it's finally actually removed.

But if this deprecated parameter and the new parameter are mutually exclusive, then we need to do a late initialization configuration. I will also open an upjet issue to make these configurations automatically.

We also need to add a deprecation comment to the spec.forProvider field. We can utilize the ArgumentDocs resource configuration parameter for this purpose. An example for this can be found here:
https://github.com/upbound/provider-gcp/blob/81dcd6d783f700deeab4e8a77335bc14758d2b4a/config/notebooks/config.go#L29

Please also see: https://github.com/golang/go/wiki/Deprecated

@turkenf
Copy link
Collaborator Author

turkenf commented Jul 17, 2023

/test-examples="examples/compute/windowsvirtualmachinescaleset.yaml"

@turkenf
Copy link
Collaborator Author

turkenf commented Jul 19, 2023

/test-examples="examples/compute/windowsvirtualmachinescaleset.yaml"

1 similar comment
@turkenf
Copy link
Collaborator Author

turkenf commented Jul 21, 2023

/test-examples="examples/compute/windowsvirtualmachinescaleset.yaml"

@@ -680,6 +680,7 @@ type WindowsVirtualMachineScaleSetObservation struct {
// A scale_in block as defined below.
ScaleIn []WindowsVirtualMachineScaleSetScaleInObservation `json:"scaleIn,omitempty" tf:"scale_in,omitempty"`

// Deprecated, scale_in_policy will be removed in favour of the scale_in code block.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Deprecated, scale_in_policy will be removed in favour of the scale_in code block.
// Deprecated: ...

Please also see: https://github.com/golang/go/wiki/Deprecated

r.LateInitializer = config.LateInitializer{
IgnoredFields: []string{"scale_in_policy"},
}
r.MetaResource.ArgumentDocs["scale_in_policy"] = "Deprecated, scale_in_policy will be removed in favour of the scale_in code block."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had better use the CRD field names instead of the Terraform configuration parameter names:

Suggested change
r.MetaResource.ArgumentDocs["scale_in_policy"] = "Deprecated, scale_in_policy will be removed in favour of the scale_in code block."
r.MetaResource.ArgumentDocs["scale_in_policy"] = "Deprecated, scaleInPolicy will be removed in favour of the scaleIn code block."

Copy link
Collaborator

@ulucinar ulucinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @turkenf, lgtm.

@turkenf turkenf merged commit 840ddd2 into crossplane-contrib:main Jul 21, 2023
8 checks passed
@turkenf turkenf deleted the issue-487 branch July 21, 2023 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error observing WindowsVirtualMachineScaleSet
2 participants