// Handle is called whenever containers change on the machine being watched. // Machines start out with no containers so the first time Handle is called, // it will be because a container has been added. func (cs *ContainerSetup) Handle(containerIds []string) (resultError error) { // Consume the initial watcher event. if len(containerIds) == 0 { return nil } logger.Tracef("initial container setup with ids: %v", containerIds) for _, id := range containerIds { containerType := state.ContainerTypeFromId(id) // If this container type has been dealt with, do nothing. if atomic.LoadInt32(cs.setupDone[containerType]) != 0 { continue } if err := cs.initialiseAndStartProvisioner(containerType); err != nil { logger.Errorf("starting container provisioner for %v: %v", containerType, err) // Just because dealing with one type of container fails, we won't exit the entire // function because we still want to try and start other container types. So we // take note of and return the first such error. if resultError == nil { resultError = err } } } return resultError }
func (s *AssignSuite) assertAssignUnitToNewMachineContainerConstraint(c *gc.C) { unit, err := s.wordpress.AddUnit() c.Assert(err, gc.IsNil) err = unit.AssignToNewMachine() c.Assert(err, gc.IsNil) machineId := s.assertAssignedUnit(c, unit) c.Assert(state.ParentId(machineId), gc.Not(gc.Equals), "") c.Assert(state.ContainerTypeFromId(machineId), gc.Equals, instance.LXC) }