-
Notifications
You must be signed in to change notification settings - Fork 107
Resolve database pending_updates duplicates bug; refactor database schema & model sharing #2166
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
base: dev
Are you sure you want to change the base?
Resolve database pending_updates duplicates bug; refactor database schema & model sharing #2166
Conversation
Release v2.30.0
Release v2.31.0
Release v2.31.1
Release v2.32.0
PR Release v2.33.0
Release v2.34.1
Release v2.34.2
Release v2.35.1
Release v2.36.0
Release v2.37.0
Release v2.39.0
Release v2.40.0
Release v2.41.0
Release v3.0.0
Bump go.mod to v3
Release v3.1.0
Release v3.1.1
Release v3.2.0
Release v3.3.0
…e#2162) * Fix database pending model handling * fix lint * Fix CheckDestroy * fix regex * Fix destroy checks * Rework response overrides * Uncomment assertions
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.
Pull Request Overview
This PR resolves a bug where duplicate entries appeared in the pending_updates field of managed database resources and refactors the database-related code by centralizing shared functionality into a new databaseshared package.
- Implements deduplication logic for pending updates using a new
FrameworkDropDuplicatesIterhelper function - Extracts common database models, schema attributes, and utility functions into a shared
linode/helper/databasesharedpackage - Adds comprehensive test coverage with HTTP client modification support to verify the deduplication fix
Reviewed Changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| linode/helper/http.go | Adds HTTPClientModifier type definition for modifying HTTP clients |
| linode/helper/framework_util.go | Adds FrameworkDropDuplicatesIter function for deduplicating iterator values |
| linode/helper/databaseshared/*.go | New package containing shared database models, schemas, and utilities extracted from individual database modules |
| linode/helper/database.go | Removed (functionality moved to databaseshared package) |
| linode/framework_provider_config.go | Adds support for applying HTTP client modifiers during client initialization |
| linode/databases/*.go | Updates to use shared database models from databaseshared package |
| linode/database*/*.go | Refactored to use shared functionality from databaseshared package instead of duplicated code |
| linode/acceptance/*.go | Adds test infrastructure for HTTP response overrides and database-specific test helpers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "day_of_week": resourceSchema.StringAttribute{ | ||
| Description: "The numeric reference for the day of the week to perform maintenance.", | ||
| Optional: true, | ||
| Computed: true, | ||
| Validators: []validator.String{ | ||
| stringvalidator.OneOf(slices.Collect(maps.Keys(dayOfWeekStrToKey))...), |
Copilot
AI
Nov 8, 2025
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 day_of_week attribute is defined as StringAttribute in the resource schema (line 42) but the model field DayOfWeek is types.Int64 (line 24). This type mismatch will cause runtime errors when converting between schema and model.
| "day_of_week": resourceSchema.StringAttribute{ | |
| Description: "The numeric reference for the day of the week to perform maintenance.", | |
| Optional: true, | |
| Computed: true, | |
| Validators: []validator.String{ | |
| stringvalidator.OneOf(slices.Collect(maps.Keys(dayOfWeekStrToKey))...), | |
| "day_of_week": resourceSchema.Int64Attribute{ | |
| Description: "The numeric reference for the day of the week to perform maintenance.", | |
| Optional: true, | |
| Computed: true, | |
| Validators: []validator.Int64{ | |
| int64validator.OneOf(slices.Collect(maps.Values(dayOfWeekStrToKey))...), |
| Default: stringdefault.StaticString("weekly"), | ||
| }, | ||
| "hour_of_day": resourceSchema.Int64Attribute{ | ||
| Description: "How frequently maintenance occurs. Currently can only be weekly.", |
Copilot
AI
Nov 8, 2025
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 description for hour_of_day is incorrect. It describes maintenance frequency instead of the hour of day when maintenance should occur. This should describe the hour value (0-23) when maintenance is scheduled.
| Description: "How frequently maintenance occurs. Currently can only be weekly.", | |
| Description: "The hour of the day (0-23) when maintenance is scheduled to occur.", |
| }, | ||
| } | ||
|
|
||
| var ObjectTypePrivateNetwork = ResourceAttributeUpdates.GetType().(types.ObjectType) |
Copilot
AI
Nov 8, 2025
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.
Variable ObjectTypePrivateNetwork incorrectly references ResourceAttributeUpdates instead of PrivateNetworkResourceAttribute. This will cause a type mismatch when flattening private network data.
| var ObjectTypePrivateNetwork = ResourceAttributeUpdates.GetType().(types.ObjectType) | |
| var ObjectTypePrivateNetwork = PrivateNetworkResourceAttribute.GetType().(types.ObjectType) |
| }, | ||
| }, | ||
| }, | ||
| "private_network": databaseshared.PrivateNetworkDataSourceAttribute, |
Copilot
AI
Nov 8, 2025
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.
Using PrivateNetworkDataSourceAttribute for a resource schema is incorrect. Should use PrivateNetworkResourceAttribute instead, as this is a resource, not a data source.
| "private_network": databaseshared.PrivateNetworkDataSourceAttribute, | |
| "private_network": databaseshared.PrivateNetworkResourceAttribute, |
📝 Description
What does this PR do and why is this change necessary?
✔️ How to Test
What are the steps to reproduce the issue or verify the changes?
How do I run the relevant unit/integration tests?
📷 Preview
If applicable, include a screenshot or code snippet of this change. Otherwise, please remove this section.