terraform-provider-pritunl icon indicating copy to clipboard operation
terraform-provider-pritunl copied to clipboard

Refreshing state problem

Open zahornyak opened this issue 2 years ago • 4 comments

Currently when you create resources using Terraform and delete them on UI, terraform will give an error like this:

╷
│ Error: Non-200 response on getting the organization
│ body=500: Internal Server Error
│ 
│   with module.test_org.pritunl_organization.this,
│   on ../../modules/pritunl_org/main.tf line 1, in resource "pritunl_organization" "this":
│    1: resource "pritunl_organization" "this" {
│ 
╵

zahornyak avatar Sep 18 '23 11:09 zahornyak

Hey @zahornyak. It looks weird and strange, but for non-exists resources, foe example organizations, Pritunl API returns status code 500 (internal server error) instead of 404 (not found):

when I directly make a HTTP requests image

or do an import of an organizations that doesn't exist

terraform import pritunl_organization.guests abcd123
pritunl_organization.guests: Importing from ID "abcd123"...
pritunl_organization.guests: Import prepared!
  Prepared pritunl_organization for import
pritunl_organization.guests: Refreshing state... [id=abcd123]
╷
│ Error: Non-200 response on getting the organization
│ body=500: Internal Server Error
│
│

disc avatar Sep 19 '23 11:09 disc

I faced with an issue when I started working on the provider, but didn't find a solution. Probably I will look into it again.

disc avatar Sep 19 '23 12:09 disc

Hello,

I got the same issue with server resource:

│ Error: Error on starting server: Non-200 response on starting the server
│ body=500: Internal Server Error
│ 
│   with pritunl_server.server["my_server"],
│   on main.tf line 15, in resource "pritunl_server" "server":
│   15: resource "pritunl_server" "server" {

Maybe a retry could be added and configured in the provider declaration?

QuentinBtd avatar Sep 27 '23 12:09 QuentinBtd

Unfortunately, the issue reproduces with various resources (servers and organizations) due to a possible issue in the Pritunl servers API. It has no validation if a requested resource does exist and it fails on a json-marshaling stage of a nil object.

disc avatar Sep 27 '23 16:09 disc