Skip to content

Conversation

@lgarber-akamai
Copy link
Contributor

📝 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.

ezilber-akamai and others added 30 commits October 22, 2024 13:38
…e#2162)

* Fix database pending model handling

* fix lint

* Fix CheckDestroy

* fix regex

* Fix destroy checks

* Rework response overrides

* Uncomment assertions
@lgarber-akamai lgarber-akamai requested a review from a team as a code owner November 8, 2025 02:57
@lgarber-akamai lgarber-akamai added improvement for improvements in existing functionality in the changelog. bugfix for any bug fixes in the changelog. labels Nov 8, 2025
@lgarber-akamai lgarber-akamai requested review from ezilber-akamai and yec-akamai and removed request for a team, ezilber-akamai and yec-akamai November 8, 2025 02:57
@lgarber-akamai lgarber-akamai marked this pull request as draft November 8, 2025 02:57
@lgarber-akamai lgarber-akamai changed the base branch from main to dev November 8, 2025 02:58
@lgarber-akamai lgarber-akamai changed the title Fix/database pending updates set Resolve database pending_updates duplicates bug; refactor database schema & model sharing Nov 8, 2025
Copy link
Contributor

Copilot AI left a 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 FrameworkDropDuplicatesIter helper function
  • Extracts common database models, schema attributes, and utility functions into a shared linode/helper/databaseshared package
  • 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.

Comment on lines 42 to 47
"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))...),
Copy link

Copilot AI Nov 8, 2025

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.

Suggested change
"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))...),

Copilot uses AI. Check for mistakes.
Default: stringdefault.StaticString("weekly"),
},
"hour_of_day": resourceSchema.Int64Attribute{
Description: "How frequently maintenance occurs. Currently can only be weekly.",
Copy link

Copilot AI Nov 8, 2025

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.

Suggested change
Description: "How frequently maintenance occurs. Currently can only be weekly.",
Description: "The hour of the day (0-23) when maintenance is scheduled to occur.",

Copilot uses AI. Check for mistakes.
},
}

var ObjectTypePrivateNetwork = ResourceAttributeUpdates.GetType().(types.ObjectType)
Copy link

Copilot AI Nov 8, 2025

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.

Suggested change
var ObjectTypePrivateNetwork = ResourceAttributeUpdates.GetType().(types.ObjectType)
var ObjectTypePrivateNetwork = PrivateNetworkResourceAttribute.GetType().(types.ObjectType)

Copilot uses AI. Check for mistakes.
},
},
},
"private_network": databaseshared.PrivateNetworkDataSourceAttribute,
Copy link

Copilot AI Nov 8, 2025

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.

Suggested change
"private_network": databaseshared.PrivateNetworkDataSourceAttribute,
"private_network": databaseshared.PrivateNetworkResourceAttribute,

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix for any bug fixes in the changelog. improvement for improvements in existing functionality in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants