IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
339 stars 663 forks source link

Error ordering LBaaS via terraform #49

Closed greyhoundforty closed 6 years ago

greyhoundforty commented 6 years ago

When trying to provision LBaaS in both Dallas 13 and Wdc07 I am getting an error about pricing. I am using IBM Cloud Provider v0.5.0.

Terraform Version

$ terraform -v
Terraform v0.10.7

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

variable slusername {}
variable slapikey {}
variable bxapikey {}

provider "ibm5" {
  bluemix_api_key    = "${var.bxapikey}"
  softlayer_username = "${var.slusername}"
  softlayer_api_key  = "${var.slapikey}"
}

data "ibm_compute_ssh_key" "terra" {
    label = "terra"
}

resource "ibm_compute_vm_instance" "host1" {
    hostname = "host1"
    domain = "cde.services"
    os_reference_code = "UBUNTU_LATEST_64"
    datacenter = "wdc07"
    network_speed = 1000
    hourly_billing = true
    private_network_only = true 
    cores = 2
    memory = 4096
    disks = [100]
    local_disk = false
    ssh_key_ids = ["${data.ibm_compute_ssh_key.terra.id}"]
    provisioner "file" {
    source      = "postinstall.sh"
    destination = "/tmp/postinstall.sh"
    }
    provisioner "remote-exec" {
    inline = [
      "chmod +x /tmp/postinstall.sh",
      "/tmp/postinstall.sh",
    ]
    }
}

resource "ibm_compute_vm_instance" "host2" {
    hostname = "host2"
    domain = "cde.services"
    os_reference_code = "UBUNTU_LATEST_64"
    datacenter = "wdc07"
    network_speed = 1000
    hourly_billing = true
    private_network_only = true 
    cores = 2
    memory = 4096
    disks = [100]
    local_disk = false
    ssh_key_ids = ["${data.ibm_compute_ssh_key.terra.id}"]
    provisioner "file" {
    source      = "postinstall.sh"
    destination = "/tmp/postinstall.sh"
    }
    provisioner "remote-exec" {
    inline = [
      "chmod +x /tmp/postinstall.sh",
      "/tmp/postinstall.sh",
    ]
    }
}

resource "ibm_compute_vm_instance" "host3" {
    hostname = "host3"
    domain = "cde.services"
    os_reference_code = "UBUNTU_LATEST_64"
    datacenter = "wdc07"
    network_speed = 1000
    hourly_billing = true
    private_network_only = true 
    cores = 2
    memory = 4096
    disks = [100]
    local_disk = false
    ssh_key_ids = ["${data.ibm_compute_ssh_key.terra.id}"]
    provisioner "file" {
    source      = "postinstall.sh"
    destination = "/tmp/postinstall.sh"
    }
    provisioner "remote-exec" {
    inline = [
      "chmod +x /tmp/postinstall.sh",
      "/tmp/postinstall.sh",
    ]
    }
}

resource "ibm_compute_vm_instance" "host4" {
    hostname = "dal13"
    domain = "cde.services"
    os_reference_code = "UBUNTU_LATEST_64"
    datacenter = "wdc07"
    network_speed = 1000
    hourly_billing = true
    private_network_only = true 
    cores = 2
    memory = 4096
    disks = [100]
    local_disk = false
    ssh_key_ids = ["${data.ibm_compute_ssh_key.terra.id}"]
    provisioner "file" {
    source      = "postinstall.sh"
    destination = "/tmp/postinstall.sh"
    }
    provisioner "remote-exec" {
    inline = [
      "chmod +x /tmp/postinstall.sh",
      "/tmp/postinstall.sh",
    ]
    }
}

resource "ibm_lbaas" "lbaas" {
  name        = "terraformLB"
  description = "testing schematics with lbaas"
  subnets     = [1892939]
  datacenter  = "wdc07"

  protocols = [
    {
      frontend_protocol     = "HTTP"
      frontend_port         = 80
      backend_protocol      = "HTTP"
      backend_port          = 80
      load_balancing_method = "round_robin"
    },
  ]

  server_instances = [
    {
      "private_ip_address" = "${ibm_compute_vm_instance.host1.ipv4_address_private}"
    },
    {
      "private_ip_address" = "${ibm_compute_vm_instance.host2.ipv4_address_private}"
    },
    {
      "private_ip_address" = "${ibm_compute_vm_instance.host3.ipv4_address_private}"
    },
    {
      "private_ip_address" = "${ibm_compute_vm_instance.host4.ipv4_address_private}"
    },
  ]
}

output "lb_id" {
    value = ["${ibm_lbaas.lbaas.vip}"]
}

Debug Output

https://gist.github.com/greyhoundforty/650bf379f2f5a575e120db307c43c67a

Expected Behavior

4 VSIs provisioned with a LBaaS instance

