You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #652 from SimoneDutto/fix-change-base
#652
## Description
This PR adds support to update the base in application charms by requiring a replace in case of a machine charm, and perform the upgrade in case of a k8s charm.
Fixes: re #635
## Type of change
- Add support to update `base` for application charms
## QA Steps
### LXD
```terraform
terraform {
required_providers {
juju = {
version = "~> 0.15.0"
source = "juju/juju"
}
}
}
provider "juju" {
controller_addresses = "10.229.36.127:17070"
username = "admin"
password = <redacted>
ca_certificate = file("ca.crt")
}
resource "juju_model" "this" {
name = "test-model"
}
resource "juju_application" "this" {
model = juju_model.this.name
name = "test-app"
charm {
name = "ubuntu"
base = "ubuntu@22.04"
}
}
```
`terraform apply`
`juju status` and you should see base=22.04
Now update the base
```terraform
resource "juju_application" "this" {
model = juju_model.this.name
name = "test-app"
charm {
name = "ubuntu"
base = "ubuntu@20.04"
}
}
```
`terraform plan` and you should see `~ base = "ubuntu@22.04" -> "ubuntu@20.04" # forces replacement`
`terraform apply`
Now we have two scenarios:
- happy (maybe just in the tests): the changes go though and you now have your new charm with the updated charm.
- sad: terraform tries to recreate the application before it was destroyed and errors out. If you rerun it, you now have your updated charm.
`juju status` and you should see base=20.04
### Microk8s
```terraform
terraform {
required_providers {
juju = {
version = "~> 0.15.0"
source = "juju/juju"
}
}
}
provider "juju" {
controller_addresses = "10.152.183.78:17070"
username = "admin"
password = "<redacted>"
ca_certificate = file("ca.crt")
}
resource "juju_model" "this" {
name = "test-model"
}
resource "juju_application" "this" {
model = juju_model.this.name
name = "test-app"
charm {
name = "coredns"
base = "ubuntu@22.04"
channel = "1.25/stable"
}
}
```
`terraform apply`
`juju show-application test-app` -> check base ubuntu 22.04
Update plan
```terraform
resource "juju_application" "this" {
model = juju_model.this.name
name = "test-app"
charm {
name = "coredns"
base = "ubuntu@20.04"
channel = "1.25/stable"
}
}
```
`terraform plan` -> check that the plan doesn't require replace.
`terraform apply`
`juju show-application test-app` -> check base ubuntu 20.04
Copy file name to clipboardexpand all lines: docs/resources/application.md
+2-1
Original file line number
Diff line number
Diff line change
@@ -74,6 +74,7 @@ Notes:
74
74
### Read-Only
75
75
76
76
-`id` (String) The ID of this resource.
77
+
-`model_type` (String) The type of the model where the application is deployed. It is a computed field and is needed to determine if the application should be replaced or updated in case of base updates.
77
78
-`principal` (Boolean, Deprecated) Whether this is a Principal application
78
79
79
80
<aid="nestedblock--charm"></a>
@@ -85,7 +86,7 @@ Required:
85
86
86
87
Optional:
87
88
88
-
-`base` (String) The operating system on which to deploy. E.g. ubuntu@22.04.
89
+
-`base` (String) The operating system on which to deploy. E.g. ubuntu@22.04. Changing this value for machine charms will trigger a replace by terraform.
89
90
-`channel` (String) The channel to use when deploying a charm. Specified as \<track>/\<risk>/\<branch>.
90
91
-`revision` (Number) The revision of the charm to deploy. During the update phase, the charm revision should be update before config update, to avoid issues with config parameters parsing.
91
92
-`series` (String, Deprecated) The series on which to deploy.
DeprecationMessage: "Configure base instead. This attribute will be removed in the next major version of the provider.",
317
326
},
318
327
BaseKey: schema.StringAttribute{
319
-
Description: "The operating system on which to deploy. E.g. ubuntu@22.04.",
328
+
Description: "The operating system on which to deploy. E.g. ubuntu@22.04. Changing this value for machine charms will trigger a replace by terraform.",
0 commit comments