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

Terraform fails to deploy from a closed channel #647

Open
gboutry opened this issue Dec 13, 2024 · 2 comments
Open

Terraform fails to deploy from a closed channel #647

gboutry opened this issue Dec 13, 2024 · 2 comments
Labels
area/application kind/bug indicates a bug in the project

Comments

@gboutry
Copy link
Contributor

gboutry commented Dec 13, 2024

Description

k8s team release a 1.31/candidate, which closed 1.31/beta (not sure about relation here).

Juju automatically sets channel to 1.31/candidate when trying to use 1.31/beta. But terraform really does not like this.

Urgency

Casually reporting

Terraform Juju Provider version

0.15.1

Terraform version

1.5.7

Juju version

3.6.1

Terraform Configuration(s)

data "juju_model" "machine_model" {
  name = var.machine_model
}

resource "juju_application" "k8s" {
  name  = "k8s"
  model = data.juju_model.machine_model.name

  charm {
    name     = "k8s"
    channel  = "1.31/beta"
    base     = "[email protected]"
  }
}

Reproduce / Test

terraform init
terraform apply

Debug/Panic Output

data.juju_model.machine_model: Read complete after 0s [id=d6981ca0-0e1a-42a9-8ed4-e3c324a1dee5]                                                                                                                                      
                                                                                                                                                                                                                                                         
                    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:                                                                                                                                                                                        
                                                                                                                                                                                                                                                         
                      # juju_application.k8s will be created                                                                                                                                                                                             
                      + resource "juju_application" "k8s" {                                                                                                                                                                                              
                          + config            = {                                                                                                                                                                                                        
                              + "load-balancer-cidrs"   = "10.206.54.240-10.206.54.250"                                                                                                                                                                  
                              + "load-balancer-enabled" = "true"                                                                                                                                                                                         
                              + "load-balancer-l2-mode" = "true"                                                                                                                                                                                         
                            }                                                                                                                                                                                                                            
                          + constraints       = (known after apply)                                                                                                                                                                                      
                          + endpoint_bindings = [                                                                                                                                                                                                        
                              + {                                                                                                                                                                                                                        
                                  + space = "management"                                                                                                                                                                                                 
                                },                                                                                                                                                                                                                       
                            ]                                                                                                                                                                                                                            
                          + id                = (known after apply)                                                                                                                                                                                      
                          + model             = "openstack-machines"                                                                                                                                                                                     
                          + name              = "k8s"                                                                                                                                                                                                    
                          + placement         = (known after apply)                                                                                                                                                                                      
                          + principal         = (known after apply)                                                                                                                                                                                      
                          + storage           = (known after apply)                                                                                                                                                                                      
                          + trust             = false                                                                                                                                                                                                    
                          + units             = 0                                                                                                                                                                                                        
                                                                                                                                                                                                                                                         
                          + charm {                                                                                                                                                                                                                      
                              + base     = "[email protected]"                                                                                                                                                                                                
                              + channel  = "1.31/beta"                                                                                                                                                                                                   
                              + name     = "k8s"                                                                                                                                                                                                         
                              + revision = (known after apply)                                                                                                                                                                                           
                              + series   = (known after apply)                                                                                                                                                                                           
                            }                                                                                                                                                                                                                            
                        }                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                         
                    Plan: 1 to add, 0 to change, 0 to destroy.                                                                                                                                                                                           
                    juju_application.k8s: Creating...                                                                                                                                                                                                    
                                                                                                                                                                                                                                                         
           WARNING                                                                                                                                                                                                                       terraform.py:221
                    Error: Provider produced inconsistent result after apply                                                                                                                                                                             
                                                                                                                                                                                                                                                         
                    When applying changes to juju_application.k8s, provider                                                                                                                                                                              
                    "provider[\"registry.terraform.io/juju/juju\"]" produced an unexpected new                                                                                                                                                           
                    value: .charm[0].channel: was cty.StringVal("1.31/beta"), but now                                                                                                                                                                    
                    cty.StringVal("1.31/candidate").                                                                                                                                                                                                     
                                                                                                                                                                                                                                                         
                    This is a bug in the provider, which should be reported in the provider's own                                                                                                                                                        
                    issue tracker.

Notes & References

This is casually reporting to make sure it's documented. This might be a wanted behavior at the end of the day.

@gboutry gboutry added kind/bug indicates a bug in the project state/untriaged untriaged bug report labels Dec 13, 2024
@alesstimec alesstimec added area/application and removed state/untriaged untriaged bug report labels Dec 13, 2024
@alesstimec
Copy link
Member

Thank you for reporting this bug. We will discuss how to address it as soon as possible, but i'm not sure much can be done in the terraform provider other than documenting this behaviour.

@hmlanigan
Copy link
Member

This is the expected behavior with snaps and charms. If a requested risk within a track is closed, use the next more stable risk within the track.

As @alesstimec mentioned, terraform does not like this behavior as a declarative language. This functionality currently resides within the juju controller and is outside of control for the provider. We can document the behavior as a note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/application kind/bug indicates a bug in the project
Projects
None yet
Development

No branches or pull requests

3 participants