Skip to content

Commit

Permalink
Merge pull request juju#13056 from wallyworld/deploy-bundle-diff
Browse files Browse the repository at this point in the history
juju#13056

When deploying over the top of an existing model a bundle that contains charm config values set to the charm default, juju would claim that config had changed when it hadn't. Any default charm values were being removed from the model representation to compare, instead of unset values.

## QA steps

juju deploy a simple bundle with a config option set to the charm default
```
applications:
 mariadb:
 charm: cs:mariadb
 num_units: 1
 options:
 dataset-size: 50%
```
`juju export-bundle --filename foo.yaml`
`juju deploy ./foo.yaml --verbose --dry-run --map-machines existing`

There should be no changes printed.

## Bug reference

https://bugs.launchpad.net/juju/+bug/1929908
  • Loading branch information
jujubot committed Jun 8, 2021
2 parents 80e3cad + 5fec5a9 commit 5e99fae
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/juju/application/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ func applicationConfigValue(key string, valueMap interface{}) (interface{}, erro
if !found {
return nil, errors.Errorf("missing application config value 'source' for key %q", key)
}
if source != "user" {
if source == "unset" {
return nil, nil
}
value, found := vm["value"]
Expand Down
7 changes: 4 additions & 3 deletions state/allwatcher_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,10 @@ func (s *allWatcherBaseSuite) setUpScenario(c *gc.C, st *State, units int) (enti
})

add(&multiwatcher.CharmInfo{
ModelUUID: modelUUID,
CharmURL: applicationCharmURL(mysql).String(),
Life: life.Alive,
ModelUUID: modelUUID,
CharmURL: applicationCharmURL(mysql).String(),
Life: life.Alive,
DefaultConfig: map[string]interface{}{"dataset-size": "80%"},
})

// Set up a remote application related to the offer.
Expand Down
5 changes: 5 additions & 0 deletions testcharms/charm-repo/bionic/mysql/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
options:
dataset-size:
default: '80%'
description: How much data do you want to keep in memory in the DB.
type: string
2 changes: 2 additions & 0 deletions testcharms/charm-repo/bundle/wordpress-simple/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ services:
mysql:
charm: mysql
num_units: 1
options:
dataset-size: 80%
relations:
- ["wordpress:db", "mysql:server"]
5 changes: 5 additions & 0 deletions testcharms/charm-repo/quantal/mysql/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
options:
dataset-size:
default: '80%'
description: How much data do you want to keep in memory in the DB.
type: string

0 comments on commit 5e99fae

Please sign in to comment.