Service offering resource update#252
Conversation
- Add service_offering_details attribute to cloudstack_service_offering resource - Support for GPU configuration with pciDevice and vgpuType parameters - Include comprehensive test coverage and documentation - Add practical examples for GPU service offerings - Addresses issue apache#246
- Update service offering documentation with GPU examples - Add service_offering_details parameter documentation - Update CHANGELOG with new feature entry - Include practical examples for GPU configuration
- Fix code formatting to comply with Go standards - Align map fields and remove trailing whitespace - Required for CI/CD pipeline to pass
add missing cpu_speed
… in service offering
…ent updates after creation
…ive tests for offering types
…d enhanced parameter descriptions
…rom version control
|
@jeanvetorello There was already work done for service offerings around fixed, constrained and unconstrained. Please see the following for discussions around this. @poddm can you review this and give your input on this as your commit a while back took a different aproach and I know we had this discussion about this before. (see links above) @DaanHoogland Also, what is your opinion on this as we need to pick a path and stick to it. We shouldn't have multiple resource files out there for the same thing We need to make sure we are using the most recent framework/sdk as well. This is what was decided back then on method to split up the resources
|
| // | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| // |
There was a problem hiding this comment.
license needs to be there
| !command/test-fixtures/**/.terraform/ | ||
| .terraform.lock.hcl | ||
| provider.tf | ||
| examples/ No newline at end of file |
There was a problem hiding this comment.
| examples/ | |
| examples/ | |
@CodeBleu , I completely agree with the blanket statement, but am sure I am missing some context. on first sight I thought you were talking about production code vs test code, but I see no issue there. Can you explain? |
@DaanHoogland There are both |
|
@CodeBleu, I think you're right. We should deprecated this resource. I can open a PR if thats whats decided. |
makes sense, @CodeBleu .
thanks @poddm . it makes no sense to maintain two SDKs for the same API. Will we then defer merging this? or is this a parallel effort? |
|
I need to remove old duplicate service offering files to pass all tests. Should I proceed? |
There was a problem hiding this comment.
Pull request overview
This PR modernizes the Service Offering support by consolidating the previously split “fixed / constrained / unconstrained” resources into an updated, unified cloudstack_service_offering resource intended to align with CloudStack API v4.21, alongside expanded docs and acceptance tests.
Changes:
- Expanded
cloudstack_service_offeringschema/Create/Read logic to cover many more CloudStack service offering parameters (GPU, IOPS/bandwidth, lease, etc.). - Removed the legacy split service offering resources/util/schema/models and their dedicated docs/tests.
- Reworked documentation into a single
service_offeringdoc page and significantly expanded acceptance testing.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/r/service_offering.html.markdown | Replaces/expands service offering documentation into a single, detailed page. |
| website/docs/r/service_offering_unconstrained.html.markdown | Deletes legacy unconstrained resource documentation. |
| website/docs/r/service_offering_fixed.html.markdown | Deletes legacy fixed resource documentation. |
| website/docs/r/service_offering_constrained.html.markdown | Deletes legacy constrained resource documentation. |
| cloudstack/resource_cloudstack_service_offering.go | Major expansion of the unified service offering resource schema and CRUD logic. |
| cloudstack/resource_cloudstack_service_offering_test.go | Adds/updates extensive acceptance test coverage for the unified resource. |
| cloudstack/data_source_cloudstack_service_offering.go | Expands the service offering data source with many additional computed attributes. |
| cloudstack/data_source_cloudstack_service_offering_test.go | Updates data source acceptance test to check additional attribute parity. |
| cloudstack/provider_v6.go | Removes registration of the deleted legacy service offering resources. |
| cloudstack/service_offering_util.go | Deletes legacy shared helper logic for split resources. |
| cloudstack/service_offering_unconstrained_resource.go | Deletes legacy unconstrained resource implementation. |
| cloudstack/service_offering_unconstrained_resource_test.go | Deletes legacy unconstrained acceptance tests. |
| cloudstack/service_offering_schema.go | Deletes legacy split-resource schema definitions. |
| cloudstack/service_offering_models.go | Deletes legacy split-resource models. |
| cloudstack/service_offering_fixed_resource.go | Deletes legacy fixed resource implementation. |
| cloudstack/service_offering_fixed_resource_test.go | Deletes legacy fixed acceptance tests. |
| cloudstack/service_offering_constrained_resource.go | Deletes legacy constrained resource implementation. |
| cloudstack/service_offering_constrained_resource_test.go | Deletes legacy constrained acceptance tests. |
| .gitignore | Adds examples/ to ignored paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if details, ok := d.GetOk("service_offering_details"); ok { | ||
| serviceOfferingDetails := make(map[string]string) | ||
| for k, v := range details.(map[string]interface{}) { | ||
| serviceOfferingDetails[k] = v.(string) | ||
| } | ||
| p.SetServiceofferingdetails(serviceOfferingDetails) | ||
| } |
| if v, ok := d.GetOk("service_offering_details"); ok { | ||
| details := make(map[string]string) | ||
| for key, value := range v.(map[string]interface{}) { | ||
| details[key] = value.(string) | ||
| } | ||
| p.SetServiceofferingdetails(details) | ||
| } |
| if v, ok := d.GetOk("zone_id"); ok { | ||
| zones := make([]string, 0) | ||
| for _, z := range v.([]interface{}) { | ||
| zones = append(zones, z.(string)) | ||
| } | ||
| p.SetZoneid(zones) | ||
| } |
| "storage_type": { | ||
| Description: "The storage type of the service offering", | ||
| Type: schema.TypeString, | ||
| Optional: true, | ||
| ForceNew: true, | ||
| Default: "shared", | ||
| }, |
| "hypervisor_snapshot_reserve": { | ||
| Description: "Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)", | ||
| Type: schema.TypeInt, | ||
| Optional: true, | ||
| Computed: true, | ||
| }, |
|
|
||
| * `storage_type` - (Optional) The storage type of the service offering. Valid values are `local` and `shared`. Changing this forces a new resource to be created. | ||
|
|
||
| * `storage_tags` - (Optional) Comma-separated list of tags for matching storage pools. Changing this forces a new resource to be created. |
| * `bytes_read_rate` - (Optional) Bytes read rate in bytes per second. Changing this forces a new resource to be created. | ||
|
|
||
| * `min_memory` - (Optional) Minimum memory (in MB) allowed for customized offerings. | ||
| Changing this forces a new resource to be created. | ||
| * `bytes_read_rate_max` - (Optional) Burst bytes read rate in bytes per second. Changing this forces a new resource to be created. | ||
|
|
||
| * `max_memory` - (Optional) Maximum memory (in MB) allowed for customized offerings. | ||
| Changing this forces a new resource to be created. | ||
| * `bytes_read_rate_max_length` - (Optional) Length of the burst bytes read rate in seconds. Changing this forces a new resource to be created. |
| * `iops_read_rate` - (Optional) IO requests read rate in IOPS. Changing this forces a new resource to be created. | ||
|
|
||
| * `iops_read_rate_max` - (Optional) Burst IO requests read rate in IOPS. Changing this forces a new resource to be created. | ||
|
|
||
| * `iops_read_rate_max_length` - (Optional) Length of the burst IO requests read rate in seconds. Changing this forces a new resource to be created. | ||
|
|
||
| * `iops_write_rate` - (Optional) IO requests write rate in IOPS. Changing this forces a new resource to be created. | ||
|
|
||
| * `iops_write_rate_max` - (Optional) Burst IO requests write rate in IOPS. Changing this forces a new resource to be created. | ||
|
|
||
| * `iops_write_rate_max_length` - (Optional) Length of the burst IO requests write rate in seconds. Changing this forces a new resource to be created. |
| * `disk_iops_min` - (Optional) Minimum IOPS for the disk. Changing this forces a new resource to be created. | ||
|
|
||
| * `disk_iops_max` - (Optional) Maximum IOPS for the disk. Changing this forces a new resource to be created. | ||
|
|
| * `id` - The ID of the service offering. | ||
| * `created` - The date when the service offering was created. | ||
|
|


