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

[ECS][IMPORT] opentelekomcloud_compute_instance_v2 seams to not work with multiple Subnet in VPC #1039

Closed
Moep90 opened this issue Apr 30, 2021 · 8 comments · Fixed by #1057
Labels
Milestone

Comments

@Moep90
Copy link
Contributor

Moep90 commented Apr 30, 2021

Version

$ terraform --version
Terraform v0.15.0
on linux_amd64
+ provider registry.terraform.io/opentelekomcloud/opentelekomcloud v1.23.9

Import doesnt work with having a SINGLE interface on the ECS but having multiple VPC-Subnet in the VPC where I try to import it.

Network

I have somethink like this as Network:

resource "opentelekomcloud_vpc_v1" "vpc_v1" {
  name = var.vpc_name
  cidr = var.vpc_cidr
}

resource "opentelekomcloud_vpc_subnet_v1" "subnet_1" {
  name   = var.subnet_name_1
  cidr   = var.subnet_cidr_1
  vpc_id = opentelekomcloud_vpc_v1.vpc_v1.id

  gateway_ip    = var.subnet_gateway_ip_1
  ntp_addresses = "10.100.0.33,10.100.0.34"
}

resource "opentelekomcloud_vpc_subnet_v1" "subnet_2" {
  name   = var.subnet_name_2
  cidr   = var.subnet_cidr_2
  vpc_id = opentelekomcloud_vpc_v1.vpc_v1.id

  gateway_ip    = var.subnet_gateway_ip_2
  ntp_addresses = "10.100.0.33,10.100.0.34"
}

resource "opentelekomcloud_vpc_subnet_v1" "subnet_3" {
  name   = var.subnet_name_3
  cidr   = var.subnet_cidr_3
  vpc_id = opentelekomcloud_vpc_v1.vpc_v1.id

  gateway_ip    = var.subnet_gateway_ip_3
  ntp_addresses = "10.100.0.33,10.100.0.34"
}

ECS Instance

The instance looks like:
I double checked that the Instances is (for real) only connected to ONE network...

resource "opentelekomcloud_compute_instance_v2" "ecs_instance" {
  name      = "boot-from-volume"
  flavor_id = var.flavor_id
  key_pair  = var.key_pair
  image_id  = var.image_id

  network {
    id        = opentelekomcloud_vpc_subnet_v1.subnet_2.id
    fixed_ip_v4 = "<fixed_ip_v4>"
  }

}

Import try

@outcatcher

$ terraform import opentelekomcloud_compute_instance_v2.ecs_instance xxxxxxxxxxxxxxx-yyyyyyyyyyyyyyy
opentelekomcloud_compute_instance_v2.ecs_instance: Importing from ID "xxxxxxxxxxxxxxx-yyyyyyyyyyyyyyy"...
opentelekomcloud_compute_instance_v2.ecs_instance: Import prepared!
  Prepared opentelekomcloud_compute_instance_v2 for import
opentelekomcloud_compute_instance_v2.ecs_instance: Refreshing state... [id=xxxxxxxxxxxxxxx-yyyyyyyyyyyyyyy]

Error: Error trying to get network information from the Network API: More than one network found for name <ID of the VPC>

API

API Response is like:

"networks": [
{
  "admin_state_up": true,
  "availability_zone_hints": [],
  "availability_zones": [
    "eu-de-01",
    "eu-de-02",
    "eu-de-03"
  ],
  "created_at": "2021-04-27T13:32:35",
  "dns_domain": "eu-de.compute.internal.",
  "id": "xxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyy",
  "name": "zzzzzzzzzzzzzzyyyyyyyyyyyyyyyyyy",
  "port_security_enabled": true,
  "project_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "provider:network_type": "vxlan",
  "router:external": false,
  "shared": false,
  "status": "ACTIVE",
  "subnets": [
    "zzzzzzzzzzzzzzzzzzzzzzz"
  ],
  "tenant_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "updated_at": "2021-04-27T13:32:35"
},
{
  "admin_state_up": true,
  "availability_zone_hints": [],
  "availability_zones": [
    "eu-de-01",
    "eu-de-02",
    "eu-de-03"
  ],
  "created_at": "2021-04-27T13:31:13",
  "dns_domain": "eu-de.compute.internal.",
  "id": "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn",
  "name": "zzzzzzzzzzzzzzyyyyyyyyyyyyyyyyyy",
  "port_security_enabled": true,
  "project_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "provider:network_type": "vxlan",
  "router:external": false,
  "shared": false,
  "status": "ACTIVE",
  "subnets": [
    "gggggggggggggggggggggggggggggggggggggggg"
  ],
  "tenant_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "updated_at": "2021-04-27T13:31:13"
},
{
  "admin_state_up": true,
  "availability_zone_hints": [],
  "availability_zones": [
    "eu-de-01",
    "eu-de-02",
    "eu-de-03"
  ],
  "created_at": "2020-10-15T14:50:35",
  "dns_domain": "eu-de.compute.internal.",
  "id": "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
  "name": "zzzzzzzzzzzzzzyyyyyyyyyyyyyyyyyy",
  "port_security_enabled": true,
  "project_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "provider:network_type": "vxlan",
  "router:external": false,
  "shared": false,
  "status": "ACTIVE",
  "subnets": [
    "fffffffffffffffffffffffffffffffffff"
  ],
  "tenant_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "updated_at": "2020-10-15T14:50:35"
}

etworks_links": [
{
  "href": "https://vpc.eu-de.otc.t-systems.com/v2.0/networks?limit=2000\u0026shared=False\u0026router:external=False\u0026name=zzzzzzzzzzzzzzyyyyyyyyyyyyyyyyyy\u0026provider:network_type=vxlan\u0026provider:network_type=geneve\u0026status=ACTIVE\u0026marker=xxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyy\u0026page_reverse=true",
  "rel": "previous"
}
2021-04-30T05:51:22.613+0200 [DEBUG] provider.terraform-provider-opentelekomcloud_v1.23.9:   ]

Originally posted by @Moep90 in #1023 (comment)

@Moep90 Moep90 changed the title ECS opentelekomcloud_compute_instance_v2 seams to not work with multiple Subnetworks in VPC ECS opentelekomcloud_compute_instance_v2 seams to not work with multiple Subnet in VPC Apr 30, 2021
@Moep90 Moep90 changed the title ECS opentelekomcloud_compute_instance_v2 seams to not work with multiple Subnet in VPC [ECS][IMPORT] opentelekomcloud_compute_instance_v2 seams to not work with multiple Subnet in VPC Apr 30, 2021
@lego963
Copy link
Contributor

lego963 commented May 12, 2021

@Moep90 We query ECSv2 instance and we have only vpc_id in response.
And the problem is when you create a VPC with 3 Subnets it creates 3 Networks with same name where Network name == VPC ID.

@Moep90
Copy link
Contributor Author

Moep90 commented May 12, 2021

@lego963 Then the OTC may would open an internal issue about it?
its not suitable to NOT be able to import ECSv2 instances.
I guess to add an subnet into the response is a possible thing.

@lego963
Copy link
Contributor

lego963 commented May 13, 2021

@Moep90 sorry, I'm wrong and we will fix it

@lego963 lego963 added this to the v1.23.11 milestone May 13, 2021
@lego963 lego963 added the bug label May 13, 2021
otc-zuul bot pushed a commit to opentelekomcloud/gophertelekomcloud that referenced this issue May 13, 2021
[ECS] Add possibility to query NICs info

What this PR does / why we need it
Add possibility to query info about NICs
Which issue this PR fixes
Fixes: #149
Refers to: opentelekomcloud/terraform-provider-opentelekomcloud#1039
Acceptance tests
=== RUN   TestServerList
--- PASS: TestServerList (2.67s)
=== RUN   TestServerLifecycle
    servers_test.go:37: Attempting to create ECSv2
    servers_test.go:76: Created ECSv2: 4ba882dd-21fc-4755-b79b-24f5b365485c
    servers_test.go:108: Attempting to update ECSv2: 4ba882dd-21fc-4755-b79b-24f5b365485c
    servers_test.go:118: ECSv2 successfully updated: 4ba882dd-21fc-4755-b79b-24f5b365485c
    servers_test.go:87: Attempting to delete ECSv2: 4ba882dd-21fc-4755-b79b-24f5b365485c
    servers_test.go:105: ECSv2 instance deleted: 4ba882dd-21fc-4755-b79b-24f5b365485c
