Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala getting started guide fails with logging config error when run with read-only workspace directory #684

Open
edmorley opened this issue May 30, 2024 · 0 comments

Comments

@edmorley
Copy link
Member

This is similar to #655, except the image is being run with a read-only filesystem mount, rather than a separate Linux user.

Currently if the Scala getting started guide is run with a read-only filesystem (with only /tmp and /home/heroku set to writable), by using docker run --read-only --tmpfs /tmp --tmpfs /home/heroku ..., then the following error occurs:

Picked up JAVA_TOOL_OPTIONS: -XX:MaxRAMPercentage=80.0 -Dfile.encoding=UTF-8
08:08:50,128 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
Oops, cannot start the server.
java.nio.file.FileSystemException: /workspace/target/universal/stage/RUNNING_PID: Read-only file system
	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218)
	at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:484)
	at java.base/java.nio.file.Files.newOutputStream(Files.java:228)
	at play.core.server.ProdServerStart$.createPidFile(ProdServerStart.scala:147)
	at play.core.server.ProdServerStart$.start(ProdServerStart.scala:45)
	at play.core.server.ProdServerStart$.main(ProdServerStart.scala:29)
	at play.core.server.ProdServerStart.main(ProdServerStart.scala)
08:08:50,128 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/workspace/target/universal/stage/conf/logback.xml]
08:08:50,180 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
08:08:50,181 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
08:08:50,190 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
08:08:50,198 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
08:08:50,250 |-INFO in ch.qos.logback.core.FileAppender[FILE] - File property is set to [./logs/application.log]
08:08:50,251 |-ERROR in ch.qos.logback.core.FileAppender[FILE] - Failed to create parent directories for [/workspace/target/universal/stage/./logs/application.log]
08:08:50,251 |-ERROR in ch.qos.logback.core.FileAppender[FILE] - openFile(./logs/application.log,true) call failed. java.io.FileNotFoundException: ./logs/application.log (No such file or directory)
	at java.io.FileNotFoundException: ./logs/application.log (No such file or directory)
	at 	at java.base/java.io.FileOutputStream.open0(Native Method)
	at 	at java.base/java.io.FileOutputStream.open(FileOutputStream.java:319)
	at 	at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:259)
	at 	at ch.qos.logback.core.recovery.ResilientFileOutputStream.<init>(ResilientFileOutputStream.java:26)
	at 	at ch.qos.logback.core.FileAppender.openFile(FileAppender.java:204)
	at 	at ch.qos.logback.core.FileAppender.start(FileAppender.java:127)
	at 	at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:90)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:179)
	at 	at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
	at 	at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:64)
	at 	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:134)
	at 	at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
	at 	at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
	at 	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
	at 	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
	at 	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
	at 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
	at 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
	at 	at play.api.Logger$.<clinit>(Logger.scala:265)
	at 	at play.api.Configuration$.<clinit>(Configuration.scala:168)
	at 	at play.core.server.ProdServerStart$.readServerConfigSettings(ProdServerStart.scala:102)
	at 	at play.core.server.ProdServerStart$.start(ProdServerStart.scala:42)
	at 	at play.core.server.ProdServerStart$.main(ProdServerStart.scala:29)
	at 	at play.core.server.ProdServerStart.main(ProdServerStart.scala)

(see https://github.com/heroku/cnb-builder-images/actions/runs/9299142531/job/25592522803)

This is presumably due to the logs location being configured here:
https://github.com/heroku/scala-getting-started/blob/61340fc2b557cb8bcf365c7bd7f05042cc9768f0/conf/logback.xml#L4-L5

...so perhaps this is specific to the getting started guide and needs fixing there, by making the logs write to /tmp instead?

However, I'm filing against the buildpack for now in case there is something the buildpack could/should be doing. (Feel free to use the GitHub issue transfer feature to move the issue over if preferred.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant