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 }