Docker Swarm Code Analysis Note (+)--node structure

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Docker Swarmschedulerwill choose to meet the requirements node to create container :

candidates, err := s.selectNodesForContainer(nodes, config, true)

nodeDefined in scheduler/node/node.go :

// Node is an abstract type used by the scheduler.type Node struct {    ID         string    IP         string    Addr       string    Name       string    Labels     map[string]string    Containers cluster.Containers    Images     []*cluster.Image    UsedMemory  int64    UsedCpus    int64    TotalMemory int64    TotalCpus   int64    HealthIndicator int64}

Cluster.listNodesThe method is implemented as follows:

// listNodes returns all validated engines in the cluster, excluding pendingEngines.func (c *Cluster) listNodes() []*node.Node {    c.RLock()    defer c.RUnlock()    out := make([]*node.Node, 0, len(c.engines))    for _, e := range c.engines {        node := node.NewNode(e)        for _, pc := range c.pendingContainers {            if pc.Engine.ID == e.ID && node.Container(pc.Config.SwarmID()) == nil {                node.AddContainer(pc.ToContainer())            }        }        out = append(out, node)    }    return out}

is actually from the Cluster.engines build node list (because it's still in a Cluster.pendingEngines pending state). The following scheduler will node select the appropriate one from this list node .

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.