コード例 #1
0
ファイル: cluster.go プロジェクト: akerbis/armhf-swarm
// StartContainer start a container
func (c *Cluster) StartContainer(container *cluster.Container) error {
	c.RLock()
	defer c.RUnlock()

	if err := container.Engine.StartContainer(container, nil); err != nil {
		return err
	}
	_, err := container.Refresh()
	return err
}
コード例 #2
0
ファイル: cluster.go プロジェクト: akerbis/armhf-swarm
// StartContainer start a container
func (c *Cluster) StartContainer(container *cluster.Container) error {
	c.RLock()
	defer c.RUnlock()

	if container, _ := container.Refresh(); container != nil {
		// As mesos garbage collect containers, we only allow starting on a "Created" containers
		if container.Info.State.Running == false && container.Info.State.FinishedAt.IsZero() {
			if err := container.Engine.StartContainer(container, nil); err != nil {
				_, err = container.Refresh()
				return err
			}
		}
	}
	return nil
}
コード例 #3
0
ファイル: cluster.go プロジェクト: denverdino/swarm-1
func formatContainer(container *cluster.Container) *cluster.Container {
	if container == nil {
		return nil
	}
	if name := container.Config.Labels[cluster.SwarmLabelNamespace+".mesos.name"]; name != "" && container.Names[0] != "/"+name {
		container.Names = append([]string{"/" + name}, container.Names...)
	}
	return container
}
コード例 #4
0
ファイル: node.go プロジェクト: marsmensch/swarm
func (n *node) updateContainer(c dockerclient.Container, containers map[string]*cluster.Container, full bool) (map[string]*cluster.Container, error) {
	var container *cluster.Container

	n.Lock()

	if current, exists := n.containers[c.Id]; exists {
		// The container is already known.
		container = current
	} else {
		// This is a brand new container. We need to do a full refresh.
		container = &cluster.Container{
			Node: n,
		}
		full = true
	}

	// Update its internal state.
	container.Container = c
	containers[container.Id] = container

	// Release the lock here as the next step is slow.
	n.Unlock()

	// Update ContainerInfo.
	if full {
		info, err := n.client.InspectContainer(c.Id)
		if err != nil {
			return nil, err
		}
		container.Info = *info
		// real CpuShares -> nb of CPUs
		container.Info.Config.CpuShares = container.Info.Config.CpuShares / 100.0 * n.Cpus
	}

	return containers, nil
}
コード例 #5
0
ファイル: scheduler.go プロジェクト: abhishekamralkar/swarm
// Remove a container from the cluster. Containers should always be destroyed
// through the scheduler to guarantee atomicity.
func (s *Scheduler) RemoveContainer(container *cluster.Container, force bool) error {
	s.Lock()
	defer s.Unlock()

	return container.Node().Destroy(container, force)
}