Docker Swarm manage
命令的scheduler
是通过filter和strategy构建的(cli/manage.go
):
sched := scheduler.New(s, fs)
而scheduler
实际的功能就是选择符合cluster.ContainerConfig
要求的node
(Docker Engine
)列表:
// SelectNodesForContainer will return a list of nodes where the container can
// be scheduled, sorted by order or preference.
func (s *Scheduler) SelectNodesForContainer(nodes []*node.Node, config *cluster.ContainerConfig) ([]*node.Node, error) {
candidates, err := s.selectNodesForContainer(nodes, config, true)
if err != nil {
candidates, err = s.selectNodesForContainer(nodes, config, false)
}
return candidates, err
}
func (s *Scheduler) selectNodesForContainer(nodes []*node.Node, config *cluster.ContainerConfig, soft bool) ([]*node.Node, error) {
accepted, err := filter.ApplyFilters(s.filters, config, nodes, soft)
if err != nil {
return nil, err
}
if len(accepted) == 0 {
return nil, errNoNodeAvailable
}
return s.strategy.RankAndSort(config, accepted)
}
有疑问加站长微信联系(非本文作者)