CiscoDevNet / terraform-provider-aci

Terraform Cisco ACI provider
https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs
Mozilla Public License 2.0
88 stars 101 forks source link

Issues with aci_physical_domain and aci_l3_domain_profile #43

Closed jgcasd closed 4 years ago

jgcasd commented 4 years ago

aci_physical_domain and aci_l3_domain_profile both will not correctly set the relation for "relation_infra_rs_vlan_ns". It just stays empty after running the config. Also, both of these resources are failing when run a 2nd time with this error:

[AWS CodeBuild Plugin] * module.shared.aci_physical_domain.vcenter: 1 error occurred: [AWS CodeBuild Plugin] * aci_physical_domain.vcenter: unknown attribute 'descr' in element 'physDomP'

An example of the config is:

resource "aci_physical_domain" "vcenter" { name = "vcenter" relation_infra_rs_vlan_ns = "${aci_vlan_pool.vcenter.id}" }

nkatarmal-crest commented 4 years ago

@jgcasd Can you please share the logs? That will help us to troubleshoot the issue.

aj-cruz commented 4 years ago

I'm having sort of the same issue, when I do this:

resource "aci_physical_domain" "PhyDom" {
  depends_on = [aci_vlan_pool.VLAN-Pools]
  name  = "PhyDom"
  relation_infra_rs_vlan_ns = "PHYS-VLAN-POOL"
}

It creates the domain with no error but does not attach the vlan pool. Then I try changing to use relation_infra_rs_vlan_ns_def (not sure which is the proper way). Next time I apply I get:

