Skip to content

openstack/db: add Trove configuration parameter APIs - #3813

Open
stias wants to merge 1 commit into
gophercloud:mainfrom
stias:feature/trove-db-configuration-parameters
Open

openstack/db: add Trove configuration parameter APIs#3813
stias wants to merge 1 commit into
gophercloud:mainfrom
stias:feature/trove-db-configuration-parameters

Conversation

@stias

@stias stias commented Jun 20, 2026

Copy link
Copy Markdown

For #3809

Split out from #3767.

Links to the line numbers/files in the OpenStack source code that support the
code in this PR:

@github-actions github-actions Bot added the edit:db This PR updates db code label Jun 20, 2026

@winiciusallan winiciusallan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @stias! I brought some comments that I have left at the old PR. Will take another time to review it thoroughly.

}

// ToParamCreateMap converts a CreateParamOpts struct into a request body.
func (opts CreateParamOpts) ToParamCreateMap() (map[string]any, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can use the existing CreateParamOpts struct here instead of creating a new one to build the request body. We avoid having an almost-duplicated struct. For example:

func (opts CreateParamOpts) ToParamCreateMap() (map[string]any, error) {
    b, err := gophercloud.BuildRequestBody(opts, "configuration-parameter")
    if err != nil {
        return nil, err
    }

    if opts.RestartRequired != nil {
        b["restart_required"] = restartRequiredToInt(opts.RestartRequired)
    }

    return b, nil
}

Does it make sense?

MaxSize *int `json:"max_size,omitempty"`
// Whether the database service needs to restart after this parameter
// changes.
RestartRequired bool `json:"restart_required"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would say that we need this field to be a *bool because we need to differentiate between the zero-value (false) and a not set value.

If a user does not set the RestartRequired, the marshaler will infer this field as false and pass it to Trove API. Since the field is not required, I believe it would be better to keep it as nil and let the Trove set the default value. Wdyt?


// UpdateParamOpts represents options for updating a configuration parameter
// for a datastore version.
type UpdateParamOpts struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ditto for ToParamCreateMap

@github-actions github-actions Bot added semver:minor Backwards-compatible change backport-v2 This PR will be backported to v2 labels Jun 29, 2026
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 63.601% (+0.06%) from 63.545% — stias:feature/trove-db-configuration-parameters into gophercloud:main

// Extract will retrieve created params from an operation result.
func (r CreateParamResult) Extract() ([]Param, error) {
var s struct {
Params []Param `json:"configuration-parameters"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know the docs at https://docs.openstack.org/api-ref/database/#id23 show the result wrapped in {"configuration-parameters": [...]} but it appears the doc is wrong if you look at the source code.

https://github.com/openstack/trove/blob/e9489ce73e2415ed277eb51ab45394f9247acc30/trove/extensions/mgmt/configuration/service.py#L96

and

https://github.com/openstack/trove/blob/e9489ce73e2415ed277eb51ab45394f9247acc30/trove/extensions/mgmt/configuration/views.py#L26

Having acceptance test would prove this works as expected (or not).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-v2 This PR will be backported to v2 edit:db This PR updates db code semver:minor Backwards-compatible change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants