예제 #1
0
func (c *Cluster) removeImage(name string, waitForAll bool) error {
	err := c.removeFromRegistry(name)
	if err != nil {
		return err
	}
	hosts, err := c.storage().RetrieveImage(name)
	if err != nil {
		return err
	}
	_, err = c.runOnNodes(func(n node) (interface{}, error) {
		return nil, n.RemoveImage(name)
	}, docker.ErrNoSuchImage, waitForAll, hosts...)
	if err != nil && err != docker.ErrNoSuchImage {
		log.Debugf("Ignored error removing image from nodes: %s", err.Error())
	}
	return c.storage().RemoveImage(name)
}
예제 #2
0
// CommitContainer commits a container and returns the image id.
func (c *Cluster) CommitContainer(opts docker.CommitContainerOptions) (*docker.Image, error) {
	if opts.Repository != "" {
		err := c.RemoveImageWait(opts.Repository)
		if err != nil {
			log.Debugf("Ignored error removing container %q on commit: %s", opts.Repository, err.Error())
		}
	}
	node, err := c.getNodeForContainer(opts.Container)
	if err != nil {
		return nil, err
	}
	image, err := node.CommitContainer(opts)
	if err != nil {
		return nil, err
	}
	key := opts.Repository
	if key == "" {
		key = image.ID
	}
	return image, c.storage().StoreImage(key, node.addr)
}
예제 #3
0
func (c *Cluster) runActiveMonitoring(updateInterval time.Duration) {
	log.Debugf("[active-monitoring]: active monitoring enabled, pinging hosts every %d seconds", updateInterval/time.Second)
	for {
		var nodes []Node
		var err error
		nodes, err = c.UnfilteredNodes()
		if err != nil {
			log.Errorf("[active-monitoring]: error in UnfilteredNodes: %s", err.Error())
		}
		wg := sync.WaitGroup{}
		for _, node := range nodes {
			wg.Add(1)
			go c.runPingForHost(node.Address, &wg)
		}
		wg.Wait()
		select {
		case <-c.monitoringDone:
			return
		case <-time.After(updateInterval):
		}
	}
}