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/instance]: add availability_zone field #1643

Conversation

zhekazuev
Copy link
Contributor

@zhekazuev zhekazuev commented Jan 18, 2024

Changes

  • code: add availability_zone to openstack/resource_openstack_db_instance_v1.go
  • tests: add availability_zone to openstack/resource_openstack_db_instance_v1_test.go
  • dependencies: bumpgithub.com/gophercloud/gophercloud from v1.8.0 to backport-b1 version v1.8.1-0.20240119210933-51831d9ee643
  • docs - add availability_zone field

Issue: #1644
Dependency update with availability_zone field: gophercloud/gophercloud#2875

@zhekazuev zhekazuev changed the title feat: add availabilityZone for resource openstack db instance v1 [v1] db/v1/instance: add availability_zone field Jan 18, 2024
@zhekazuev zhekazuev marked this pull request as ready for review January 20, 2024 00:07
@zhekazuev
Copy link
Contributor Author

zhekazuev commented Jan 20, 2024

@EugenMayer Hi,

Could you help me with reviewing this PR?

@zhekazuev
Copy link
Contributor Author

zhekazuev commented Jan 20, 2024

Failed Job: https://github.com/terraform-provider-openstack/terraform-provider-openstack/actions/runs/7590657439/job/20683598950#step:5:130994

+ ./scripts/acceptancetest.sh:main:39      :   go test ./openstack -v -timeout 120m -run TestAccLBQuotaV2_basic
=== RUN   TestAccLBQuotaV2_basic
2024-01-20T10:28:42.225Z [DEBUG] sdk.helper_resource: Starting TestCase: test_name=TestAccLBQuotaV2_basic
2024-01-20T10:28:42.225Z [DEBUG] sdk.helper_resource: Calling TestCase PreCheck: test_name=TestAccLBQuotaV2_basic
    provider_test.go:241: Skipping test because it requires the admin user
--- SKIP: TestAccLBQuotaV2_basic (0.00s)
PASS
ok  	github.com/terraform-provider-openstack/terraform-provider-openstack/openstack	0.007s
+ ./scripts/acceptancetest.sh:main:41      :   [[ 0 != 0 ]]
+ ./scripts/acceptancetest.sh:main:47      :   [[ -n 1 ]]
+ ./scripts/acceptancetest.sh:main:48      :   exit 1
Error: Process completed with exit code 1.

Failed Job: https://github.com/terraform-provider-openstack/terraform-provider-openstack/actions/runs/7590657439/job/20683599344?pr=1643

2024-01-20T10:53:17.5091377Z === RUN   TestAccLBQuotaV2_basic
2024-01-20T10:53:17.5093956Z 2024-01-20T10:53:17.509Z [DEBUG] sdk.helper_resource: Starting TestCase: test_name=TestAccLBQuotaV2_basic
2024-01-20T10:53:17.5095470Z 2024-01-20T10:53:17.509Z [DEBUG] sdk.helper_resource: Calling TestCase PreCheck: test_name=TestAccLBQuotaV2_basic
2024-01-20T10:53:17.5096412Z     provider_test.go:241: Skipping test because it requires the admin user
2024-01-20T10:53:17.5096990Z --- SKIP: TestAccLBQuotaV2_basic (0.00s)
2024-01-20T10:53:17.5097314Z PASS
2024-01-20T10:53:17.5108880Z ok  	github.com/terraform-provider-openstack/terraform-provider-openstack/openstack	0.009s
2024-01-20T10:53:17.5433877Z + ./scripts/acceptancetest.sh:main:41      :   [[ 0 != 0 ]]
2024-01-20T10:53:17.5442397Z + ./scripts/acceptancetest.sh:main:47      :   [[ -n 1 ]]
2024-01-20T10:53:17.5450369Z + ./scripts/acceptancetest.sh:main:48      :   exit 1
2024-01-20T10:53:17.5467150Z ##[error]Process completed with exit code 1.
2024-01-20T10:53:17.5513489Z ##[group]Run ./scripts/collectlogs.sh
2024-01-20T10:53:17.5513877Z �[36;1m./scripts/collectlogs.sh�[0m
2024-01-20T10:53:17.5533111Z shell: /usr/bin/bash -e {0}
2024-01-20T10:53:17.5533577Z ##[endgroup]

Copy link
Member

@nikParasyr nikParasyr left a comment

Choose a reason for hiding this comment

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

Small change requested on the test.

We currently do not have Trove/DBaaS CI tests. were you able to run the test on your local env?

( the 2 CI tests currently failing are unrelated to your change)

openstack/resource_openstack_db_instance_v1_test.go Outdated Show resolved Hide resolved
@zhekazuev
Copy link
Contributor Author

zhekazuev commented Jan 21, 2024

Hi @nikParasyr ,

were you able to run the test on your local env?

I will do that on Monday.

@zhekazuev
Copy link
Contributor Author

zhekazuev commented Jan 22, 2024

were you able to run the test on your local env?

@nikParasyr Hi,

So I tested it with real openstack cluster, and resource was created.

Steps

I prebuilded terraform-provider-openstack binary and added it to the local plugins dir:

$ make build
==> Checking that code complies with gofmt requirements...
go install

$ cp /go/bin/terraform-provider-openstack terraform.d/plugins/registry.terraform.io/terraform-provider-openstack/openstack/1.53.0-az/linux_amd64/terraform-provider-openstack_v1.53.0-az

$ tree terraform.d/
terraform.d/
└── plugins
    └── registry.terraform.io
        └── terraform-provider-openstack
            └── openstack
                └── 1.53.0-az
                    └── linux_amd64
                        └── terraform-provider-openstack_v1.53.0-az

6 directories, 1 file

$ ll
total 120
drwxr-xr-x 4 eugenezuev eugenezuev  4096 Jan 22 11:36 ./
drwxr-xr-x 8 eugenezuev eugenezuev 12288 Jan 18 16:41 ../
drwxr-xr-x 3 eugenezuev eugenezuev  4096 Jan 18 14:01 .terraform/
-rw-r--r-- 1 eugenezuev eugenezuev   312 Jan 22 11:21 .terraform.lock.hcl
-rw-r--r-- 1 eugenezuev eugenezuev  1994 Jan 18 16:35 CA-...-...-sandbox2-dev-openrc.sh
-rw-r--r-- 1 eugenezuev eugenezuev   892 Jan 18 13:57 clouds.yaml
-rw-r--r-- 1 eugenezuev eugenezuev  2935 Jan 18 16:50 configurations.tf
-rw-r--r-- 1 eugenezuev eugenezuev     1 Jan 19 20:07 databases.tf
-rw-r--r-- 1 eugenezuev eugenezuev  7280 Jan 22 11:34 main.tf
-rw-r--r-- 1 eugenezuev eugenezuev  1232 Jan 19 15:15 networks.tf
-rw-r--r-- 1 eugenezuev eugenezuev  8275 Jan 19 15:44 openstack-wl.sh
drwxr-xr-x 3 eugenezuev eugenezuev  4096 Jan 22 11:21 terraform.d/
-rw-r--r-- 1 eugenezuev eugenezuev 18197 Jan 22 11:36 terraform.tfstate
-rw-r--r-- 1 eugenezuev eugenezuev 16649 Jan 22 11:36 terraform.tfstate.backup
-rw-r--r-- 1 eugenezuev eugenezuev   211 Jan 22 11:15 versions.tf

Then updated provider:

# Define required providers
terraform {
  required_version = ">= 0.14.0"
  required_providers {
    openstack = {
      source  = "terraform-provider-openstack/openstack"
      version = "1.53.0-az"
    }
  }
}

Then defined resource with az field:

resource "openstack_db_instance_v1" "sandboxdev02_dbaas" {
  region           = "EU-Krakow-new"
  name             = "sandboxdev02-dbaas-0"
  flavor_id        = "43ae1fa4-....-....-....-67f276b8a56b"
  configuration_id = openstack_db_configuration_v1.psql_15_3_C2R4.id
  size             = 8

  network {
    uuid = openstack_networking_network_v2.sandboxdev02_dbaas.id
  }

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

  availability_zone = "az1"
}

And run apply command:

$ terraform version
Terraform v1.6.2
on linux_amd64
+ provider registry.terraform.io/terraform-provider-openstack/openstack v1.53.0-az

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

$ terraform apply 
openstack_db_configuration_v1.psql_15_3_C2R4: Refreshing state... [id=fb3fc45d-....-....-....-432b63500337]
data.openstack_compute_flavor_v2.c1r2: Reading...
openstack_networking_network_v2.sandboxdev02_dbaas: Refreshing state... [id=84a42ade-....-....-....-efc9a75d96de]
data.openstack_networking_network_v2.internal_ip_01: Reading...
data.openstack_compute_flavor_v2.c2r4: Reading...
openstack_db_configuration_v1.psql_15_3_C1R2: Refreshing state... [id=1befaaaf-....-....-....-b177ae15fbd7]
data.openstack_networking_network_v2.internal_ip_02: Reading...
data.openstack_compute_flavor_v2.c1r2: Read complete after 0s [id=296d45cf-....-....-....-ab3a5bc1a744]
data.openstack_compute_flavor_v2.c2r4: Read complete after 0s [id=fa74fdc2-....-....-....-3a4467ea7812]
openstack_networking_subnet_v2.sandboxdev02_dbaas: Refreshing state... [id=9f48b0fd-....-....-....-1890775544a4]
data.openstack_networking_network_v2.internal_ip_02: Read complete after 2s [id=2b56e154-....-....-....-1ef768f5adbb]
openstack_networking_router_v2.sandboxdev02_dbaas: Refreshing state... [id=c8882a3e-....-....-....-de249225a08f]
openstack_networking_router_interface_v2.router_interface_1: Refreshing state... [id=7ffa93da-....-....-....-c049bc047e6d]
data.openstack_networking_network_v2.internal_ip_01: Still reading... [10s elapsed]
data.openstack_networking_network_v2.internal_ip_01: Still reading... [20s elapsed]
data.openstack_networking_network_v2.internal_ip_01: Read complete after 22s [id=4530a10e-....-....-....-4576dee5ca98]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # openstack_db_instance_v1.sandboxdev02_dbaas will be created
  + resource "openstack_db_instance_v1" "sandboxdev02_dbaas" {
      + addresses         = (known after apply)
      + availability_zone = "az1"
      + configuration_id  = "fb3fc45d-....-....-....-432b63500337"
      + flavor_id         = "43ae1fa4-....-....-....-67f276b8a56b"
      + id                = (known after apply)
      + name              = "sandboxdev02-dbaas-0"
      + region            = "EU-Krakow-new"
      + size              = 8

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

      + network {
          + uuid = "84a42ade-....-....-....-efc9a75d96de"
        }
    }

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.sandboxdev02_dbaas: Creating...
openstack_db_instance_v1.sandboxdev02_dbaas: Still creating... [10s elapsed]
openstack_db_instance_v1.sandboxdev02_dbaas: Still creating... [20s elapsed]
openstack_db_instance_v1.sandboxdev02_dbaas: Still creating... [30s elapsed]
openstack_db_instance_v1.sandboxdev02_dbaas: Still creating... [40s elapsed]
openstack_db_instance_v1.sandboxdev02_dbaas: Still creating... [50s elapsed]
openstack_db_instance_v1.sandboxdev02_dbaas: Still creating... [1m0s elapsed]
openstack_db_instance_v1.sandboxdev02_dbaas: Still creating... [1m10s elapsed]
openstack_db_instance_v1.sandboxdev02_dbaas: Still creating... [1m20s elapsed]
openstack_db_instance_v1.sandboxdev02_dbaas: Still creating... [1m30s elapsed]
openstack_db_instance_v1.sandboxdev02_dbaas: Creation complete after 1m35s [id=33112f8c-....-....-....-54129d97cff2]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Screenshot: image

Copy link
Member

@nikParasyr nikParasyr left a comment

Choose a reason for hiding this comment

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

LGTM.

Thanks for the quick responses and testing this. I hope to get a release in the next 1-2 weeks with this included

@nikParasyr nikParasyr merged commit fec0e2e into terraform-provider-openstack:main Jan 22, 2024
64 of 67 checks passed
@zhekazuev
Copy link
Contributor Author

LGTM.

Thanks for the quick responses and testing this. I hope to get a release in the next 1-2 weeks with this included

I have a quick question about testing pipelines for db/v1.
What parts are missing for the tests?
As I understand it, only the CI part and the tests are already there. Am I right?

@nikParasyr
Copy link
Member

I can't get trove to work properly in devstack => #1408.

Initially it wasnt even installed properly, then i fixed that but i had any db instance creation would remain in error status. Then i tried again after some time and trove wasnt getting installed properly on devstack again.

@nikParasyr
Copy link
Member

@zhekazuev just kicked the ci once again and now it fails ond evstack. seems like the trove image is too big => https://github.com/terraform-provider-openstack/terraform-provider-openstack/actions/runs/7610171381/job/20722954240?pr=1408

nikParasyr added a commit to nikParasyr/terraform-provider-openstack that referenced this pull request Jan 25, 2024
nikParasyr added a commit that referenced this pull request Jan 25, 2024
al26p pushed a commit to al26p/terraform-provider-openstack that referenced this pull request Feb 2, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants