lxd/db/node.go
func (c *ClusterTx) NodeIsOutdated() (bool, error) {
	nodes, err := c.nodes(false /* not pending */, "")
	if err != nil {
		return false, errors.Wrap(err, "Failed to fetch nodes")
	}

	// Figure our own version.
	version := [2]int{}
	for _, node := range nodes {
		if node.ID == c.nodeID {
			version = node.Version()
		}
	}
	if version[0] == 0 || version[1] == 0 {
		return false, fmt.Errorf("Inconsistency: local node not found")
	}

	// Check if any of the other nodes is greater than us.
	for _, node := range nodes {
		if node.ID == c.nodeID {
			continue
		}
		n, err := util.CompareVersions(node.Version(), version)
		if err != nil {
			errors.Wrapf(err, "Failed to compare with version of node %s", node.Name)
		}

		if n == 1 {
			// The other node's version is greater than ours.
			return true, nil
		}
	}

	return false, nil
}
func (c *ClusterTx) NodeIsOutdated() (bool, error) {
	nodes, err := c.nodes(false /* not pending */, "")
	if err != nil {
		return false, errors.Wrap(err, "Failed to fetch nodes")
	}

	// Figure our own version.
	version := [2]int{}
	for _, node := range nodes {
		if node.ID == c.nodeID {
			version = node.Version()
		}
	}
	if version[0] == 0 || version[1] == 0 {
		return false, fmt.Errorf("Inconsistency: local node not found")
	}

	// Check if any of the other nodes is greater than us.
	for _, node := range nodes {
		if node.ID == c.nodeID {
			continue
		}
		n, err := util.CompareVersions(node.Version(), version)
		if err != nil {
			errors.Wrapf(err, "Failed to compare with version of node %s", node.Name)
		}

		if n == 1 {
			// The other node's version is greater than ours.
			return true, nil
		}
	}

	return false, nil
}
func ( c * ClusterTx ) NodeIsOutdated ( ) ( bool , error ) { nodes , err := c . nodes ( false /* not pending */ , " " ) if err != nil { return false , errors . Wrap ( err , " " ) } // Figure our own version. version := [ 2 ] int { } for _ , node := range nodes { if node . ID == c . nodeID { version = node . Version ( ) } } if version [ 0 ] == 0 || version [ 1 ] == 0 { return false , fmt . Errorf ( " " ) } // Check if any of the other nodes is greater than us. for _ , node := range nodes { if node . ID == c . nodeID { continue } n , err := util . CompareVersions ( node . Version ( ) , version ) if err != nil { errors . Wrapf ( err , " " , node . Name ) } if n == 1 { // The other node's version is greater than ours. return true , nil } } return false , nil }
// NodeIsOutdated returns true if there's some cluster node having an API or
// schema version greater than the node this method is invoked on.
NodeIsOutdated returns true if there s some cluster node having an API or schema version greater than the node this method is invoked on .