Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4575)

Issue 11137044: cmd/jujud: Ensure valid agent.conf after upgrade

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 9 months ago by jameinel
Modified:
10 years, 9 months ago
Reviewers:
mue, mp+174620, fwereade
Visibility:
Public.

Description

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://code.launchpad.net/~jameinel/juju-core/api-set-creds-1199915/+merge/174620 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 18

Patch Set 2 : cmd/jujud: Ensure valid agent.conf after upgrade #

Patch Set 3 : cmd/jujud: Ensure valid agent.conf after upgrade #

Unified diffs Side-by-side diffs Delta from patch set Stats (+476 lines, -22 lines) Patch
A [revision details] View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M cmd/jujud/machine.go View 1 2 3 chunks +17 lines, -0 lines 0 comments Download
M cmd/jujud/machine_test.go View 1 chunk +1 line, -1 line 0 comments Download
M cmd/jujud/unit.go View 1 2 3 chunks +12 lines, -1 line 0 comments Download
M cmd/jujud/unit_test.go View 3 chunks +11 lines, -8 lines 0 comments Download
M cmd/jujud/upgradevalidation.go View 1 2 2 chunks +86 lines, -0 lines 0 comments Download
A cmd/jujud/upgradevalidation_test.go View 1 2 1 chunk +335 lines, -0 lines 0 comments Download
M state/apiserver/common/remove_test.go View 1 2 2 chunks +10 lines, -10 lines 0 comments Download
M state/apiserver/deployer/deployer_test.go View 1 2 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 8
jameinel
Please take a look.
10 years, 9 months ago (2013-07-14 16:05:50 UTC) #1
mue
LGTM, only few remarks. https://codereview.appspot.com/11137044/diff/1/cmd/jujud/upgradevalidation.go File cmd/jujud/upgradevalidation.go (right): https://codereview.appspot.com/11137044/diff/1/cmd/jujud/upgradevalidation.go#newcode91 cmd/jujud/upgradevalidation.go:91: //??? We should at least ...
10 years, 9 months ago (2013-07-15 13:31:42 UTC) #2
fwereade
Looking very nice, thanks for this; I have a couple of questions. https://codereview.appspot.com/11137044/diff/1/cmd/jujud/machine.go File cmd/jujud/machine.go ...
10 years, 9 months ago (2013-07-15 13:53:51 UTC) #3
jameinel
https://codereview.appspot.com/11137044/diff/1/cmd/jujud/upgradevalidation.go File cmd/jujud/upgradevalidation.go (right): https://codereview.appspot.com/11137044/diff/1/cmd/jujud/upgradevalidation.go#newcode165 cmd/jujud/upgradevalidation.go:165: if err := setter.SetPassword(password); err != nil { On ...
10 years, 9 months ago (2013-07-15 13:57:52 UTC) #4
jameinel
Please take a look. https://codereview.appspot.com/11137044/diff/1/cmd/jujud/machine.go File cmd/jujud/machine.go (right): https://codereview.appspot.com/11137044/diff/1/cmd/jujud/machine.go#newcode145 cmd/jujud/machine.go:145: // TODO: Once we can ...
10 years, 9 months ago (2013-07-16 07:41:09 UTC) #5
fwereade
LGTM, but please do a little bit of investigation to see if there's a reaosnably ...
10 years, 9 months ago (2013-07-16 12:52:16 UTC) #6
jameinel
Please take a look.
10 years, 9 months ago (2013-07-16 13:42:49 UTC) #7
jameinel
10 years, 9 months ago (2013-07-17 06:15:10 UTC) #8
On 2013/07/16 13:42:49, jameinel wrote:
> Please take a look.

I did end up doing state.APIAddresses.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b