Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing time (extra text) when creating resources #145

Closed
nleiva opened this issue Apr 6, 2022 · 5 comments
Closed

Error parsing time (extra text) when creating resources #145

nleiva opened this issue Apr 6, 2022 · 5 comments

Comments

@nleiva
Copy link
Contributor

nleiva commented Apr 6, 2022

More of a FYI.

I'm hitting an issue with the latest release of NetBox. I know I'm getting ahead of myself, so no action needed. Just sharing in case someone else runs into this. The provider creates the resources, however Terraform returns an error complaining about not being able to parse the time like in this issue on StackOverflow.

EDIT: I added a link to the NetBox breaking change in references that I believe is the culprit of this (issue netbox-community/netbox#8463).

Terraform Version

$ terraform version
Terraform v1.1.7
on linux_amd64
+ provider registry.terraform.io/e-breuninger/netbox v1.5.2

Affected Resource(s)

This affected all the resources tested:

  • netbox_platform
  • netbox_device_role
  • ...

Terraform Configuration Files

terraform {
  required_providers {
    netbox = {
      source = "e-breuninger/netbox"
    }
  }
}

provider "netbox" {
  server_url = "https://demo.netbox.dev"
  api_token = "0123456789abcdef0123456789abcdef01234567"
}

Debug Output

Panic Output

Expected Behavior

What should have happened?
Apply and create the resources

Actual Behavior

What actually happened?
It does create the resources, but Terraform errors out, so it does not save the state.

Steps to Reproduce

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

Resource:

resource "netbox_device_role" "container" {
  name      = "Container Router"
  vm_role   = true
  slug      = "container"
  color_hex = "ff0000"
}

Terraform apply:

$ terraform apply -auto-approve

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # netbox_device_role.container will be created
  + resource "netbox_device_role" "container" {
      + color_hex = "ff0000"
      + id        = (known after apply)
      + name      = "Container Router"
      + slug      = "container"
      + vm_role   = true
    }

Plan: 1 to add, 0 to change, 0 to destroy.
netbox_device_role.container: Creating...
╷
│ Warning: Possibly unsupported Netbox version
│ 
│   with provider["registry.terraform.io/e-breuninger/netbox"],
│   on main.tf line 9, in provider "netbox":
│    9: provider "netbox" {
│ 
│ This provider was tested against Netbox v3.1.3. Your Netbox version is v3.2.0. Unexpected errors may occur.
│ 
│ (and one more similar warning elsewhere)
╵
╷
│ Error: parsing time "2022-04-06T17:57:25.048803Z": extra text: "T17:57:25.048803Z"
│ 
│   with netbox_device_role.container,
│   on main.tf line 29, in resource "netbox_device_role" "container":
│   29: resource "netbox_device_role" "container" {
│ 
╵

Important Factoids

I'm running against a non-tested Netbox version (v3.2.0).

References

v3.2.0 Breaking Changes

The created field of all change-logged models now conveys a full datetime object, rather than only a date. (Previous date-only values will receive a timestamp of 00:00.) While this change is largely unconcerning, strictly-typed API consumers may need to be updated.

@arjenvri
Copy link
Contributor

This would be useful to fix, i am currently stuck because of our environment running on 3.2.0 :) Maybe the fbreckle go-netbox fork can have a fix applied until fix applied upstream? I am missing the skills to fix this myself unfortunately.

@fbreckle
Copy link
Collaborator

I was actually in the process of rebuilding the client with 3.1.10 but there are some problems with that (see fbreckle/go-netbox#9 (comment)). The corresponding branch is https://github.com/fbreckle/go-netbox/tree/feature/netbox-3.1.10 (not working with go-netbox yet). The problems are mainly with the types of the available-ips endpoints, which seem to have changed in the swagger spec (but the current implementation seems to work with newer netboxes, it is very confusing).

Then, there was a spike in PRs in this repo (looking at you, @arjenvri :D) and I focused my time on that.

So, regarding a newer client: the netbox maintainers really love to mess with their API/swagger spec, even in minor versions. They explicitly do not follow semver, see netbox-community/netbox#9084

Once we have a stable 3.1.10 release, I will start building a 3.2.0 client.

@arjenvri
Copy link
Contributor

A go netbox fix has been merged upstream!

netbox-community/go-netbox#128

@twink0r
Copy link
Contributor

twink0r commented May 23, 2022

@arjenvri, @fbreckle we build something to migrate this problem: https://github.com/riege/go-netbox-proxy

We know this is a monkey patch and should no longer stay in place as needed!

@fbreckle
Copy link
Collaborator

This should be solved with https://github.com/e-breuninger/terraform-provider-netbox/releases/tag/v2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants