ARTIFACTORY: How to resolve the panic runtime error in the Router service when Artifactory starts up
Affected Versions: Artifactory 7.x
DescriptionWhen starting Artifactory, you may run into the below panic error message that’s related to the Router service (jf-router).
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb11b65]
goroutine 1 [running]:
os.(*File).Name(...)
/go/src/os/file.go:57
jfrog.com/jfrog-router/v7/internal/pkg/utils/fileutils.AtomicWriteFile({0x7fe3fff74f30, 0xc00064ca80}, {0xc0005212c0, 0x4b}, {0xc000b4a000, 0x74f, 0x771})
…
jfrog.com/jfrog-router/v7/internal/app/application.(*application).Start(0xc0009e0b00)
/src/router/internal/app/application/application.go:54 +0xa6
main.runApplication(0x2f77aa8, 0xc000440ff0)
/src/router/cmd/jf-router/main.go:44 +0x331
main.main()
/src/router/cmd/jf-router/main.go:29 +0x65
And other microservices will not connect to the Router service and Artifactory will fail to start.
[jfac ] Retry 150 Elapsed 1.24 minutes failed: Registration with router on URL http://localhost:8046 failed with error: UNAVAILABLE: io exception. Trying again [jfrt ] Cluster join: Retry 70: Service registry ping failed, will retry. Error while trying to connect to local router at address 'http://localhost:8046/access': Connect to localhost:8046 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
Resolution
This issue can occur when there is an issue with the TEMP directory in the Artifactory host machine. By default, Artifactory will use the “/tmp” directory as the default TEMP directory to write temporary files to operate. Below is an example of where Artifactory makes reference to the TEMP directory,
[$JFROG_HOME/artifactory/app]# grep -nr "/tmp" * Binary file artifactory/tomcat/webapps/access.war matches Binary file artifactory/tomcat/webapps/artifactory/WEB-INF/lib/spring-beans-5.3.20.jar matches Binary file artifactory/tomcat/webapps/artifactory/WEB-INF/lib/jruby-stdlib-9.2.20.1-jfrog-4.jar matches Binary file artifactory/tomcat/webapps/access/WEB-INF/lib/spring-beans-5.3.20.jar matches Binary file artifactory/tomcat/webapps/mc/WEB-INF/lib/spring-beans-5.3.20.jar matches Binary file bin/diagnostics/diagnosticsUtil matches bin/artifactory.sh:175: # Install license file if exists in /tmp bin/artifactory.sh:176: if ls /tmp/art*.lic 1> /dev/null 2>&1; then bin/artifactory.sh:177: logger "Found /tmp/art*.lic. Using t..." bin/artifactory.sh:178: cp -v /tmp/art*.lic $ART_ETC/artifactory.lic bin/migrationComposeInfo.yaml:63: work/access=access/tmp bin/migrationRpmInfo.yaml:97: work/access=access/tmp bin/migrationDockerInfo.yaml:61: work/access=access/tmp Binary file event/bin/jf-event matches
It’s possible that the permission to this directory has been changed and the Artifactory user does not have the permission to write to the directory. Or the TEMP directory may have been mounted to a different disk/partition that prevents the Artifactory user from writing to the directory.
Below is the default permission on the “/tmp” directory.
$ ls -al / drwxrwxrwt. 14 root root 4096 Feb 9 22:16 tmp
After correcting the permission to the TEMP directory, restart Artifactory and it should resolve the issue.