Skip to content
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

DB V1: Error creating openstack_db_instance_v1: there is no availability_zone field in provider #1644

Closed
zhekazuev opened this issue Jan 19, 2024 · 1 comment

Comments

@zhekazuev
Copy link
Contributor

zhekazuev commented Jan 19, 2024

Terraform Version

Terraform v1.3.9
on linux_amd64
+ provider registry.terraform.io/terraform-provider-openstack/openstack v1.53.0

Your version of Terraform is out of date! The latest version
is 1.6.6. You can update by downloading from https://www.terraform.io/downloads.html

Affected Resource(s)

  • openstack_db_instance_v1

Terraform Configuration Files

resource "openstack_networking_network_v2" "test_dbaas" {
  name           = "test-dbaas"
  admin_state_up = "true"
}

resource "openstack_db_configuration_v1" "psql_15_3_C2R4" {
  name        = "15.3-C2R4-cfg"
  description = "Configuration for postgres 15.3 C2R4"

  datastore {
    type    = "postgresql"
    version = "15.3"
  }

  configuration {
    name  = "max_connections"
    value = 300
  }
}

resource "openstack_db_instance_v1" "test_dbaas" {
  region           = "test"
  name             = "test-dbaas-0"
  flavor_id        = "ID_REPLACED"
  configuration_id = openstack_db_configuration_v1.psql_15_3_C2R4.id
  size             = 8

  network {
    uuid = openstack_networking_network_v2.test_dbaas.id
  }

  datastore {
    type    = "postgresql"
    version = "15.3"
  }
}

Debug Output

$ terraform apply 
...
Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

openstack_db_instance_v1.test_dbaas: Creating...
╷
│ Error: Error creating openstack_db_instance_v1: Bad request with: [POST https://openstack.example.com/v1.0/ID_REPLACED/instances], error message: {"badRequest": {"code": 400, "message": "Validation error: instance 'availability_zone' is a required property"}}
│ 
│   with openstack_db_instance_v1.test_dbaas,
│   on main.tf line 37, in resource "openstack_db_instance_v1" "test_dbaas":
│   37: resource "openstack_db_instance_v1" "test_dbaas" {
│ 
╵

Expected Behavior

The availability_zone field should be present in DB V1 to ensure

Without availability_zone field some versions/installations of Openstack will return an error.
That field optional for Openstack by default, but if cluster operation's team change it and you don't have admin access to do availability_zone field optional, apply will failed.

Openstack Docs: https://docs.openstack.org/api-ref/database/#create-database-instance

Actual Behavior

Terraform applying failed with error:

│ Error: Error creating openstack_db_instance_v1: Bad request with: [POST https://openstack.example.com/v1.0/ID_REPLACED/instances], error message: {"badRequest": {"code": 400, "message": "Validation error: instance 'availability_zone' is a required property"}}

Steps to Reproduce

  1. Define openstack_db_instance_v1 resource for the cluster with availability_zone marked as required.
  2. terraform apply

Important Factoids

  • Openstack Ussuri
  • Openstack uses as a Company Wide platform - there is no way to use default AZ created by Openstack Bootstrap and therefore providing other AZ is mandatatory to create an instance.

The use of the default availability zone name in requests can be very error-prone. Since the user can see the list of availability zones, they have no way to know whether the default availability zone name (currently nova) is provided because a host belongs to an aggregate whose AZ metadata key is set to nova, or because there is at least one host not belonging to any aggregate. Consequently, it is highly recommended for users to never ever ask for booting an instance by specifying an explicit AZ named nova and for operators to never set the AZ metadata for an aggregate to nova.

Docs Ussuri: https://docs.openstack.org/nova/ussuri/admin/availability-zones.html
Docs Latest: https://docs.openstack.org/nova/latest/admin/availability-zones.html

References

Issues and PRs:

Docs and Openstack Trove Source Code Links:

@zhekazuev zhekazuev changed the title DB v1: Error creating openstack_db_instance_v1: there is no availability_zone field in provider DB V1: Error creating openstack_db_instance_v1: there is no availability_zone field in provider Jan 19, 2024
@nikParasyr
Copy link
Member

Fixed by #1643
will be part of the new release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants