示例#1
0
文件: unit.go 项目: makyo/juju
// runUpgrades is a temporary fix to deal with upgrade steps that need
// to be run for each unit. This function cannot fail. Errors in the
// upgrade steps are logged, but the uniter will attempt to continue.
// Worst case, we are no worse off than we are today, best case, things
// actually work properly. Only simple upgrade steps that don't use the API
// are available now. If we need really complex steps using the API, there
// should be significant steps to unify the agents first.
func runUpgrades(tag names.Tag, dataDir string) {
	unitTag, ok := tag.(names.UnitTag)
	if !ok {
		logger.Errorf("unit agent tag not a unit tag: %v", tag)
		return
	}
	if err := uniter.AddStoppedFieldToUniterState(unitTag, dataDir); err != nil {
		logger.Errorf("Upgrade step failed - add Stopped field to uniter state: %v", err)
	}
	if err := uniter.AddInstalledToUniterState(unitTag, dataDir); err != nil {
		logger.Errorf("Upgrade step failed - installed boolean needs to be set in the uniter local state: %v", err)
	}
}
示例#2
0
// stepsFor123 returns upgrade steps for Juju 1.23 that only need the API.
func stepsFor123() []Step {
	return []Step{
		&upgradeStep{
			description: "add environment UUID to agent config",
			targets:     []Target{AllMachines},
			run:         addEnvironmentUUIDToAgentConfig,
		},
		&upgradeStep{
			description: "add Stopped field to uniter state",
			targets:     []Target{AllMachines},
			run: func(context Context) error {
				config := context.AgentConfig()
				tag, ok := config.Tag().(names.UnitTag)
				if !ok {
					// not a Unit; skipping
					return nil
				}
				return uniter.AddStoppedFieldToUniterState(tag, config.DataDir())
			},
		},
	}
}
示例#3
0
func (s *upgradeStateContextSuite) confirmUpgradeNoErrors(c *gc.C) {
	err := uniter.AddStoppedFieldToUniterState(s.unitTag, s.datadir)
	c.Assert(err, jc.ErrorIsNil)
}