apache/hadoop · error · NotInMountpointException

getStoragePolicy on path `{}' is not within a mount point

Error message

getStoragePolicy on path `{}' is not within a mount point

What it means

ViewFileSystem.getStoragePolicy throws NotInMountpointException from InternalDirOfViewFs when the path resolves to an internal (virtual) mount-table directory. Storage policies are a property of the backing HDFS cluster, so the overlay cannot answer for a node with no child FileSystem. The exception is unchecked.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java:1912

      throw readOnlyMountTable("satisfyStoragePolicy", src);
    }

    @Override
    public void setStoragePolicy(Path src, String policyName)
        throws IOException {
      checkPathIsSlash(src);
      throw readOnlyMountTable("setStoragePolicy", src);
    }

    @Override
    public void unsetStoragePolicy(Path src) throws IOException {
      checkPathIsSlash(src);
      throw readOnlyMountTable("unsetStoragePolicy", src);
    }

    @Override
    public BlockStoragePolicySpi getStoragePolicy(Path src) throws IOException {
      throw new NotInMountpointException(src, "getStoragePolicy");
    }

    @Override
    public Collection<? extends BlockStoragePolicySpi> getAllStoragePolicies()
        throws IOException {
      Collection<BlockStoragePolicySpi> allPolicies = new HashSet<>();
      for (FileSystem fs : getChildFileSystems()) {
        try {
          Collection<? extends BlockStoragePolicySpi> policies =
              fs.getAllStoragePolicies();
          allPolicies.addAll(policies);
        } catch (UnsupportedOperationException e) {
          // ignored
        }
      }
      return allPolicies;
    }

View on GitHub (pinned to 2add963021)

Solutions

  1. Run getStoragePolicy on a concrete mounted path (e.g. viewfs:///data/ds1/file)
  2. Add a mount link for the prefix, or configure linkMergeSlash/linkFallback for root coverage
  3. Catch NotInMountpointException and surface 'no policy: not a mounted path' to the CLI user

Example fix

// before
BlockStoragePolicySpi pol = vfs.getStoragePolicy(new Path("/"));

// after
BlockStoragePolicySpi pol;
try {
  pol = vfs.getStoragePolicy(p);
} catch (NotInMountpointException e) {
  pol = null; // virtual dir: policy lives on the backing cluster
}
Defensive patterns

Strategy: try-catch

Validate before calling

static boolean storagePolicyQueryable(ViewFileSystem vfs, Path p) {
  String s = p.toUri().getPath();
  return vfs.getMountPoints().stream()
      .map(mp -> mp.getMountedOnPath().toUri().getPath())
      .anyMatch(m -> s.equals(m) || s.startsWith(m + "/"));
}

Try / catch

try {
  policy = vfs.getStoragePolicy(p);
} catch (NotInMountpointException e) {
  policy = null; // ask the backing HDFS cluster directly instead
}

Prevention

When it happens

Trigger: `hdfs storagepolicies -getStoragePolicy -path viewfs:///...` where the path is / or an unmounted ancestor; fs.getStoragePolicy(new Path("/")) on a viewfs FileSystem; storage-policy audit scripts walking a federated namespace.

Common situations: Operators running storage-policy tooling after switching the defaultFS to viewfs:// (federation); scripts written against plain HDFS URIs reused unchanged on viewfs; mount tables that only mount leaf dirs.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/ea0729dcfc5b0cb8. Report an issue: GitHub.