Description of change
The upgrade step to add "container-image-series" to model config was accidentally adding it to all settings documents, including application config. We only noticed because some charm documents have "." in their keys so we have to encode/decode the keys to map it to keys that Mongo will accept.
This changes it so that we only touch the model documents. It also refactors the upgrade steps that touch model documents so all the steps that find the model docs are shared, and just the modification of the docs is unique code.
QA steps
You can see the reproduction steps in the bug but:
$ juju bootstrap lxd --agent-version=2.3.5
$ juju switch controller
$ juju deploy --to 0 percona-cluster
$ juju run --unit percona-cluster/0 leader-get
# see that it has mysql.password in it
$ juju upgrade-juju --build-agent
$ juju status
With the existing 2.3.6 release, it will be stuck in an upgrade loop because the upgrade step will be trying to rewrite documents incorrectly.
As a further test, you could deploy any other change, and upgrading to 2.3.6 would show that
> db.settings.find().pretty()
Would have added "container-image-stream": "released" to the settings. Then upgrading to 2.3.7 should show that value being removed. A test for that would be:
$ juju bootstrap --agent-version=2.3.5
$ juju switch controller
$ juju deploy cs:~jameinel/ubuntu-lite --to 0
$ juju upgrade-juju --agent-version=2.3.6
> db.settings.find().pretty()
# will include something like:
{
"_id" : "c96ad806-372e-4c1c-83b0-f3ef1b2bdb8b:a#ubuntu-lite#cs:~jameinel/ubuntu-lite-7",
"model-uuid" : "c96ad806-372e-4c1c-83b0-f3ef1b2bdb8b",
"settings" : {
"container-image-stream" : "released"
},
"version" : NumberLong(0),
"txn-revno" : NumberLong(4),
"txn-queue" : [
"5adc977cf96e93066e4ebf33_38c97e68"
]
}
# this should upgrade happily, albeit slightly incorrectly
$ juju upgrade-juju --build-agent
> db.settings.find().pretty()
# new value:
{
"_id" : "c96ad806-372e-4c1c-83b0-f3ef1b2bdb8b:a#ubuntu-lite#cs:~jameinel/ubuntu-lite-7",
"model-uuid" : "c96ad806-372e-4c1c-83b0-f3ef1b2bdb8b",
"settings" : {
},
"version" : NumberLong(0),
"txn-revno" : NumberLong(5),
"txn-queue" : [
"5adc9a15f96e9309c6ce4ec6_46cc5b83"
]
}
Note that this doesn't work with 'lxd' because it has:
{
"_id" : "c96ad806-372e-4c1c-83b0-f3ef1b2bdb8b:pool#lxd-zfs",
"model-uuid" : "c96ad806-372e-4c1c-83b0-f3ef1b2bdb8b",
"settings" : {
"type" : "lxd",
"driver" : "zfs",
"lxd-pool" : "juju-zfs",
"zfs.pool_name" : "juju-lxd",
"name" : "lxd-zfs"
},
"version" : NumberLong(0),
"txn-revno" : NumberLong(2),
"txn-queue" : [
"5adc9566f96e93037cb50555_26c7bcb5",
"5adc95cbf96e930546fb0af9_dfa5c61c",
"5adc9643f96e930546fb0b02_834567ce"
]
}
Documentation changes
None.
Bug reference
该提问来源于开源项目:juju/juju