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

[Enhancement] - Add os_disk.storage_type and data_disk.storage_type to azurerm_image #26936

Merged

Conversation

bruceharrison1984
Copy link
Contributor

@bruceharrison1984 bruceharrison1984 commented Aug 5, 2024

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

This just adds a two new properties that allows choosing the type of disk that will be utilized by downstream VMs created with a particular image.

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevent documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • azurerm_image - support for the os_disk.storage_type and data_disk.storage_type properties

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

@bruceharrison1984 bruceharrison1984 changed the title [Enhancement] - Add os_disk.storage_type to azurerm_image [Enhancement] - Add os_disk.storage_type and data_disk.storage_type to azurerm_image Aug 5, 2024
@bruceharrison1984 bruceharrison1984 marked this pull request as ready for review August 5, 2024 16:07
Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Hi @bruceharrison1984 - Thanks for the PR. Unfortunately this is a breaking change for users as the new property has a default value. I've left a little guidance on how to address this below, but reach out over slack to the team if you need further help.

internal/services/compute/image_resource.go Show resolved Hide resolved
internal/services/compute/image_resource.go Outdated Show resolved Hide resolved
@bruceharrison1984
Copy link
Contributor Author

@jackofallops I believe I've hidden it all behind the feature flag, though it looks like there are multiple ways to accomplish this.

Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

@bruceharrison1984 Thanks for making that change! I've made some more comments inline below, if you can take a look at these then this should be good to merge 👍

internal/services/compute/image_resource.go Outdated Show resolved Hide resolved
Comment on lines 68 to 69
1. `id` (String) Azure Resource Manager ID. No newline at end of file
1. `id` (String) Azure Resource Manager ID.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what's happening here, a stealthy space/newline maybe? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like a trailing whitespace was removed by running the linter.

Not sure if we want to revert it, or just leave it?

website/docs/r/image.html.markdown Outdated Show resolved Hide resolved
website/docs/r/image.html.markdown Outdated Show resolved Hide resolved
Comment on lines 474 to 479

if v.StorageAccountType != nil && features.FourPointOhBeta() {
output = append(output, map[string]interface{}{
"storage_type": string(*v.StorageAccountType),
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this will work as expected, since the intended output of this helper func should be a single map[string]interface{} containing all properties (contained as the only element of a []interface{}

Due to GH limitations I can't suggest inline, but something like this should work:

			properties := map[string]interface{}{
				"blob_uri":               blobUri,
				"caching":                caching,
				"managed_disk_id":        managedDiskId,
				"os_type":                string(v.OsType),
				"os_state":               string(v.OsState),
				"size_gb":                diskSizeGB,
				"disk_encryption_set_id": diskEncryptionSetId,
			}

			if v.StorageAccountType != nil && features.FourPointOhBeta() {
				properties["storage_type"] = string(*v.StorageAccountType)
			}

			output = append(output, properties)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 508 to 522

output = append(output, map[string]interface{}{
"blob_uri": blobUri,
"caching": caching,
"lun": int(disk.Lun),
"managed_disk_id": managedDiskId,
"size_gb": diskSizeGb,
})

if disk.StorageAccountType != nil && features.FourPointOhBeta() {
output = append(output, map[string]interface{}{
"storage_type": string(*disk.StorageAccountType),
})
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

As above, we should output a single map here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

bruceharrison1984 and others added 2 commits August 7, 2024 09:17
Co-authored-by: Tom Bamford <tom@bamford.io>
Co-authored-by: Tom Bamford <tom@bamford.io>
bruceharrison1984 and others added 2 commits August 7, 2024 09:17
Co-authored-by: Tom Bamford <tom@bamford.io>
@github-actions github-actions bot added size/M and removed size/S labels Aug 7, 2024
@bruceharrison1984
Copy link
Contributor Author

@manicminer Is there a way to run tests against Beta 4.0 features? Right now the tests pass, but only because none of the 4.0 code is under test.

@manicminer
Copy link
Contributor

@bruceharrison1984 You can export the environment variable ARM_FOURPOINTZERO_BETA=true and both the provider and the acceptance tests will pick that up.

@bruceharrison1984
Copy link
Contributor Author

@manicminer Augmenting the tests with the new storage_type property and running them in 4.0 mode all passed, so it should be ready to go.

Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

Thanks @bruceharrison1984, this is mostly looking great! Could you also add an acceptance test for this property? You should be able to find examples of other tests that are gated behind the 4.0 feature flag (via the features.FourPointOh() function).

I've also made a couple more comments, if you could take a look at those as well as the test coverage, then this will be ready for merging 👍

internal/services/compute/image_resource.go Outdated Show resolved Hide resolved
internal/services/compute/image_resource.go Outdated Show resolved Hide resolved
internal/services/compute/image_resource.go Outdated Show resolved Hide resolved
internal/services/compute/image_resource.go Outdated Show resolved Hide resolved
internal/services/compute/image_resource.go Outdated Show resolved Hide resolved
internal/services/compute/image_resource.go Outdated Show resolved Hide resolved
Co-authored-by: Tom Bamford <tom@bamford.io>
Co-authored-by: Tom Bamford <tom@bamford.io>
@github-actions github-actions bot added size/S and removed size/M labels Aug 8, 2024
bruceharrison1984 and others added 3 commits August 8, 2024 14:28
Co-authored-by: Tom Bamford <tom@bamford.io>
Co-authored-by: Tom Bamford <tom@bamford.io>
Co-authored-by: Tom Bamford <tom@bamford.io>
@github-actions github-actions bot added size/M and removed size/S labels Aug 8, 2024
@github-actions github-actions bot added size/L and removed size/M labels Aug 12, 2024
@bruceharrison1984
Copy link
Contributor Author

@manicminer All existing tests have been updated and gated with the new 4.0 property. I'll have another PR for this same resource shortly, so this should help grease the skids for that one.

Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

Thanks @bruceharrison1984, this LGTM! 👍

@manicminer
Copy link
Contributor

Test results

Screenshot 2024-08-15 at 11 51 51

@manicminer manicminer merged commit 199c2f5 into hashicorp:main Aug 15, 2024
34 checks passed
@github-actions github-actions bot added this to the v3.116.0 milestone Aug 15, 2024
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants