cmd/jujud: avoid potential race for UpgradedToVersion

Store the initial UpgradedToVersion as the the machine agent starts up
and use that when deciding whether HA initialisation is
required. Previously it could have been possible for the upgrade-steps
worker to update UpgradedToVersion before ensureMongoServer got to
check it.
cmd/jujud: update upgradedToVersion even when upgrade mode is skipped

Recent changes to avoid entering "upgrade mode" unnecessarily have
meant that the upgradedToVersion field in a machine agent's config
wasnt't getting updated whenever upgrade mode is skipped. This can
have a variety of negative effects.

This change fixes that by writing the current version to agent.conf
when upgrade mode is skipped.
Merge pull request #569 from mjs/1359484-write-upgradedToVersion-even-when-no-upgrade-1.20

Write upgraded to version even when no upgrade (v1.20)

This is the 1.20 backport of https://github.com/juju/juju/pull/566.

See also: https://bugs.launchpad.net/juju-core/+bug/1359484