--- PASS: TestServerLifecycle (149.57s)
PASS

Process finished with the exit code 0

Reviewed-by: None <None>
Reviewed-by: Anton Sidelnikov <None>
@otc-zuul otc-zuul bot closed this as completed in #1057 May 14, 2021
otc-zuul bot pushed a commit that referenced this issue May 14, 2021
[ECS] Fix issue with multiple networks

Summary of the Pull Request
Fix issue with reading networks in resource/opentelekomcloud_compute_instance_v2
Fixes: #1039
PR Checklist

 Refers to: #1039
 Tests added/passed.
 Documentation updated.
 Schema updated.

Acceptance Steps Performed
=== RUN   TestAccComputeV2Instance_basic
--- PASS: TestAccComputeV2Instance_basic (140.33s)
=== RUN   TestAccComputeV2Instance_multiSecgroup
--- PASS: TestAccComputeV2Instance_multiSecgroup (149.64s)
=== RUN   TestAccComputeV2Instance_bootFromImage
--- PASS: TestAccComputeV2Instance_bootFromImage (79.78s)
=== RUN   TestAccComputeV2Instance_bootFromVolume
--- PASS: TestAccComputeV2Instance_bootFromVolume (78.77s)
=== RUN   TestAccComputeV2Instance_changeFixedIP
--- PASS: TestAccComputeV2Instance_changeFixedIP (80.90s)
=== RUN   TestAccComputeV2Instance_bootFromVolumeVolume
--- PASS: TestAccComputeV2Instance_bootFromVolumeVolume (100.41s)
=== RUN   TestAccComputeV2Instance_stopBeforeDestroy
--- PASS: TestAccComputeV2Instance_stopBeforeDestroy (126.18s)
=== RUN   TestAccComputeV2Instance_metadata
--- PASS: TestAccComputeV2Instance_metadata (137.88s)
=== RUN   TestAccComputeV2Instance_timeout
--- PASS: TestAccComputeV2Instance_timeout (87.94s)
=== RUN   TestAccComputeV2Instance_autoRecovery
--- PASS: TestAccComputeV2Instance_autoRecovery (127.58s)
=== RUN   TestAccComputeV2Instance_crazyNICs
--- PASS: TestAccComputeV2Instance_crazyNICs (231.48s)
=== RUN   TestAccComputeV2Instance_initialStateActive
--- PASS: TestAccComputeV2Instance_initialStateActive (215.49s)
=== RUN   TestAccComputeV2Instance_initialStateShutoff
--- PASS: TestAccComputeV2Instance_initialStateShutoff (287.69s)
PASS

Process finished with the exit code 0

Reviewed-by: None <None>
Reviewed-by: Anton Kachurin <katchuring@gmail.com>
Reviewed-by: Rodion Gyrbu <fpsoff@outlook.com>
@Moep90
Copy link
Contributor Author

Moep90 commented May 18, 2021

No testing regarding importing of resources?

@lego963
Copy link
Contributor

lego963 commented May 18, 2021

@Moep90 we've tested import with multiple networks and it was green. We will release soon new version.

@Moep90
Copy link
Contributor Author

Moep90 commented May 18, 2021

@lego963 manually I guess?
Why not automate import tests as well?

@lego963
Copy link
Contributor

lego963 commented May 18, 2021

Our acceptance tests for resources/data_sources and imports
image

@Moep90
Copy link
Contributor Author

Moep90 commented May 18, 2021

ah ok, didn't found them...sorry!
great! Thank you!

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

Successfully merging a pull request may close this issue.

2 participants