Revision c69b147d

b/lib/cmdlib/cluster.py
1900 1900
             utils.CommaJoin(inst_config.secondary_nodes),
1901 1901
             code=self.ETYPE_WARNING)
1902 1902

  
1903
    if inst_config.disk_template not in constants.DTS_EXCL_STORAGE:
1904
      # Disk template not compatible with exclusive_storage: no instance
1905
      # node should have the flag set
1906
      es_flags = rpc.GetExclusiveStorageForNodeNames(self.cfg,
1907
                                                     inst_config.all_nodes)
1908
      es_nodes = [n for (n, es) in es_flags.items()
1909
                  if es]
1910
      _ErrorIf(es_nodes, constants.CV_EINSTANCEUNSUITABLENODE, instance,
1911
               "instance has template %s, which is not supported on nodes"
1912
               " that have exclusive storage set: %s",
1913
               inst_config.disk_template, utils.CommaJoin(es_nodes))
1903
    es_flags = rpc.GetExclusiveStorageForNodeNames(self.cfg,
1904
                                                   inst_config.all_nodes)
1905
    if any(es_flags.values()):
1906
      if inst_config.disk_template not in constants.DTS_EXCL_STORAGE:
1907
        # Disk template not compatible with exclusive_storage: no instance
1908
        # node should have the flag set
1909
        es_nodes = [n
1910
                    for (n, es) in es_flags.items()
1911
                    if es]
1912
        self._Error(constants.CV_EINSTANCEUNSUITABLENODE, instance,
1913
                    "instance has template %s, which is not supported on nodes"
1914
                    " that have exclusive storage set: %s",
1915
                    inst_config.disk_template, utils.CommaJoin(es_nodes))
1916
      for (idx, disk) in enumerate(inst_config.disks):
1917
        _ErrorIf(disk.spindles is None,
1918
                 constants.CV_EINSTANCEMISSINGCFGPARAMETER, instance,
1919
                 "number of spindles not configured for disk %s while"
1920
                 " exclusive storage is enabled, try running"
1921
                 " gnt-cluster repair-disk-sizes",
1922
                 idx)
1914 1923

  
1915 1924
    if inst_config.disk_template in constants.DTS_INT_MIRROR:
1916 1925
      instance_nodes = utils.NiceSort(inst_config.all_nodes)
b/lib/constants.py
1589 1589
CV_EINSTANCEUNSUITABLENODE = \
1590 1590
  (CV_TINSTANCE, "EINSTANCEUNSUITABLENODE",
1591 1591
   "Instance running on nodes that are not suitable for it")
1592
CV_EINSTANCEMISSINGCFGPARAMETER = \
1593
  (CV_TINSTANCE, "EINSTANCEMISSINGCFGPARAMETER",
1594
   "A configuration parameter for an instance is missing")
1592 1595
CV_ENODEDRBD = \
1593 1596
  (CV_TNODE, "ENODEDRBD", "Error parsing the DRBD status file")
1594 1597
CV_ENODEDRBDVERSION = \
b/tools/cfgupgrade
155 155
      UpgradeIPolicy(ipolicy, cl_ipolicy, True)
156 156

  
157 157

  
158
def GetExclusiveStorageValue(config_data):
159
  """Return a conservative value of the exclusive_storage flag.
160

  
161
  Return C{True} if the cluster or at least a nodegroup have the flag set.
162

  
163
  """
164
  ret = False
165
  cluster = config_data["cluster"]
166
  ndparams = cluster.get("ndparams")
167
  if ndparams is not None and ndparams.get("exclusive_storage"):
168
    ret = True
169
  for group in config_data["nodegroups"].values():
170
    ndparams = group.get("ndparams")
171
    if ndparams is not None and ndparams.get("exclusive_storage"):
172
      ret = True
173
  return ret
174

  
175

  
158 176
def UpgradeInstances(config_data):
159 177
  network2uuid = dict((n["name"], n["uuid"])
160 178
                      for n in config_data["networks"].values())
161 179
  if "instances" not in config_data:
162 180
    raise Error("Can't find the 'instances' key in the configuration!")
163 181

  
182
  missing_spindles = False
164 183
  for instance, iobj in config_data["instances"].items():
165 184
    for nic in iobj["nics"]:
166 185
      name = nic.get("network", None)
......
182 201
                        " from '%s' to '%s'",
183 202
                        instance, idx, current, expected)
184 203
        dobj["iv_name"] = expected
204
      if not "spindles" in dobj:
205
        missing_spindles = True
206

  
207
  if GetExclusiveStorageValue(config_data) and missing_spindles:
208
    # We cannot be sure that the instances that are missing spindles have
209
    # exclusive storage enabled (the check would be more complicated), so we
210
    # give a noncommittal message
211
    logging.warning("Some instance disks could be needing to update the"
212
                    " spindles parameter; you can check by running"
213
                    " 'gnt-cluster verify', and fix any problem with"
214
                    " 'gnt-cluster repair-disk-sizes'")
185 215

  
186 216

  
187 217
def UpgradeRapiUsers():

Also available in: Unified diff