|
| 1 | +# Implementation Summary: Add PriorityScaleInUnhealthy Parameter |
| 2 | + |
| 3 | +## Change ID |
| 4 | +`add-as-priority-scale-in-unhealthy` |
| 5 | + |
| 6 | +## Status |
| 7 | +✅ **IMPLEMENTED** (10/11 tasks completed) |
| 8 | + |
| 9 | +## Implementation Date |
| 10 | +2025-12-10 |
| 11 | + |
| 12 | +## Overview |
| 13 | +Successfully added support for the `priority_scale_in_unhealthy` parameter to the `tencentcloud_as_scaling_group` resource. This parameter controls whether unhealthy instances should be prioritized during scale-in operations in TencentCloud Auto Scaling. |
| 14 | + |
| 15 | +## Changes Made |
| 16 | + |
| 17 | +### 1. Schema Definition ✅ |
| 18 | +**File**: `tencentcloud/services/as/resource_tc_as_scaling_group.go` |
| 19 | +- Added `priority_scale_in_unhealthy` field at line 188-192 |
| 20 | +- Type: `schema.TypeBool` |
| 21 | +- Optional: true |
| 22 | +- Description: "Whether to enable priority for unhealthy instances during scale-in operations. If set to `true`, unhealthy instances will be removed first when scaling in." |
| 23 | + |
| 24 | +### 2. Create Operation ✅ |
| 25 | +**File**: `tencentcloud/services/as/resource_tc_as_scaling_group.go` |
| 26 | +- Added field retrieval at line 339: `priorityScaleInUnhealthy = d.Get("priority_scale_in_unhealthy").(bool)` |
| 27 | +- Updated condition check at line 342 to include the new field |
| 28 | +- Added to `ServiceSettings` struct at line 357: `PriorityScaleInUnhealthy: &priorityScaleInUnhealthy` |
| 29 | + |
| 30 | +### 3. Read Operation ✅ |
| 31 | +**File**: `tencentcloud/services/as/resource_tc_as_scaling_group.go` |
| 32 | +- Added `d.Set` call at lines 496-498 to read the parameter value from state |
| 33 | +- Follows the same pattern as other ServiceSettings fields |
| 34 | + |
| 35 | +### 4. Update Operation ✅ |
| 36 | +**File**: `tencentcloud/services/as/resource_tc_as_scaling_group.go` |
| 37 | +- Added change detection at line 626: `d.HasChange("priority_scale_in_unhealthy")` |
| 38 | +- Updated `updateAttrs` slice at line 627 to include the new field |
| 39 | +- Added field retrieval at line 639: `priorityScaleInUnhealthy := d.Get("priority_scale_in_unhealthy").(bool)` |
| 40 | +- Added to `ServiceSettings` struct at line 646: `PriorityScaleInUnhealthy: &priorityScaleInUnhealthy` |
| 41 | + |
| 42 | +### 5. Testing ✅ |
| 43 | +**File**: `tencentcloud/services/as/resource_tc_as_scaling_group_test.go` |
| 44 | +- Added test assertion at line 145: `resource.TestCheckResourceAttr(..., "priority_scale_in_unhealthy", "true")` |
| 45 | +- Added test configuration at line 281: `priority_scale_in_unhealthy = true` |
| 46 | + |
| 47 | +### 6. Documentation ✅ |
| 48 | +**File**: `tencentcloud/services/as/resource_tc_as_scaling_group.md` |
| 49 | +- Added parameter to complete example at line 97: `priority_scale_in_unhealthy = true` |
| 50 | +- Documentation will be auto-generated from schema description via `make doc` |
| 51 | + |
| 52 | +### 7. Code Quality ✅ |
| 53 | +- Code formatting applied with `gofmt` |
| 54 | +- No new linting errors introduced |
| 55 | +- Code compiles successfully |
| 56 | +- Follows existing patterns and conventions |
| 57 | + |
| 58 | +## Files Modified |
| 59 | + |
| 60 | +| File | Lines Changed | Description | |
| 61 | +|------|---------------|-------------| |
| 62 | +| `tencentcloud/services/as/resource_tc_as_scaling_group.go` | ~20 additions | Added schema, create, read, update logic | |
| 63 | +| `tencentcloud/services/as/resource_tc_as_scaling_group_test.go` | 2 additions | Added test assertions and config | |
| 64 | +| `tencentcloud/services/as/resource_tc_as_scaling_group.md` | 1 addition | Added example usage | |
| 65 | +| `openspec/changes/add-as-priority-scale-in-unhealthy/tasks.md` | Updated | Marked tasks as completed | |
| 66 | + |
| 67 | +## Testing Status |
| 68 | + |
| 69 | +### Automated Testing ✅ |
| 70 | +- **Unit Tests**: N/A (Provider uses acceptance tests) |
| 71 | +- **Compilation**: ✅ Code compiles without errors |
| 72 | +- **Linting**: ✅ No new linting errors introduced |
| 73 | +- **Formatting**: ✅ Code properly formatted with gofmt |
| 74 | + |
| 75 | +### Manual Testing ⏳ |
| 76 | +- **Status**: Pending (requires TencentCloud environment access) |
| 77 | +- **Required Actions**: |
| 78 | + 1. Create a scaling group with `priority_scale_in_unhealthy = true` |
| 79 | + 2. Verify setting is applied in TencentCloud console |
| 80 | + 3. Update parameter to `false` and verify change |
| 81 | + 4. Test import functionality |
| 82 | + |
| 83 | +## API Mapping |
| 84 | + |
| 85 | +| Terraform Field | API Field | Location | |
| 86 | +|----------------|-----------|----------| |
| 87 | +| `priority_scale_in_unhealthy` | `ServiceSettings.PriorityScaleInUnhealthy` | Create/Modify/Describe AutoScalingGroup | |
| 88 | + |
| 89 | +## Compatibility |
| 90 | + |
| 91 | +### Backward Compatibility ✅ |
| 92 | +- **Breaking Changes**: None |
| 93 | +- **Default Behavior**: Unchanged (field is optional) |
| 94 | +- **State Migration**: Not required |
| 95 | +- **Existing Configurations**: Continue to work without modification |
| 96 | + |
| 97 | +### API Compatibility ✅ |
| 98 | +- **TencentCloud SDK**: Uses existing SDK version (already in vendor) |
| 99 | +- **API Version**: v20180419 |
| 100 | +- **Field Support**: Confirmed in API documentation |
| 101 | + |
| 102 | +## Example Usage |
| 103 | + |
| 104 | +```hcl |
| 105 | +resource "tencentcloud_as_scaling_group" "example" { |
| 106 | + scaling_group_name = "example-scaling-group" |
| 107 | + configuration_id = tencentcloud_as_scaling_config.example.id |
| 108 | + max_size = 10 |
| 109 | + min_size = 0 |
| 110 | + vpc_id = tencentcloud_vpc.example.id |
| 111 | + subnet_ids = [tencentcloud_subnet.example.id] |
| 112 | + |
| 113 | + # Enable priority scale-in for unhealthy instances |
| 114 | + priority_scale_in_unhealthy = true |
| 115 | + |
| 116 | + # Other ServiceSettings parameters |
| 117 | + replace_monitor_unhealthy = true |
| 118 | + scaling_mode = "WAKE_UP_STOPPED_SCALING" |
| 119 | +} |
| 120 | +``` |
| 121 | + |
| 122 | +## Known Issues |
| 123 | +None |
| 124 | + |
| 125 | +## Follow-up Actions |
| 126 | +1. **Manual Validation** (Task 5.2): Requires access to TencentCloud environment |
| 127 | + - Create test scaling group |
| 128 | + - Verify parameter behavior |
| 129 | + - Test update operations |
| 130 | + - Validate import functionality |
| 131 | + |
| 132 | +2. **Acceptance Test Execution**: Run with TencentCloud credentials |
| 133 | + ```bash |
| 134 | + TF_ACC=1 go test ./tencentcloud/services/as -v -run TestAccTencentCloudAsScalingGroup |
| 135 | + ``` |
| 136 | + |
| 137 | +## References |
| 138 | +- **Proposal**: `openspec/changes/add-as-priority-scale-in-unhealthy/proposal.md` |
| 139 | +- **Design**: `openspec/changes/add-as-priority-scale-in-unhealthy/design.md` |
| 140 | +- **Tasks**: `openspec/changes/add-as-priority-scale-in-unhealthy/tasks.md` |
| 141 | +- **API Docs**: |
| 142 | + - [CreateAutoScalingGroup](https://cloud.tencent.com/document/product/377/20440) |
| 143 | + - [DescribeAutoScalingGroups](https://cloud.tencent.com/document/product/377/20438) |
| 144 | + - [ModifyAutoScalingGroup](https://cloud.tencent.com/document/product/377/20433) |
| 145 | + |
| 146 | +## Conclusion |
| 147 | +Implementation successfully completed following OpenSpec workflow and Terraform provider best practices. The change is minimal, focused, and follows established patterns. Code is ready for manual validation and deployment pending successful acceptance testing. |
0 commit comments