1482
|
|
|
Roger Peppe |
11 years ago
|
|
|
1481
|
|
|
jtv at canonical |
11 years ago
|
|
|
1480
|
|
[r=jameinel],[bug=1199915] cmd/jujud: Ensure valid agent.conf after upgrade
This fixes the agent.conf files for the machine and unit agents after upgrading from 1.10 to 1.11. I ran into a few differences, the basics are:
1) Machine Agent: machine 0 always starts the state worker, when upgrading it has an APIInfo section, but it 1a) Didn't have Machine.SetPassword in the DB set so we didn't have a way to connect via the api 1b) Didn't have a password set in apiinfo, and 1.10 had already changed the password after connecting to the MongoDB 1c) Had changed their password already
So to solve this one, we grab the Password from StateInfo.Password, call Agent.SetPassword(), and set the value in APIInfo.Password.
2) Machine Agent: machine != 0. Were only connecting to the state after connecting to the API. Because of (1a,b) they couldn't connect to notice that they had work to do.
So on top of what we did for (1), I added a step of:
2a) If we are unable to connect to the API, call ensureStateWorker(). This gives us an opportunity to set our API password and save it in agent.conf.
3) Unit agents:
3a) Didn't even have an APIInfo section. 3b) Did have a Mongo password, and had reset their Mongo Password
So we copy the state info into the api info section, and change the port. I only use the default port (17070). I think it would be possible to query something in state for what the official API is (state.State.Environ().APIInfo() comes to mind, but I'm not sure what the correct value is.)
I felt that changing the port would solve all current 1.10 users, and if we change things in the future, we can change the code. (I also just discovered that we have Conf.APIPort which may or may not be set in all the various permutations, I don't have the energy to track down 3 different versions now.)
4) Unit agents bootstrapped with 1.11.2 tools
4a) Would have a valid APIInfo section 4b) But would not have StateInfo.Password or APIInfo.Password set. This is because changing the Password now occurs when we connect to the API, not when we first connect to the Mongo DB.
I added checks for this, to make sure that 1.11.3 doesn't cause us to call Unit.SetPassword("").
I did a few upgrades from 1.10 => this code, and 1.11.2 => this code, and straight bootstrapping from this code. It all seems to be up and running. I don't think I tried bootstrapping 1.10 with this code and upgrading.
I hopefully captured all of these config edge cases in the test suite, so we don't have to test all the permutations manually in the future. We also need to think very carefully when we add stuff about how we will get upgrade to notice. I'm starting to think we want to tweak how upgrade works. So instead of just replacing the tools, it has a "juju upgraded" or some other command that runs the first time you are upgraded so we can put logic into that place and have it centralized.
https://codereview.appspot.com/11137044/
|
John Arbash Meinel |
11 years ago
|
|
|
1479
|
|
|
Martin Packman |
11 years ago
|
|
|
1478
|
|
|
Dimiter Naydenov |
11 years ago
|
|
|
1477
|
|
|
jtv at canonical |
11 years ago
|
|
|
1476
|
|
|
Tim Penhey |
11 years ago
|
|
|
1475
|
|
|
Gavin Panella |
11 years ago
|
|
|
1474
|
|
|
Tim Penhey |
11 years ago
|
|
|
1473
|
|
|
Tim Penhey |
11 years ago
|
|
|
1472
|
|
|
Tim Penhey |
11 years ago
|
|
|
1471
|
|
|
Tim Penhey |
11 years ago
|
|
|
1470
|
|
|
Ian Booth |
11 years ago
|
|
|
1469
|
|
|
Tim Penhey |
11 years ago
|
|
|
1468
|
|
|
Ian Booth |
11 years ago
|
|
|
1467
|
|
|
Ian Booth |
11 years ago
|
|
|
1466
|
|
|
Tim Penhey |
11 years ago
|
|
|
1465
|
|
|
Tim Penhey |
11 years ago
|
|
|
1464
|
|
|
jtv at canonical |
11 years ago
|
|
|
1463
|
|
|
jtv at canonical |
11 years ago
|
|
|