Error: unknown attribute 'descr' in element 'physDomP'

  on aci.tf line 112, in resource "aci_physical_domain" "PhyDom":
 112: resource "aci_physical_domain" "PhyDom" {

Then the next apply does not generate the error, but still does not attach the vlan pool

Then if I switch back to using relation_infra_rs_vlan_ns, I get the unknown attribute error again, but only once.

aj-cruz commented 4 years ago

I also tried using the VLAN pool Dn instead of the name, same results

aj-cruz commented 4 years ago

I'm no programmer but I think I see the problem? The POST that get's sent when I run the apply is: {"infraRsVlanNs":{"attributes":{"dn":"uni/phys-PhyDom/rsvlanNs","tnFvnsVlanInstPName":"uni/infra/vlanns-[PHYS-VLAN-POOL]-static"}}}

And then I see this error in the trace: {"code":"400","text":"unknown attribute 'tnFvnsVlanInstPName' in element 'infraRsVlanNs'"}

I think the attribute in the POST should be "fvnsVlanInstP" instead of "tnFvnsVlanInstPName" right? for ACI 4.2(3q) anyways.

aj-cruz commented 4 years ago

I don't know if I'm in the right place, but I see that terraform-provider-aci/aci/resource_rest.go imports "github.com/ciscoecosystem/aci-go-client/client" and digging through aci-go-client/client/physDomP_service.go I see:

func (sm *ServiceManager) CreateRelationinfraRsVlanNsFromPhysicalDomain(parentDn, tnFvnsVlanInstPName string) error {
    dn := fmt.Sprintf("%s/rsvlanNs", parentDn)
    containerJSON := []byte(fmt.Sprintf(`{
        "%s": {
            "attributes": {
                "dn": "%s","tnFvnsVlanInstPName": "%s"

            }
        }
    }`, "infraRsVlanNs", dn, tnFvnsVlanInstPName))

***Cutting off the rest***

I tried changing those references in physDomP_service.go, compiled the project, put it in my ~/.terraform.d/plugins directory, did terraform init (confirmed it did not download the provider but used plugin), but I still see the POSTS come through with tnFvnsVlanInstPName instead of fvnsVlanInstP. I tried grep'ing the provider for "tnFvnsVlanInstPName" but physDomP_service.go seems to be the only place I would change that. Oh also, I don't really know what I'm doing...

nkatarmal-crest commented 4 years ago

@aj-cruz Thank you for the detailed investigation here, I will fix this issue.

aj-cruz commented 4 years ago

@nkatarmal-crest I see you pushed a fix for this, but I am still not able to attach a VLAN pool. The error from the post has changed to "unknown property value [PHYS-VLAN-POOL]-static" Here is my .tf file:

resource "aci_vlan_pool" "PHYS-VLAN-POOL" {
  name  = "PHYS-VLAN-POOL"
  alloc_mode  = "static"
}
resource "aci_physical_domain" "PhyDom" {
  depends_on = [aci_vlan_pool.PHYS-VLAN-POOL]
  name  = "PhyDom"
  relation_infra_rs_vlan_ns = aci_vlan_pool.PHYS-VLAN-POOL.id
}

And here is a snippet of the trace when I run the apply:

2020/06/16 08:55:55 [DEBUG] aci_physical_domain.PhyDom: applying the planned Create change
2020/06/16 08:55:55 [TRACE] GRPCProvider: ApplyResourceChange
2020-06-16T08:55:55.339-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 [DEBUG] PhysicalDomain: Beginning Creation
2020-06-16T08:55:55.339-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 HTTP request POST /api/node/mo.json &{POST https://apic.ajlab.local/api/node/mo.json HTTP/1.1 1 1 map[] {{"physDomP":{"attributes":{"dn":"uni/phys-PhyDom","rn":"phys-PhyDom","status":"created, modified"}}}} 0x765d90 100 [] false apic.ajlab.local map[] map[] <nil> map[]   <nil> <nil> <nil> 0xc0000380a8}
2020-06-16T08:55:55.339-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 [DEBUG] Begin Injection
2020-06-16T08:55:55.339-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 HTTP request after injection POST /api/node/mo.json &{POST https://apic.ajlab.local/api/node/mo.json HTTP/1.1 1 1 map[Cookie:[APIC-Cookie=MyMAAAAAAAAAAAAAAAAAAP9e7pVmnlXYfNbADq8duxRBN9qB2ckfEy0eTFsrhmLvicyYkhyktgCCzGPL/5BbisDde6Ctplg73NnSKXtBGiG6fbkrpFbt+ZqX5AapA54YEPiXU4R6r39EhC2btRpLAyxvTljtckC+HAW/Kwm7mY6qhU2dy00V7cbZCNjBPFGQMQubxk6s1PLyAobbe/7rrg==]] {{"physDomP":{"attributes":{"dn":"uni/phys-PhyDom","rn":"phys-PhyDom","status":"created, modified"}}}} 0x765d90 100 [] false apic.ajlab.local map[] map[] <nil> map[]   <nil> <nil> <nil> 0xc0000380a8}
2020-06-16T08:55:55.340-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 [DEBUG] Begining DO method https://apic.ajlab.local/api/node/mo.json
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: 
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: 
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci:  HTTP request: {}
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: HTTP Request: POST https://apic.ajlab.local/api/node/mo.json
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 nHTTP Response: 200 200 OK &{200 OK 200 HTTP/1.1 1 1 map[Access-Control-Allow-Credentials:[false] Access-Control-Allow-Headers:[Origin, X-Requested-With, Content-Type, Accept, devcookie, APIC-challenge, Request-Tag] Access-Control-Allow-Methods:[POST,GET,OPTIONS,DELETE] Access-Control-Allow-Origin:[http://127.0.0.1:8000] Cache-Control:[no-cache="Set-Cookie, Set-Cookie2"] Client-Cert-Enabled:[false] Connection:[keep-alive] Content-Length:[30] Content-Type:[application/json] Date:[Tue, 16 Jun 2020 13:55:55 GMT] Server:[Cisco APIC] Strict-Transport-Security:[max-age=31536000; includeSubDomains] X-Content-Type-Options:[nosniff] X-Frame-Options:[SAMEORIGIN]] 0xc0001d1a80 30 [] false false map[] 0xc000108a00 0xc00011b130}
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci:  HTTP response unique string POST https://apic.ajlab.local/api/node/mo.json {"totalCount":"0","imdata":[]}
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 [DEBUG] Exit from do method
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 [DEBUG] Exit from errors {"imdata":[],"totalCount":"0"}
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 HTTP request POST /api/node/mo.json &{POST https://apic.ajlab.local/api/node/mo.json HTTP/1.1 1 1 map[] {{"infraRsVlanNs":{"attributes":{"dn":"uni/phys-PhyDom/rsvlanNs","tDn":"[PHYS-VLAN-POOL]-static"}}}} 0x765d90 98 [] false apic.ajlab.local map[] map[] <nil> map[]   <nil> <nil> <nil> 0xc0000380a8}
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 [DEBUG] Begin Injection
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 HTTP request after injection POST /api/node/mo.json &{POST https://apic.ajlab.local/api/node/mo.json HTTP/1.1 1 1 map[Cookie:[APIC-Cookie=MyMAAAAAAAAAAAAAAAAAAP9e7pVmnlXYfNbADq8duxRBN9qB2ckfEy0eTFsrhmLvicyYkhyktgCCzGPL/5BbisDde6Ctplg73NnSKXtBGiG6fbkrpFbt+ZqX5AapA54YEPiXU4R6r39EhC2btRpLAyxvTljtckC+HAW/Kwm7mY6qhU2dy00V7cbZCNjBPFGQMQubxk6s1PLyAobbe/7rrg==]] {{"infraRsVlanNs":{"attributes":{"dn":"uni/phys-PhyDom/rsvlanNs","tDn":"[PHYS-VLAN-POOL]-static"}}}} 0x765d90 98 [] false apic.ajlab.local map[] map[] <nil> map[]   <nil> <nil> <nil> 0xc0000380a8}
2020-06-16T08:55:55.350-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 [DEBUG] Begining DO method https://apic.ajlab.local/api/node/mo.json
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci:  HTTP request: {}
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: HTTP Request: POST https://apic.ajlab.local/api/node/mo.json
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 nHTTP Response: 400 400 Bad Request &{400 Bad Request 400 HTTP/1.1 1 1 map[Access-Control-Allow-Credentials:[false] Access-Control-Allow-Headers:[Origin, X-Requested-With, Content-Type, Accept, devcookie, APIC-challenge, Request-Tag] Access-Control-Allow-Methods:[POST,GET,OPTIONS,DELETE] Access-Control-Allow-Origin:[http://127.0.0.1:8000] Connection:[keep-alive] Content-Length:[197] Content-Type:[application/json] Date:[Tue, 16 Jun 2020 13:55:55 GMT] Server:[Cisco APIC]] 0xc0001d1b80 197 [] false false map[] 0xc000108d00 0xc00011b130}
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci:  HTTP response unique string POST https://apic.ajlab.local/api/node/mo.json {"totalCount":"1","imdata":[{"error":{"attributes":{"code":"120","text":"unknown property value [PHYS-VLAN-POOL]-static, name tDn, class infraRsVlanNs [(Dn0)] Dn0=uni\/phys-PhyDom\/rsvlanNs, "}}}]}
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 [DEBUG] Exit from do method
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 [DEBUG] uni/phys-PhyDom: Creation finished successfully
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 [DEBUG] uni/phys-PhyDom: Beginning Read
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 HTTP request GET /api/node/mo/uni/phys-PhyDom.json &{GET https://apic.ajlab.local/api/node/mo/uni/phys-PhyDom.json HTTP/1.1 1 1 map[] <nil> <nil> 0 [] false apic.ajlab.local map[] map[] <nil> map[]   <nil> <nil> <nil> 0xc0000380a8}
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 [DEBUG] Begin Injection
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 HTTP request after injection GET /api/node/mo/uni/phys-PhyDom.json &{GET https://apic.ajlab.local/api/node/mo/uni/phys-PhyDom.json HTTP/1.1 1 1 map[Cookie:[APIC-Cookie=MyMAAAAAAAAAAAAAAAAAAP9e7pVmnlXYfNbADq8duxRBN9qB2ckfEy0eTFsrhmLvicyYkhyktgCCzGPL/5BbisDde6Ctplg73NnSKXtBGiG6fbkrpFbt+ZqX5AapA54YEPiXU4R6r39EhC2btRpLAyxvTljtckC+HAW/Kwm7mY6qhU2dy00V7cbZCNjBPFGQMQubxk6s1PLyAobbe/7rrg==]] <nil> <nil> 0 [] false apic.ajlab.local map[] map[] <nil> map[]   <nil> <nil> <nil> 0xc0000380a8}
2020-06-16T08:55:55.374-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 [DEBUG] Begining DO method https://apic.ajlab.local/api/node/mo/uni/phys-PhyDom.json
2020-06-16T08:55:55.382-0500 [DEBUG] plugin.terraform-provider-aci: 2020/06/16 08:55:55 
nkatarmal-crest commented 4 years ago

@aj-cruz This issue will be resolved in the next release of the provider. The release should be available soon in next couple of days maybe.

aj-cruz commented 4 years ago

Ah gotcha I thought if I cloned and re compiled it would be available immediately. Sorry I'm still new to git. Thanks!

nkatarmal-crest commented 4 years ago

@aj-cruz This issue should be resolved in the provider v0.3.0. Please try to run your terraform configuration using that version and let me know whether it solves your error not.

aj-cruz commented 4 years ago

@nkatarmal-crest Confirmed it is fixed. Thanks.