orange-cloudfoundry / terraform-provider-cloudfoundry

A terraform provider to manage a Cloud Foundry instance.
Apache License 2.0
31 stars 8 forks source link

Panic when trying to refresh non existing org quota #35

Open gberche-orange opened 6 years ago

gberche-orange commented 6 years ago

When trying to refresh the TF state with an org quota which is missing in the cloud, the provider panics with the following traces:

2018-05-29T15:12:45.837Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: {
2018-05-29T15:12:45.837Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:   "description": "Space Quota Definition could not be found: 52606bcc-fe61-4398-831e-ca9d56dbbddf",
2018-05-29T15:12:45.837Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:   "error_code": "CF-SpaceQuotaDefinitionNotFound",
2018-05-29T15:12:45.837Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:   "code": 310007
2018-05-29T15:12:45.837Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: }
2018-05-29T15:12:45.837Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: 
2018-05-29T15:12:45.840Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: panic: interface conversion: interface {} is models.QuotaFields, not models.SpaceQuota
2018-05-29T15:12:45.840Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: 
2018-05-29T15:12:45.840Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: goroutine 1209 [running]:
2018-05-29T15:12:45.841Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: github.com/orange-cloudfoundry/terraform-provider-cloudfoundry/resources.CfQuotaResource.Exists(0x0, 0x0, 0xc42018bf80
, 0xfacc20, 0xc420098a00, 0x7f32da03d000, 0x0, 0x30)
2018-05-29T15:12:45.842Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:         /home/travis/gopath/src/github.com/orange-cloudfoundry/terraform-provider-cloudfoundry/resources/quotas.go:197
 +0x791
2018-05-29T15:12:45.842Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: github.com/orange-cloudfoundry/terraform-provider-cloudfoundry/resources.(*CfQuotaResource).Exists(0xc420476690, 0xc42
018bf80, 0xfacc20, 0xc420098a00, 0xf99cc0, 0x100050100000001, 0xc42018bf80)
2018-05-29T15:12:45.843Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:         <autogenerated>:1 +0x67
2018-05-29T15:12:45.843Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: github.com/orange-cloudfoundry/terraform-provider-cloudfoundry/resources.(CfResource).Exists-fm(0xc42018bf80, 0xfacc20
, 0xc420098a00, 0x24, 0x1714940, 0x0)
2018-05-29T15:12:45.844Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:         /home/travis/gopath/src/github.com/orange-cloudfoundry/terraform-provider-cloudfoundry/resources/cf_resource.g
o:24 +0x4d
2018-05-29T15:12:45.844Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: github.com/hashicorp/terraform/helper/schema.(*Resource).Refresh(0xc4203440c0, 0xc42035ca50, 0xfacc20, 0xc420098a00, 0
xc4201539e0, 0xc420810b01, 0x80000000018)
2018-05-29T15:12:45.845Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:         /home/travis/gopath/src/github.com/hashicorp/terraform/helper/schema/resource.go:298 +0x3bf
2018-05-29T15:12:45.845Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: github.com/hashicorp/terraform/helper/schema.(*Provider).Refresh(0xc4200f67e0, 0xc42035ca00, 0xc42035ca50, 0x7f32da03d
000, 0x0, 0x0)
2018-05-29T15:12:45.846Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:         /home/travis/gopath/src/github.com/hashicorp/terraform/helper/schema/provider.go:284 +0x9a
2018-05-29T15:12:45.846Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Refresh(0xc42026dfc0, 0xc420250bb0, 0xc420250cc0, 0x0,
 0x0)
2018-05-29T15:12:45.846Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:         /home/travis/gopath/src/github.com/hashicorp/terraform/plugin/resource_provider.go:510 +0x4e
2018-05-29T15:12:45.847Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: reflect.Value.call(0xc4202632c0, 0xc42000c9a0, 0x13, 0xfc103c, 0x4, 0xc420964f20, 0x3, 0x3, 0x403a23, 0xc420232380, ..
.)
2018-05-29T15:12:45.848Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:         /home/travis/.gimme/versions/go1.9.linux.amd64/src/reflect/value.go:434 +0x906
2018-05-29T15:12:45.848Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: reflect.Value.Call(0xc4202632c0, 0xc42000c9a0, 0x13, 0xc4203f2720, 0x3, 0x3, 0xc4203f2720, 0xc4203f2728, 0xc420355ec0)

2018-05-29T15:12:45.849Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:         /home/travis/.gimme/versions/go1.9.linux.amd64/src/reflect/value.go:302 +0xa4
2018-05-29T15:12:45.850Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: net/rpc.(*service).call(0xc420482d40, 0xc42005a190, 0xc420015a28, 0xc4200f1500, 0xc4208f82c0, 0xdd1f20, 0xc420250bb0, 
2018-05-29T15:12:45.850Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:         /home/travis/.gimme/versions/go1.9.linux.amd64/src/net/rpc/server.go:381 +0x142
2018-05-29T15:12:45.850Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1: created by net/rpc.(*Server).ServeCodec
2018-05-29T15:12:45.850Z [DEBUG] plugin.terraform-provider-cloudfoundry_v0.9.1:         /home/travis/.gimme/versions/go1.9.linux.amd64/src/net/rpc/server.go:475 +0x36b
2018/05/29 15:12:45 [ERROR] root: eval: *terraform.EvalRefresh, err: cloudfoundry_space.cassandra-smoke-tests-space: unexpected EOF
obeyler commented 5 years ago

se placer sur à coté de terraform.state terraform state list |grep quota ça donne la liste de quota et pour chaque quota terraform state rm [quota] ensuite commit du fichier

gberche-orange commented 5 years ago

For english speakers, the workaround is to apply the following

cd /path/to/terraform.tfstate
terraform state list | grep cloudfoundry_quota | xargs -n 1 terraform state rm