Actual Behavior

* ibm_lbaas.lbaas: 1 error(s) occurred:

* ibm_lbaas.lbaas: Error during creation of Load balancer: SoftLayer_Exception_Public: The price for Load Balancer Uptime (#205913) is not valid for location wdc07. (HTTP 500)

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
Praveengostu commented 6 years ago

Hi, One of the reason for the exception could be unavailability of servers on the location wdc07. It works normal on locations where the servers are up/available like wdc04, dal06 etc.. Could you please try on locations wdc04, dal06.

greyhoundforty commented 6 years ago

All 4 of the VSIs got provisioned correctly and are up and online. I will test again though in wdc04.

greyhoundforty commented 6 years ago

Yeah, the error remains the same:

Error applying plan:

1 error(s) occurred:

* ibm_lbaas.lbaas: 1 error(s) occurred:

* ibm_lbaas.lbaas: Error during creation of Load balancer: SoftLayer_Exception_Public: The price for Load Balancer Uptime (#205913) is not valid for location wdc04. (HTTP 500)

The VSIs are provisioned properly:

$ slcli --format raw vs list -d wdc04 -D cde.services 
41258523  host1  NULL  10.149.214.8   wdc04  NULL
41258529  host2  NULL  10.149.214.42  wdc04  NULL
41259311  host3  NULL  10.149.214.49  wdc04  NULL
41259309  host4  NULL  10.149.214.44  wdc04  NULL

Here is the updated main.tf

Praveengostu commented 6 years ago

Ok.. Need some more information to proceed . Could you please enable the trace and run the terraform apply. For enabling trace export TF_LOG=trace Could you please share me the output of these API calls curl -g -k -L -H 'Content-Type: application/json' -u : 'https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/getAllObjects.json?objectMask=id;name;type&objectFilter={%22name%22:{%22operation%22:%22Load%20Balancer%20As%20A%20Service%20(LBaaS)%22}}'

curl -g -k -L -H 'Content-Type: application/json' -u : 'https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/$packageidentifier/getItemPrices?objectMask=id;item.description;categories.id'

Replace the $packageidentifier with id from the output of first curl request

ashishth09 commented 6 years ago

SoftLayer_Exception_Public: The price for Load Balancer Uptime (#205913) is not valid for location wdc04. (HTTP 500)

Interestingly I don't see the price id 205913 in the output of https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/805/getItemPrices.

greyhoundforty commented 6 years ago

Output of terraform apply with TF_LOG=TRACE

curl -g -k -L -H 'Content-Type: application/json' -u "$SOFTLAYER_USERNAME:$SOFTLAYER_API_KEY" 'https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/getAllObjects.json?objectMask=id;name;type&objectFilter={%22name%22:{%22operation%22:%22Load%20Balancer%20As%20A%20Service%20(LBaaS)%22}}'

[{"id":805,"name":"Load Balancer As A Service (LBaaS)","type":{"id":662,"keyName":"LOAD_BALANCER_AS_A_SERVICE","name":"Load Balancer As A Service"}}]%
curl -g -k -L -H 'Content-Type: application/json' -u "$SOFTLAYER_USERNAME:$SOFTLAYER_API_KEY" "https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/805/getItemPrices?objectMask=id;item.description;categories.id"

[{"id":205915,"categories":[{"id":1119}],"item":{"description":"Load Balancer Uptime"}},{"id":205907,"categories":[{"id":1119}],"item":{"description":"Load Balancer Uptime"}},{"id":199467,"categories":[{"id":1117}],"item":{"description":"Load Balancer Bandwidth"}},{"id":205839,"categories":[{"id":1228}],"item":{"description":"Load Balancer Data Processed "}},{"id":205909,"categories":[{"id":1119}],"item":{"description":"Load Balancer Uptime"}},{"id":205917,"categories":[{"id":1119}],"item":{"description":"Load Balancer Uptime"}},{"id":205913,"categories":[{"id":1119}],"item":{"description":"Load Balancer Uptime"}},{"id":199447,"categories":[{"id":1116}],"item":{"description":"Load Balancer as a Service"}},{"id":205911,"categories":[{"id":1119}],"item":{"description":"Load Balancer Uptime"}}]%

This is an internal SoftLayer account (I work in Cloud Design Engineering) and was part of the beta. Not sure if the internal account part is causing an issue. Seems to only be affecting the LBaaS stuff at the moment as I can create VSIs and DNS records without issue.

ashishth09 commented 6 years ago

Thanks for the logs: This is from your logs and it has 205913 price id. 2017-10-09T11:33:13.789Z [DEBUG] plugin.terraform-provider-ibm: 2017/10/09 11:33:13 [DEBUG] Request URL: GET https://api.softlayer.com/rest/v3/SoftLayer_Product_Package/805/getItems.json?objectMask=mask%5Bid%2Ccapacity%2Cdescription%2Cunits%2CkeyName%2Cprices%5Bid%2Ccategories%5Bid%2Cname%2CcategoryCode%5D%5D%5D 2017-10-09T11:33:13.789Z [DEBUG] plugin.terraform-provider-ibm: 2017/10/09 11:33:13 [DEBUG] Parameters: 2017-10-09T11:33:14.258Z [DEBUG] plugin.terraform-provider-ibm: 2017/10/09 11:33:14 [DEBUG] Response: [{"description":"Load Balancer Data Processed ","id":10771,"keyName":"LOAD_BALANCER_DATA_PROCESSED","units":"GIGABYTE","prices":[{"id":205839,"categories":[{"categoryCode":"load_balancer_data_processed","id":1228,"name":"Load Balancer Data Processed"}]}]},{"capacity":"0","description":"Load Balancer as a Service","id":10043,"keyName":"LOAD_BALANCER_AS_A_SERVICE","prices":[{"id":199447,"categories":[{"categoryCode":"load_balancer_as_a_service","id":1116,"name":"Load Balancer As A Service"}]}]},{"capacity":"0","description":"Load Balancer Bandwidth","id":10051,"keyName":"LOAD_BALANCER_BANDWIDTH","units":"GB","prices":[{"id":199467,"categories":[{"categoryCode":"load_balancer_bandwidth","id":1117,"name":"Load Balancer Bandwidth"}]}]},{"capacity":"0","description":"Load Balancer Uptime","id":10785,"keyName":"LOAD_BALANCER_UPTIME","units":"hour","prices":[{"id":205913,"categories":[{"categoryCode":"load_balancer_uptime","id":1119,"name":"Load Balancer Uptime"}]},{"id":205915,"categories":[{"categoryCode":"load_balancer_uptime","id":1119,"name":"Load Balancer Uptime"}]},{"id":205911,"categories":[{"categoryCode":"load_balancer_uptime","id":1119,"name":"Load Balancer Uptime"}]},{"id":205907,"categories":[{"categoryCode":"load_balancer_uptime","id":1119,"name":"Load Balancer Uptime"}]},{"id":205909,"categories":[{"categoryCode":"load_balancer_uptime","id":1119,"name":"Load Balancer Uptime"}]},{"id":205917,"categories":[{"categoryCode":"load_balancer_uptime","id":1119,"name":"Load Balancer Uptime"}]}]}]

While the below is from our account and it doesn't include that

[{"description":"Load Balancer Data Processed ","id":10771,"keyName":"LOAD_BALANCER_DATA_PROCESSED","units":"GIGABYTE","prices":[{"id":205837,"categories":[{"categoryCode":"load_balancer_data_processed","id":1228,"name":"Load Balancer Data Processed"}]}]},{"capacity":"0","description":"Load Balancer as a Service","id":10043,"keyName":"LOAD_BALANCER_AS_A_SERVICE","prices":[{"id":199445,"categories":[{"categoryCode":"load_balancer_as_a_service","id":1116,"name":"Load Balancer As A Service"}]}]},{"capacity":"0","description":"Load Balancer Bandwidth","id":10051,"keyName":"LOAD_BALANCER_BANDWIDTH","units":"GB","prices":[{"id":199465,"categories":[{"categoryCode":"load_balancer_bandwidth","id":1117,"name":"Load Balancer Bandwidth"}]}]},{"capacity":"0","description":"Load Balancer Uptime","id":10785,"keyName":"LOAD_BALANCER_UPTIME","units":"hour","prices":[{"id":205975,"categories":[{"categoryCode":"load_balancer_uptime","id":1119,"name":"Load Balancer Uptime"}]},{"id":205981,"categories":[{"categoryCode":"load_balancer_uptime","id":1119,"name":"Load Balancer Uptime"}]},{"id":205983,"categories":[{"categoryCode":"load_balancer_uptime","id":1119,"name":"Load Balancer Uptime"}]},{"id":205979,"categories":[{"categoryCode":"load_balancer_uptime","id":1119,"name":"Load Balancer Uptime"}]},{"id":205977,"categories":[{"categoryCode":"load_balancer_uptime","id":1119,"name":"Load Balancer Uptime"}]},{"id":205985,"categories":[{"categoryCode":"load_balancer_uptime","id":1119,"name":"Load Balancer Uptime"}]}]}]

I am going to give you another branch in few minutes, please try and let us know..

ashishth09 commented 6 years ago

Fixed in master branch. You can build latest from that. Official binary would be provided soon. Also datacenter should be removed from the configuration as the order will infer that from the subnet. Meanwhile here is the binary for mac/linux darwin_amd64.zip linux_amd64.zip Please re-open if still an issue.