lxd/cluster/upgrade.go
func maybeUpdate(state *state.State) {
	shouldUpdate := false

	enabled, err := Enabled(state.Node)
	if err != nil {
		logger.Errorf("Failed to check clustering is enabled: %v", err)
		return
	}
	if !enabled {
		return
	}

	err = state.Cluster.Transaction(func(tx *db.ClusterTx) error {
		outdated, err := tx.NodeIsOutdated()
		if err != nil {
			return err
		}
		shouldUpdate = outdated
		return nil
	})

	if err != nil {
		// Just log the error and return.
		logger.Errorf("Failed to check if this node is out-of-date: %v", err)
		return
	}

	if !shouldUpdate {
		logger.Debugf("Cluster node is up-to-date")
		return
	}

	logger.Infof("Node is out-of-date with respect to other cluster nodes")

	updateExecutable := os.Getenv("LXD_CLUSTER_UPDATE")
	if updateExecutable == "" {
		logger.Debug("No LXD_CLUSTER_UPDATE variable set, skipping auto-update")
		return
	}

	logger.Infof("Triggering cluster update using: %s", updateExecutable)

	_, err = shared.RunCommand(updateExecutable)
	if err != nil {
		logger.Errorf("Cluster upgrade failed: '%v'", err.Error())
		return
	}
}
func maybeUpdate(state *state.State) {
	shouldUpdate := false

	enabled, err := Enabled(state.Node)
	if err != nil {
		logger.Errorf("Failed to check clustering is enabled: %v", err)
		return
	}
	if !enabled {
		return
	}

	err = state.Cluster.Transaction(func(tx *db.ClusterTx) error {
		outdated, err := tx.NodeIsOutdated()
		if err != nil {
			return err
		}
		shouldUpdate = outdated
		return nil
	})

	if err != nil {
		// Just log the error and return.
		logger.Errorf("Failed to check if this node is out-of-date: %v", err)
		return
	}

	if !shouldUpdate {
		logger.Debugf("Cluster node is up-to-date")
		return
	}

	logger.Infof("Node is out-of-date with respect to other cluster nodes")

	updateExecutable := os.Getenv("LXD_CLUSTER_UPDATE")
	if updateExecutable == "" {
		logger.Debug("No LXD_CLUSTER_UPDATE variable set, skipping auto-update")
		return
	}

	logger.Infof("Triggering cluster update using: %s", updateExecutable)

	_, err = shared.RunCommand(updateExecutable)
	if err != nil {
		logger.Errorf("Cluster upgrade failed: '%v'", err.Error())
		return
	}
}
// Check this node's version and possibly run LXD_CLUSTER_UPDATE.