oke-free icon indicating copy to clipboard operation
oke-free copied to clipboard

Error returned by GetVnic operation in VcnInternalService service.(404, NotAuthorizedOrNotFound, false) Either VNIC with ID ocid1.vnic.oc1.***.*** does not exist or you are not authorized to access it.

Open Rapha-Borges opened this issue 4 months ago • 0 comments

Ao executar o terraform apply, tendo outras instâncias no mesmo compartment, mesmo que com estado diferente de Running, ou que tenham sido criadas fora do cluster OKE, recebi o erro de que eu não tinha permissão para acessar o recurso ou que o mesmo não existia. Após investigar o erro, entendi que o problema estava na forma como o target para os backends do Network Load Balancer (NLB) estava sendo referenciado. Atualmente, o data source oci_core_instances é utilizado para retornar todas as instâncias do compartment especificado pela variável var.compartment_id, o que inclui todas as instâncias, inclusive aquelas recentemente terminadas, e não apenas as criadas pelo cluster OKE e ativas.

Testei adicionando o filtro state = "RUNNING" no data source, o que resolveu o problema ao retornar apenas as instâncias em estado Running no compartment.

No entanto, essa não é a forma que considero ideal para a configuração dos backends do NLB, pois retornar todas as instâncias em estado Running e limitar pelo número de nodes com a variável var.node_size pode causar novos erros relacionados à definição incorreta dos recursos a serem utilizados como target no NLB.

Por isso, alterei o data source para utilizar o oci_containerengine_node_pool para obter os nodes, em vez das instâncias fornecidas pelo oci_core_instances. Para que isso funcionasse corretamente, também ajustei a forma como a contagem da quantidade de backends é feita, bem como a referência no target.

Antigo:

resource "oci_network_load_balancer_network_load_balancer" "nlb" {
  backend_set_name         = oci_network_load_balancer_backend_set.nlb_backend_set_http.name
  network_load_balancer_id = oci_network_load_balancer_network_load_balancer.nlb.id
  port                     = var.node_port_http
  depends_on               = [oci_network_load_balancer_backend_set.nlb_backend_set_http]
  count                    = var.node_size
  target_id                = data.oci_core_instances.instances.instances[count.index].id
}

Novo:

resource "oci_network_load_balancer_network_load_balancer" "nlb" {
  backend_set_name         = oci_network_load_balancer_backend_set.nlb_backend_set_http.name
  network_load_balancer_id = oci_network_load_balancer_network_load_balancer.nlb.id
  port                     = var.node_port_http
  depends_on               = [oci_network_load_balancer_backend_set.nlb_backend_set_http]
  count                    = length(data.oci_containerengine_node_pool.oke_node_pool.nodes)
  target_id                = data.oci_containerengine_node_pool.oke_node_pool.nodes[count.index].id
}

Log do erro:

│ Provider version: 6.11.0, released on 2024-09-24.  
│ Service: Network Load Balancer Backend 
│ Error Message: work request did not succeed, workId: ocid1.coreservicesworkrequest.oc1..***, action: CREATED. Message: Error returned by GetVnic operation in VcnInternalService service.(404, NotAuthorizedOrNotFound, false) Either VNIC with ID ocid1.vnic.oc1.***.*** does not exist or you are not authorized to access it. (opc-request-id: ***/***/***)
│ Timestamp: 2024-09-29T22:41:30.652Z
│ Client version: Oracle-JavaSDK/2.73.3-preview1-sdk-6264-SNAPSHOT
│ Request Endpoint: [https://vcn-ad-api.svc.ad1.***/v1/internal/vnics/ocid1.vnic.oc1.***.***](https://vcn-ad-api.svc.ad1.%2A%2A%2A/v1/internal/vnics/ocid1.vnic.oc1.***.***)
│ Troubleshooting Tips: See https://docs.oracle.com/en-us/iaas/Content/API/References/apierrors.htm#apierrors_404__404_notauthorizedornotfound for more information about resolving this error
│ Also see  for details on this operation's requirements.
│ To get more info on the failing request, you can enable debug level logs as mentioned in `Using SLF4J for Logging section` in https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/javasdkconfig.htm.
│ If you are unable to resolve this VcnInternalService issue, please contact Oracle support and provide them this full error message. 
│ Resource OCID: networkLoadBalancers/ocid1.networkloadbalancer.oc1.***.***/backendSets/oke-free-backend-set-http/backends/ocid1.instance.oc1.***.***.30080 
│ Suggestion: Please retry or contact support for help with service: Network Load Balancer Backend
│ 
│ 
│   with module.loadbalancer.oci_network_load_balancer_backend.nlb_backend_http[1],
│   on loadbalancer/load-balancer.tf line 38, in resource "oci_network_load_balancer_backend" "nlb_backend_http":
│   38: resource "oci_network_load_balancer_backend" "nlb_backend_http" {```

Rapha-Borges avatar Sep 30 '24 01:09 Rapha-Borges