devopsarr / terraform-provider-radarr

Terraform Radarr provider
https://registry.terraform.io/providers/devopsarr/radarr
Mozilla Public License 2.0
11 stars 0 forks source link

Problem with Tags, client error 404 #246

Closed dmfrey closed 5 months ago

dmfrey commented 7 months ago

I have a terraform which creates a tag and autotag:

resource "radarr_tag" "movie" {
  label = "movie"
}

resource "radarr_auto_tag" "movie" {
  name                      = "Movie"
  remove_tags_automatically = true
  tags                      = [radarr_tag.movie.id]

  specifications = [
    {
      name           = "folder"
      implementation = "RootFolderSpecification"
      negate         = false
      required       = false
      value          = "/media/movies"
    }
  ]
}

It seems to run successfully the first time. I can verify in the web interface that the tag is there. Subsequent runs, however, error out. Here is the log from weaveworks tf-controller:

2024/02/09 19:02:25 Starting the runner... version  sha                                                                                                                                                                                                                                             
{"level":"info","ts":"2024-02-09T19:02:39.361Z","logger":"runner.terraform","msg":"preparing for Upload and Extraction","instance-id":""}                                                                                                                                                           
{"level":"info","ts":"2024-02-09T19:02:39.363Z","logger":"runner.terraform","msg":"write backend config","instance-id":"","path":"/tmp/media-radarr-provisioner","config":"backend_override.tf"}                                                                                                    
{"level":"info","ts":"2024-02-09T19:02:39.363Z","logger":"runner.terraform","msg":"write config to file","instance-id":"","filePath":"/tmp/media-radarr-provisioner/backend_override.tf"}                                                                                                           
{"level":"info","ts":"2024-02-09T19:02:39.363Z","logger":"runner.terraform","msg":"looking for path","instance-id":"","file":"terraform"}                                                                                                                                                           
{"level":"info","ts":"2024-02-09T19:02:39.364Z","logger":"runner.terraform","msg":"creating new terraform","instance-id":"6f8b5d93-21c3-4b86-8416-35f120d08fef","workingDir":"/tmp/media-radarr-provisioner","execPath":"/usr/local/bin/terraform"}                                                 
{"level":"info","ts":"2024-02-09T19:02:39.366Z","logger":"runner.terraform","msg":"setting envvars","instance-id":"6f8b5d93-21c3-4b86-8416-35f120d08fef"}                                                                                                                                           
{"level":"info","ts":"2024-02-09T19:02:39.366Z","logger":"runner.terraform","msg":"getting envvars from os environments","instance-id":"6f8b5d93-21c3-4b86-8416-35f120d08fef"}                                                                                                                      
{"level":"info","ts":"2024-02-09T19:02:39.367Z","logger":"runner.terraform","msg":"setting up the input variables","instance-id":"6f8b5d93-21c3-4b86-8416-35f120d08fef"}                                                                                                                            
{"level":"info","ts":"2024-02-09T19:02:39.367Z","logger":"runner.terraform","msg":"mapping the Spec.Values","instance-id":"6f8b5d93-21c3-4b86-8416-35f120d08fef"}                                                                                                                                   
{"level":"info","ts":"2024-02-09T19:02:39.367Z","logger":"runner.terraform","msg":"mapping the Spec.Vars","instance-id":"6f8b5d93-21c3-4b86-8416-35f120d08fef"}                                                                                                                                     
{"level":"info","ts":"2024-02-09T19:02:39.367Z","logger":"runner.terraform","msg":"mapping the Spec.VarsFrom","instance-id":"6f8b5d93-21c3-4b86-8416-35f120d08fef"}                                                                                                                                 
{"level":"info","ts":"2024-02-09T19:02:39.372Z","logger":"runner.terraform","msg":"generating the template founds"}                                                                                                                                                                                 
{"level":"info","ts":"2024-02-09T19:02:39.372Z","logger":"runner.terraform","msg":"main.tf.tpl not found, skipping"}                                                                                                                                                                                
{"level":"info","ts":"2024-02-09T19:02:39.372Z","logger":"runner.terraform","msg":"initializing","instance-id":"6f8b5d93-21c3-4b86-8416-35f120d08fef"}                                                                                                                                              
{"level":"info","ts":"2024-02-09T19:02:39.372Z","logger":"runner.terraform","msg":"mapping the Spec.BackendConfigsFrom","instance-id":"6f8b5d93-21c3-4b86-8416-35f120d08fef"}                                                                                                                       
{                                                                                                                                                                                                                                                                                                   
  "terraform_version": "1.3.9",                                                                                                                                                                                                                                                                     
  "platform": "linux_amd64",                                                                                                                                                                                                                                                                        
  "provider_selections": {                                                                                                                                                                                                                                                                          
    "registry.terraform.io/devopsarr/radarr": "2.1.0"                                                                                                                                                                                                                                               
  },                                                                                                                                                                                                                                                                                                
  "terraform_outdated": true                                                                                                                                                                                                                                                                        
}                                                                                                                                                                                                                                                                                                   

Initializing the backend...                                                                                                                                                                                                                                                                         

Successfully configured the backend "kubernetes"! Terraform will automatically                                                                                                                                                                                                                      
use this backend unless the backend configuration changes.                                                                                                                                                                                                                                          

Initializing provider plugins...                                                                                                                                                                                                                                                                    
- Finding devopsarr/radarr versions matching "2.1.0"...                                                                                                                                                                                                                                             
- Installing devopsarr/radarr v2.1.0...                                                                                                                                                                                                                                                             
- Installed devopsarr/radarr v2.1.0 (self-signed, key ID E1D227AB81897AC6)                                                                                                                                                                                                                          

Partner and community providers are signed by their developers.                                                                                                                                                                                                                                     
If you'd like to know more about provider signing, you can read about it here:                                                                                                                                                                                                                      
https://www.terraform.io/docs/cli/plugins/signing.html                                                                                                                                                                                                                                              

Terraform has made some changes to the provider dependency selections recorded                                                                                                                                                                                                                      
in the .terraform.lock.hcl file. Review those changes and commit them to your                                                                                                                                                                                                                       
version control system if they represent changes you intended to make.                                                                                                                                                                                                                              

Terraform has been successfully initialized!                                                                                                                                                                                                                                                        
{"level":"info","ts":"2024-02-09T19:02:40.601Z","logger":"runner.terraform","msg":"workspace select"}                                                                                                                                                                                               
{"level":"info","ts":"2024-02-09T19:02:40.613Z","logger":"runner.terraform","msg":"creating a plan","instance-id":"6f8b5d93-21c3-4b86-8416-35f120d08fef"}                                                                                                                                           

Error: Client Error                                                                                                                                                                                                                                                                                 

  with radarr_tag.movie,                                                                                                                                                                                                                                                                            
  on tags.tf line 1, in resource "radarr_tag" "movie":                                                                                                                                                                                                                                              
   1: resource "radarr_tag" "movie" {                                                                                                                                                                                                                                                               

Unable to read tag, got error: 404 Not Found                                                                                                                                                                                                                                                        
Details:                                                                                                                                                                                                                                                                                            
{                                                                                                                                                                                                                                                                                                   
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.4",                                                                                                                                                                                                                                      
  "title": "Not Found",                                                                                                                                                                                                                                                                             
  "status": 404,                                                                                                                                                                                                                                                                                    
  "traceId": "00-d93a00c9d5f6b93b446219ce5b04a420-cbc8965e865fde9d-00"                                                                                                                                                                                                                              
}                                                                                                                                                                                                                                                                                                   
{"level":"error","ts":"2024-02-09T19:02:40.890Z","logger":"runner.terraform","msg":"error creating the plan","instance-id":"6f8b5d93-21c3-4b86-8416-35f120d08fef","error":"exit status 1\n\nError: Client Error\n\n  with radarr_tag.movie,\n  on tags.tf line 1, in resource \"radarr_tag\" \"movie
{"level":"info","ts":"2024-02-09T19:02:40.892Z","logger":"runner.terraform","msg":"cleanup TmpDir","instance-id":"6f8b5d93-21c3-4b86-8416-35f120d08fef","tmpDir":"/tmp/media-radarr-provisioner"}                                                                                                   
Stream closed EOF for media/radarr-provisioner-tf-runner (tf-runner)                                                                                                                                                                                                                                
Fuochi commented 7 months ago

Hi @dmfrey, Thanks for opening the issue. Unfortunately, I'm unable to replicate it. Which version of Radarr are you using? I tested with v5.1.3.8246

dmfrey commented 7 months ago

@Fuochi I'm using version 5.2.6.8376

Fuochi commented 7 months ago

Hi @dmfrey, I tried again with v5.2.6.8376, using Terraform v1.3.9, and provider v2.1.0. I still can't replicate the issue. You could try to check if the ID in state is correct using terraform state show radarr_tag.movie. Then you can either make an API call, or use the radarr_tags datasource to check the real tag ID.

404 is a very specific error, and looking at where it happens, it seems the response of GET on /api/v3/tag/{tagID}. Which means that either the tag is deleted between runs, or the ID in state isn't aligned with the real one. I'm not sure I can help you further on this. Please check the IDs and let me know.

dmfrey commented 5 months ago

I'm not sure what's going on. I was able to pull the tfstate secret and use gzip to decode it. It showed me the id. I removed readarr and the provisioned completely, including the tfstate secret, lease, etc. I then deployed it again and it was fine.

Fuochi commented 5 months ago

Ok, quite weird! Still thanks