[ 
https://issues.apache.org/jira/browse/HDFS-4205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13509887#comment-13509887
 ] 

Nikolai Grigoriev commented on HDFS-4205:
-----------------------------------------

It seems to me that the symlink support is completely broken - at least in 
2.0.0-cdh4.0.0 version I am using. I can create the symlinks using 
FileContext.createSymlink() but this is all. After that any attempt to access 
that symlink result in UnresolvedPathException for the path that is perfectly 
valid. Tried all forms of path, absolute, with complete URI  - nothing seems to 
work. And this symlink cannot be removed using the DFS tools like Andy said 
before.

Also the FileStatus returned for that symlink returns false when calling its 
isSymlink() method. This simple test does not work for me.

{code}
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.fs.permission.FsPermission;

public class HDFSSymlink {
  public static void main(String[] args) throws IOException {
    HdfsConfiguration dfsConfig = new HdfsConfiguration();
    
    Path dir = new Path("/nikolai");
    
    Path target = new Path(dir, "file.txt");
    System.out.println("Target: " + target.toUri());

    Path link = new Path(dir, "link_to_file.txt");
    System.out.println("Link: " + link.toUri());
    
    FileContext fc = FileContext.getFileContext(dfsConfig);

    fc.mkdir(dir, FsPermission.getDefault(), false);

    FSDataOutputStream out = fc.create(target, EnumSet.of(CreateFlag.CREATE));
    out.writeUTF("Hello there");
    out.flush();
    out.close();

    fc.createSymlink(target, link, false);
    
    FileStatus stat = fc.getFileStatus(link);
    System.out.println("Is symlink? " + stat.isSymlink());
    
    if (stat.isSymlink()) {
      Path p = fc.resolvePath(link);
      System.out.println("Pointing to: " + p);
    } 
  }
}
{code}

After running it I do see: 

{code}
$ hadoop fs -ls  /nikolai/
Found 2 items
-rw-r--r--   3 root hadoop         13 2012-12-04 17:31 /nikolai/file.txt
-rwxrwxrwx   0 root hadoop          0 2012-12-04 17:31 /nikolai/link_to_file.txt
{code}


But that "link_to_file.txt" does not really work as symlink and I cannot even 
remove it without removing the parent directory.
                
> fsck fails with symlinks
> ------------------------
>
>                 Key: HDFS-4205
>                 URL: https://issues.apache.org/jira/browse/HDFS-4205
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: hdfs-client
>    Affects Versions: 3.0.0, 2.0.2-alpha
>            Reporter: Andy Isaacson
>
> I created a symlink using
> {code}
> ...
>     FileContext fc = FileContext.getFileContext(dst.fs.getUri());
>     for (PathData src : srcs) {
>       fc.createSymlink(src.path, dst.path, false);
>     }
> {code}
> After doing this to create a symlink {{/foo/too.txt -> /foo/hello.txt}}, I 
> tried to {{hdfs fsck}} and got the following:
> {code}
> [adi@host01 ~]$ hdfs fsck /
> Connecting to namenode via http://host01:21070
> FSCK started by adi (auth:SIMPLE) from /172.29.122.91 for path / at Fri Nov 
> 16 15:59:18 PST 2012
> FSCK ended at Fri Nov 16 15:59:18 PST 2012 in 3 milliseconds
> hdfs://host01:21020/foo/hello.txt
> Fsck on path '/' FAILED
> {code}
> It's very surprising that an unprivileged user can run code which so easily 
> causes a fundamental administration tool to fail.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to