Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-40421

Too many levels of symbolic links/Archiving artifact stuck

      When we have the symbolic links in src code like,

      dir1 -> .
      dir2 -> ../../../..

      Symptoms observed during this problematic phase:

      • The “Archiving artifact” step under Post- build phase get stuck. We can see the never ending cycling icon…
      • the slave node will report error like “too many levels of symbolic links” and ping response time would gradually degrade, eventually killing the slave.
      • the build log may also have error like WARN: Caught error while checking for symbolic links

          [JENKINS-40421] Too many levels of symbolic links/Archiving artifact stuck

          Oleg Nenashev added a comment -

          "too many levels of symbolic links" comes from the operating system, it has nothing to do with Jenkins. From what I see dir2 points to the directory, which contains dir2. In such case it will cause the infinite recursion cycle in the operating system.

          Oleg Nenashev added a comment - "too many levels of symbolic links" comes from the operating system, it has nothing to do with Jenkins. From what I see dir2 points to the directory, which contains dir2. In such case it will cause the infinite recursion cycle in the operating system.

          Daniel Beck added a comment -

          Weirdly enough the archiving code is supposed to detect cycles and abort. I think there are other issues related to this.

          Daniel Beck added a comment - Weirdly enough the archiving code is supposed to detect cycles and abort. I think there are other issues related to this.

          Audrey Azra added a comment -

          https://github.com/jenkinsci/jenkins/blob/08def67a18eee51de9f3f99bc2a792fee1c160e0/core/src/main/java/hudson/tasks/ArtifactArchiver.java#L251
          perhaps tuning system property value hudson.FilePath.VALIDATE_ANT_FILE_MASK_BOUND?
          Any recommendations or other suggestions Daniel?

          Audrey Azra added a comment - https://github.com/jenkinsci/jenkins/blob/08def67a18eee51de9f3f99bc2a792fee1c160e0/core/src/main/java/hudson/tasks/ArtifactArchiver.java#L251 perhaps tuning system property value hudson.FilePath.VALIDATE_ANT_FILE_MASK_BOUND? Any recommendations or other suggestions Daniel?

          Daniel Beck added a comment -

          In JENKINS-36559 I got the impression that that option didn't work, but it's been a while since I've looked.

          No suggestions right no other than ensuring you don't have loops.

          Daniel Beck added a comment - In JENKINS-36559 I got the impression that that option didn't work, but it's been a while since I've looked. No suggestions right no other than ensuring you don't have loops.

          David Spångberg added a comment - - edited

          The "to many levels of symbolic links" comes from "org.apache.tools.ant.DirectoryScanner.scandir" it seems.

          I tried the config.xml example from JENKINS-36559 and modified `hudson.Util.createFileSet(File, String, String)' to not follow symlinks, i.e. with `fs.setFollowSymlinks(false)'. Without the change I get slow archiving and the "too many levels of symbolic links" error log messages above. With the change the mentioned example seems to run ok. I'm testing on 1.642.4 instead of 1.642.3 though but I suppose that does not really matter.

          David Spångberg added a comment - - edited The "to many levels of symbolic links" comes from "org.apache.tools.ant.DirectoryScanner.scandir" it seems. I tried the config.xml example from JENKINS-36559 and modified `hudson.Util.createFileSet(File, String, String)' to not follow symlinks, i.e. with `fs.setFollowSymlinks(false)'. Without the change I get slow archiving and the "too many levels of symbolic links" error log messages above. With the change the mentioned example seems to run ok. I'm testing on 1.642.4 instead of 1.642.3 though but I suppose that does not really matter.

          Have the same issue. It breaks our slaves.

          Kirill Fedoseev added a comment - Have the same issue. It breaks our slaves.

          I worked around the issue by not using '**' to glob directories that contained symlinks to itself, but instead specified the exact files I required.

          Alastair D'Silva added a comment - I worked around the issue by not using '**' to glob directories that contained symlinks to itself, but instead specified the exact files I required.

          Vasile Baluta added a comment -

          Hi!

          Some updates related to versions from 2.89.2 and above.

          If anyone needs to do a patch then the solution proposed by David Spånberg is partly complete.

          setFolowSymlinks(false) needs also to be called for the instance of "org.apache.tools.ant.DirectoryScanner" created in method hasMatch in class hudson.FilePath.

          Vasile Baluta added a comment - Hi! Some updates related to versions from 2.89.2 and above. If anyone needs to do a patch then the solution proposed by David Spånberg is partly complete. setFolowSymlinks(false) needs also to be called for the instance of "org.apache.tools.ant.DirectoryScanner" created in method hasMatch in class hudson.FilePath.

            Unassigned Unassigned
            lmcazra Audrey Azra
            Votes:
            3 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: