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

panic: Error reading level state: strconv.ParseInt: parsing "8580780465065941099": value out of range #16809

Closed
bourdeau opened this issue Dec 15, 2023 · 6 comments

Comments

@bourdeau
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v1.6.6
on linux_386

Affected Resource(s)

all

Terraform Configuration Files

terraform {
  required_version = ">= 1.6.6"
  cloud {
    organization = "staysail"

    workspaces {
      name = "preprod"
    }
  }
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 5.9.0"
    }
    random = ">= 3.4.3"
  }
}

Debug Output

https://gist.github.com/bourdeau/22ed5d5a28b36d760632777e86a15f36

Panic Output

https://gist.github.com/bourdeau/22ed5d5a28b36d760632777e86a15f36

Expected Behavior

terraform plan normal output

Actual Behavior

Crashes because trying to cast "8580780465065941099" to int.

panic: Error reading level state: strconv.ParseInt: parsing "8580780465065941099": value out of range

Steps to Reproduce

  1. terraform plan

Important Factoids

  • I use a user account instead of a service account.

References

I didn't find any other issue related. Maybe I didn't look hard enough.

@bourdeau bourdeau added the bug label Dec 15, 2023
@github-actions github-actions bot added the crash label Dec 15, 2023
@melinath
Copy link
Collaborator

Generally speaking, value out of range errors happen due to running on a 32-bit system - here are some open (and closed) tickets with similar errors in the past: https://github.com/hashicorp/terraform-provider-google/issues?q=is%3Aissue+is%3Aopen+%22value+out+of+range%22

It's hard to tell from your config & debug log which resource this is related to - could you share a minimal config (without modules or variables and with the smallest number of resources possible) that reproduces the issue? Thanks!

@bourdeau
Copy link
Author

bourdeau commented Dec 16, 2023

@melinath Thank you for your help

I use Terraform Cloud to store the state, but I execute terraform commands locally.

I'm on a 64bits machine (Linux ph-corsair 6.5.0-14-generic #14-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 14 14:59:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux)

My project look like this:

.
├── docs
│   └── img
│       └── logo.jpg
├── environments
│   ├── preprod
│   │   └── main.tf
│   ├── prod
│   │   └── main.tf
│   └── test
│       └── main.tf
├── Makefile
├── modules
│   └── staysail
│       ├── bucket.tf
│       ├── cloud_run.tf
│       ├── database.tf
│       ├── dns.tf
│       ├── etc
│       │   └── env.tpl
│       ├── iam.tf
│       ├── lb.tf
│       ├── main.tf
│       ├── output.tf
│       ├── registry.tf
│       ├── secrets.tf
│       ├── service_account.tf
│       └── variables.tf
└── README.md

I tried to debug creating a new environment named test which contains exactly the same config as preprod:

terraform {
  required_version = ">= 1.6.6"
  cloud {
    organization = "staysail"

    workspaces {
      name = "test"
    }
  }
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 5.9.0"
    }
    random = ">= 3.4.3"
  }
}


module "staysail" {
  source  = "../../modules/staysail"
  stage   = "test"
  is_prod = false
  db_settings = {
    tier              = "db-custom-1-3840"
    availability_type = "ZONAL"
    retained_backups  = 1
  }
  cr_api_settings = {
    cpu            = "1"
    memory         = "2048Mi"
    cpu_throttling = false
    min_scale      = "0"
    max_scale      = "1"
  }
  polaris_version = "latest"
}

The google-beta resources I use are the following:

resource "google_compute_region_network_endpoint_group" "serverless_neg" {
  project               = var.project
  provider              = google-beta
  name                  = "serverless-neg-${var.stage}"
  network_endpoint_type = "SERVERLESS"
  region                = var.region
  cloud_run {
    service = google_cloud_run_v2_service.polaris.name
  }
}

resource "google_artifact_registry_repository" "staysail" {
  provider               = google-beta
  count                  = var.is_prod ? 1 : 0
  location               = var.region
  repository_id          = "staysail"
  description            = "staysail Registery"
  format                 = "DOCKER"
  cleanup_policy_dry_run = false
  cleanup_policies {
    id     = "delete-week-old-latest"
    action = "DELETE"
    condition {
      tag_state  = "UNTAGGED"
      older_than = "604800s"
    }
  }
}

I also use Global HTTP Load Balancer Terraform Module for Serverless NEGs, which uses google-beta:

module "gce-lb-http" {
  source  = "GoogleCloudPlatform/lb-http/google//modules/serverless_negs"
  version = "~> 9.0"
  ...
}

terraform plan in the new testenvironment went absolutely fine. The bug only occurs in existing terraform states (prodand preprod).

The bug appeared after a terraform init -upgrade, no changes made.

I can push the full code on a public repo if it helps.

Edit: I'm sorry, I just realized I didn't post the issue on the google-beta repository. Do you want me to open it there?

@ggtisc
Copy link
Collaborator

ggtisc commented Mar 4, 2024

Hi @bourdeau if it is under your possibilities to share the full code please do it. Have you checked the past issues?
What are you trying to parse and where is it?

@ggtisc ggtisc self-assigned this Mar 4, 2024
@ggtisc ggtisc added waiting-response forward/review In review; remove label to forward labels Mar 4, 2024
@rileykarson
Copy link
Collaborator

rileykarson commented Mar 4, 2024

Generally speaking, value out of range errors happen due to running on a 32-bit system....

A 32-bit system can only run a 32-bit binary but a 64-bit system can run either a 32-bit or 64-bit binary. This error generally happens when folks on an AMD64 system have accidentally installed an i386 binary- 32 bit systems are pretty rare nowadays.

The big trap causing this to happen is on https://developer.hashicorp.com/terraform/install which lists i386/ARM before AMD64/ARM64 (and happens most commonly on Windows, where package managers are less ubiquitious. although that's not the case here):

image

@bourdeau while your system is AMD64 as indicated by the x86_64 in your system version string, the Terraform binary you've downloaded is i386 (32-bit). In your original post see the results from terraform -v:

Terraform v1.6.6
on linux_386

For an AMD64 binary you'd expect linux_amd64. This is from my system where I'm using Terraform 1.5.2:

Terraform v1.5.2
on linux_amd64

You should be able to replace your binary w/ the AMD64 one.

@rileykarson
Copy link
Collaborator

I reworked #6518 into a canonical issue, deduplicating.

@rileykarson rileykarson added service/terraform and removed forward/review In review; remove label to forward labels Mar 5, 2024
Copy link

github-actions bot commented Apr 5, 2024

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants