apache/hadoop · error · UnsupportedActionException
"Failed to set quota by storage type because either" + DFS_Q
Error message
"Failed to set quota by storage type because either" + DFS_QUOTA_BY_STORAGETYPE_ENABLED_KEY + " is set to " + fsd.isQuotaByStorageTypeEnabled() + " or nsQuota value is illegal " + nsQuota
What it means
unprotectedSetQuota with a non-null StorageType throws UnsupportedActionException when the NameNode has dfs.quota.by.storage.type.enabled=false, or when the call also carries a namespace quota (nsQuota != QUOTA_DONT_SET) - type quotas are a distinct operation. The message prints the config key with its current state and the offending nsQuota so you can tell which condition fired. The key defaults to true on current Hadoop, but older 2.7/2.8 clusters shipped false.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java:344
FSDirectory fsd, INodesInPath iip, long nsQuota,
long ssQuota, StorageType type)
throws FileNotFoundException, PathIsNotDirectoryException,
QuotaExceededException, UnresolvedLinkException,
SnapshotAccessControlException, UnsupportedActionException {
assert fsd.hasWriteLock();
// sanity check
if ((nsQuota < 0 && nsQuota != HdfsConstants.QUOTA_DONT_SET &&
nsQuota != HdfsConstants.QUOTA_RESET) ||
(ssQuota < 0 && ssQuota != HdfsConstants.QUOTA_DONT_SET &&
ssQuota != HdfsConstants.QUOTA_RESET)) {
throw new IllegalArgumentException("Illegal value for nsQuota or " +
"ssQuota : " + nsQuota + " and " +
ssQuota);
}
// sanity check for quota by storage type
if ((type != null) && (!fsd.isQuotaByStorageTypeEnabled() ||
nsQuota != HdfsConstants.QUOTA_DONT_SET)) {
throw new UnsupportedActionException(
"Failed to set quota by storage type because either" +
DFS_QUOTA_BY_STORAGETYPE_ENABLED_KEY + " is set to " +
fsd.isQuotaByStorageTypeEnabled() + " or nsQuota value is illegal " +
nsQuota);
}
INodeDirectory dirNode =
INodeDirectory.valueOf(iip.getLastINode(), iip.getPath());
final QuotaCounts oldQuota = dirNode.getQuotaCounts();
final long oldNsQuota = oldQuota.getNameSpace();
final long oldSsQuota = oldQuota.getStorageSpace();
if (dirNode.isRoot() && nsQuota == HdfsConstants.QUOTA_RESET) {
nsQuota = HdfsConstants.QUOTA_DONT_SET;
} else if (nsQuota == HdfsConstants.QUOTA_DONT_SET) {
nsQuota = oldNsQuota;
} // a directory inode
if (ssQuota == HdfsConstants.QUOTA_DONT_SET) {
ssQuota = oldSsQuota;View on GitHub (pinned to 2add963021)
Solutions
- Set dfs.quota.by.storage.type.enabled=true in the NameNode's hdfs-site.xml and restart the NameNode (the flag is read at FSDirectory initialization).
- When setting a type quota, pass HdfsConstants.QUOTA_DONT_SET for the namespace quota and set namespace quotas as a separate call.
- If the feature must stay disabled, enforce per-type limits outside HDFS or plan an upgrade.
Example fix
<!-- hdfs-site.xml on the NameNode, then restart NN --> <property> <name>dfs.quota.by.storage.type.enabled</name> <value>true</value> </property> // and set type quotas in a dedicated call: dfs.setQuotaByStorageType(path, StorageType.SSD, quota); // nsQuota stays DONT_SET internally
Defensive patterns
Strategy: validation
Validate before calling
boolean typeQuotaOn = fs.getConf().getBoolean(
DFSConfigKeys.DFS_QUOTA_BY_STORAGETYPE_ENABLED_KEY,
DFSConfigKeys.DFS_QUOTA_BY_STORAGETYPE_ENABLED_DEFAULT);
if (!typeQuotaOn) {
throw new IllegalStateException(
"Type quotas disabled on this cluster; enable dfs.quota.by.storage.type.enabled on the NameNode");
}
// set type quota in its own call so nsQuota stays QUOTA_DONT_SET
dfs.setQuotaByStorageType(path, StorageType.SSD, quota); Try / catch
try {
dfs.setQuotaByStorageType(path, type, quota);
} catch (UnsupportedActionException e) {
if (e.getMessage().contains("quota by storage type")) {
// config disabled on NN or nsQuota leaked into the call: fix config/call shape
}
} Prevention
- Client config must mirror the NameNode's flag; verify on the NN config page after restarts.
- Never bundle namespace quota values into type-quota calls.
When it happens
Trigger: 'hdfs dfsadmin -setSpaceQuota <q> -storageType <type> <dir>' or DistributedFileSystem.setQuotaByStorageType against an NN with the feature disabled; or an internal caller invoking the combined setQuota with both a type and a namespace quota.
Common situations: Older Hadoop 2.x clusters where the flag defaulted to false; hardened configs that disable it; custom quota tooling that passes one combined quota struct into the type-quota path.
Related errors
- Quota by storage type : type on path : pathName is exceeded.
- Storage type {} is not available. Available storage types ar
- Invalid values for quota :{}
- Invalid storage type(null)
- Don't support Quota for storage type : {}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/4458938991f6e980.
Report an issue: GitHub.