Overview
This PR completely updates the
cloudstack_service_offeringresource to support CloudStack API version 4.21, achieving 100% SDK coverage with all 54 parameters fromCreateServiceOfferingParamsfully implemented.Motivation
I needed to update the Service Offering API to the latest CloudStack version (4.21) to support modern features like GPU configuration, advanced IOPS settings, and dynamic scaling. The existing implementation was missing critical parameters and had several drift issues.
What's New
1. Complete API v4.21 Coverage (54/54 Parameters)
All parameters from CloudStack Go SDK v2
CreateServiceOfferingParamsare now implemented:CPU & Memory:
cpu_number,cpu_speed,memorycustomized,min_cpu_number,max_cpu_numbermin_memory,max_memoryGPU Support (NEW):
gpu_card- GPU card name (maps togpucardid)gpu_type- vGPU profile UUID (maps tovgpuprofileid)gpu_count- Number of GPUsStorage:
storage_type,storage_tags,host_tagsroot_disk_size,encrypt_rootprovisioning_type,cache_modeIOPS & Bandwidth (12 parameters):
bytes_read_rate,bytes_write_ratebytes_read_rate_max,bytes_write_rate_maxbytes_read_rate_max_length,bytes_write_rate_max_lengthiops_read_rate,iops_write_rateiops_read_rate_max,iops_write_rate_maxiops_read_rate_max_length,iops_write_rate_max_lengthPerformance:
disk_iops_min,disk_iops_maxhypervisor_snapshot_reserveoffer_ha,limit_cpu_usedynamic_scaling_enabledcustomized_iopsSystem & Domain:
is_system,system_vm_typezone_id,domain_idis_volatile,deployment_plannerAdvanced:
service_offering_details(map for custom settings)2. Bug Fixes
Fixed
service_offering_detailsDriftExternal:key,External:value,purge.db.entities) causing state driftFixed
customizedParameter Logiccpu_number+memoryprovided →customized = false(Fixed Offering)customized = true+ min/max → Custom Constrainedcustomized = true+ no limits → Custom UnconstrainedIdentified ForceNew Parameters (47 of 54)
ForceNew: trueto 47 parameters based on CloudStack API limitationsdisplay_text,host_tags, andstorage_tagscan be updated in-place3. Comprehensive Testing
Added 4 new tests covering all CloudStack UI offering types:
TestAccServiceOfferingTypeFixed- Fixed CPU/memoryTestAccServiceOfferingTypeCustomConstrained- Customizable with limitsTestAccServiceOfferingTypeCustomUnconstrained- Fully customizableTestAccServiceOfferingAllUITypes- All types togetherTotal: 17 tests (13 existing + 4 new)
4. Complete Documentation
Created comprehensive documentation in
website/docs/r/service_offering.html.markdown: