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

azurerm_storage_share_file crashes with panic : makechan: size out of range #24171

Closed
1 task done
cschar opened this issue Dec 9, 2023 · 2 comments · Fixed by #24179
Closed
1 task done

azurerm_storage_share_file crashes with panic : makechan: size out of range #24171

cschar opened this issue Dec 9, 2023 · 2 comments · Fixed by #24179

Comments

@cschar
Copy link
Contributor

cschar commented Dec 9, 2023

Is there an existing issue for this?

  • I have searched the existing issues

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 and review the contribution guide to help.

Terraform Version

1.6.4

AzureRM Provider Version

3.84.0

Affected Resource(s)/Data Source(s)

azurerm_storage_share_file

Terraform Configuration Files

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = ">= 3.70.0"
    }
  }
}

provider "azurerm" {
  features {}
}

locals {
  prefix = "my-prefix"
}


data "azurerm_virtual_network" "my_network" {
  name                = "my-network"
  resource_group_name = local.network_rg
}

locals {
  network_rg   = "my-network-rg"
  network_name = data.azurerm_virtual_network.my_network.name
  network_id   = data.azurerm_virtual_network.my_network.id

  location = "canadacentral"
}

resource "azurerm_log_analytics_workspace" "example" {
  name                = "${local.prefix}-law"
  location            = local.location
  resource_group_name = local.network_rg
  sku                 = "PerGB2018"
  retention_in_days   = 30
}

resource "azurerm_container_app_environment" "my_env" {
  name                       = "${local.prefix}-environment"
  location                   = local.location
  resource_group_name        = local.network_rg
  log_analytics_workspace_id = azurerm_log_analytics_workspace.example.id
}
resource "azurerm_container_app" "my_app" {
  name                         = "${local.prefix}-app"
  container_app_environment_id = azurerm_container_app_environment.my_env.id
  resource_group_name          = local.network_rg
  revision_mode                = "Single"

  template {
    container {
      name   = "nginx"
      image  = "index.docker.io/nginx:mainline-alpine3.18"
      cpu    = 0.25
      memory = "0.5Gi"

      volume_mounts {
        name = "mymount"
        path = "/usr/share/nginx/html"
      }
    }

    volume {
      storage_name = azurerm_storage_account.my_storage.name
      storage_type = "AzureFile"
      name         = "mymount"
    }
    container {
      name   = "examplecontainerapp"
      image  = "mcr.microsoft.com/azuredocs/containerapps-helloworld:latest"
      cpu    = 0.25
      memory = "0.5Gi"
    }
  }
}

resource "azurerm_storage_account" my_storage {
  name                     = replace("${local.prefix}-storage","-","")
  resource_group_name      = local.network_rg
  location                 = local.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

resource "azurerm_storage_share" "example" {
  name                 = "sharename"
  storage_account_name = azurerm_storage_account.my_storage.name
  quota                = 5
}

resource "azurerm_storage_share_file" "nginx_index" {
  name             = "index.html"
  storage_share_id = azurerm_storage_share.example.id
  source           = "${path.module}/templates/index.html"
}

resource "azurerm_container_app_environment_storage" "my_fileshare" {
  name                         = "mycontainerappstorage"
  container_app_environment_id = azurerm_container_app_environment.my_env.id
  account_name                 = azurerm_storage_account.my_storage.name
  share_name                   = azurerm_storage_share.example.name
  access_key                   = azurerm_storage_account.my_storage.primary_access_key
  access_mode                  = "ReadOnly"
}

Debug Output/Panic Output

╷
│ Error: Plugin did not respond
│
│   with module.my_container_app[0].azurerm_storage_share_file.nginx_index,
│   on ../../modules/my_container_app/main.tf line 80, in resource "azurerm_storage_share_file" "nginx_index":
│   80: resource "azurerm_storage_share_file" "nginx_index" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs
│ may contain more details.
╵

Stack trace from the terraform-provider-azurerm_v3.84.0_x5 plugin:

panic: makechan: size out of range

goroutine 223 [running]:
github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files.Client.PutFile({{{0xa58b7a0, 0xc00224c940}, {0xa58b760, 0xc00172c7b0}, 0x0, 0x0, 0x6fc23ac00, 0xd18c2e2800, 0x3, 0x6fc23ac00, ...}, ...}, ...)
        github.com/tombuildsstuff/[email protected]/storage/2020-08-04/file/files/range_put_file.go:37 +0x1a5
github.com/hashicorp/terraform-provider-azurerm/internal/services/storage.resourceStorageShareFileCreate(0x0?, {0x8e172c0?, 0xc0018a0000})
        github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/storage_share_file_resource.go:186 +0x144a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xa5b8490?, {0xa5b8490?, 0xc002412ab0?}, 0xd?, {0x8e172c0?, 0xc0018a0000?})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:766 +0x163
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0015ab180, {0xa5b8490, 0xc002412ab0}, 0xc0021d89c0, 0xc001398a80, {0x8e172c0, 0xc0018a0000})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:909 +0xa7e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00030bb18, {0xa5b8490?, 0xc0024129c0?}, 0xc001e65090)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1060 +0xdbc
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00191cb40, {0xa5b8490?, 0xc0024121b0?}, 0xc0021e4150)
        github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:859 +0x56a
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x9921b00?, 0xc00191cb40}, {0xa5b8490, 0xc0024121b0}, 0xc0021e40e0, 0x0)
        github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:467 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0003201e0, {0xa5c9ee0, 0xc001616b60}, 0xc0021f6480, 0xc0015b4cf0, 0x10161b78, 0x0)
        google.golang.org/[email protected]/server.go:1374 +0xde7
google.golang.org/grpc.(*Server).handleStream(0xc0003201e0, {0xa5c9ee0, 0xc001616b60}, 0xc0021f6480, 0x0)
        google.golang.org/[email protected]/server.go:1751 +0x9e7
google.golang.org/grpc.(*Server).serveStreams.func1.1()
        google.golang.org/[email protected]/server.go:986 +0xbb
created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 55
        google.golang.org/[email protected]/server.go:997 +0x145

Error: The terraform-provider-azurerm_v3.84.0_x5 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Expected Behaviour

no error

Actual Behaviour

Was trying to setup a app container + app container environment with a mounted file share...

tried to do an apply and had the panic output (see above)

I suspect it maybe has something to do with the 3rs party library mentioned in output :
https://github.com/tombuildsstuff/giovanni/

Note: this was initally run inside a module but I have removed it and placed it in the above as a single configuration file

Steps to Reproduce

No response

Important Factoids

No response

References

No response

@cschar
Copy link
Contributor Author

cschar commented Dec 9, 2023

the file i was uploading to the share in the templates/index.html path was empty... I changed the block to specify the content_type as such, and filled in the file with a simple 'hello world' text. The bug no longer came up... maybe has to do with a bad content_type crashing the underlying SDK.

resource "azurerm_storage_share_file" "nginx_index" {
  name             = "index.html"
  storage_share_id = azurerm_storage_share.example.id
  source           = "${path.module}/templates/index.html"
  content_type = "text/plain"
}

Copy link

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 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
1 participant