kieraneglin / pinchflat

Your next YouTube media manager
GNU Affero General Public License v3.0
468 stars 8 forks source link

[notice] Application tzdata exited / Read-only root filesystem. #237

Closed reefland closed 1 month ago

reefland commented 1 month ago

Just upgraded from v0.1.17 -> v0.1.18, running under K3s with a non-root container and read-only root file system.

Added the TZ environment variable

        image:
          repository: ghcr.io/kieraneglin/pinchflat
          tag: v0.1.18@sha256:2f64c344cb02637a8b5d57d0aeb52e14d4849afc432c64fbce4b047c6c9c08b7
          pullPolicy: IfNotPresent
        env:
          TZ: America/New_York

And Pinchflat starts crash looping with this:

10:36:04.679 [info] Checking permissions for /config
10:36:04.681 [info] Permissions OK
10:36:04.681 [info] Checking permissions for /downloads
10:36:04.682 [info] Permissions OK
10:36:04.682 [info] Checking permissions for /tmp/pinchflat/data
10:36:04.682 [info] Permissions OK
10:36:04.682 [info] Checking permissions for /config/extras
10:36:04.682 [info] Permissions OK
10:36:04.682 [info] Checking permissions for /config/metadata
10:36:04.682 [info] Permissions OK
10:36:05.027 [info] Migrations already up
10:36:06.119 [notice] Application tzdata exited: exited in: Tzdata.App.start(:normal, [])
** (EXIT) an exception was raised:
** (MatchError) no match of right hand side value: {:error, {:shutdown, {:failed_to_start_child, Tzdata.EtsHolder, {%File.Error{reason: :enoent, path: "/etc/elixir_tzdata_data/release_ets", action: "list directory"}, [{File, :ls!, 1, [file: ~c"lib/file.ex", line: 1685]}, {Tzdata.EtsHolder, :release_files_for_dir, 1, [file: ~c"lib/tzdata/ets_holder.ex", line: 117]}, {Tzdata.EtsHolder, :make_sure_a_release_is_on_file, 0, [file: ~c"lib/tzdata/ets_holder.ex", line: 80]}, {Tzdata.EtsHolder, :init, 1, [file: ~c"lib/tzdata/ets_holder.ex", line: 16]}, {:gen_server, :init_it, 2, [file: ~c"gen_server.erl", line: 980]}, {:gen_server, :init_it, 6, [file: ~c"gen_server.erl", line: 935]}, {:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 241]}]}}}}
(tzdata 1.1.1) lib/tzdata/tzdata_app.ex:13: Tzdata.App.start/2
(kernel 9.2.1) application_master.erl:293: :application_master.start_it_old/4
Kernel pid terminated (application_controller) ("{application_start_failure,tzdata,{bad_return,{{'Elixir.Tzdata.App',start,[normal,[]]},{'EXIT',{{badmatch,{error,{shutdown,{failed_to_start_child,'Elixir.Tzdata.EtsHolder',{#{reason => enoent,path => <<\"/etc/elixir_tzdata_data/release_ets\">>,action => <<\"list directory\">>,'__struct__' => 'Elixir.File.Error','__exception__' => true},[{'Elixir.File','ls!',1,[{file,\"lib/file.ex\"},{line,1685}]},{'Elixir.Tzdata.EtsHolder',release_files_for_dir,1,[{file,\"lib/tzdata/ets_holder.ex\"},{line,117}]},{'Elixir.Tzdata.EtsHolder',make_sure_a_release_is_on_file,0,[{file,\"lib/tzdata/ets_holder.ex\"},{line,80}]},{'Elixir.Tzdata.EtsHolder',init,1,[{file,\"lib/tzdata/ets_holder.ex\"},{line,16}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,980}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,935}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,241}]}]}}}}},[{'Elixir.Tzdata.App',start,2,[{file,\"lib/tzdata/tzdata_app.ex\"},{line,13}]},{appli
Crash dump is being written to: erl_crash.dump...

To solve this I created an emptyDir mapped to /etc/elixir_tzdata_data such as:

persistence:
  elixir-tzdata:
    enabled: true
    globalMounts:
      - path: /etc/elixir_tzdata_data
    type: emptyDir
    medium: Memory

This allow Pinchflat to start:

10:51:40.752 [info] Migrations already up
10:51:41.821 [info] No tzdata release files found in custom data dir. Copying release file from tzdata priv dir.
10:51:41.921 [info] Reset 0 executing jobs
10:51:41.925 [info] [command_wrapper]: /usr/local/bin/yt-dlp called with: --version
10:51:42.364 [info] [command_wrapper]: /usr/local/bin/apprise called with: --version
10:51:42.474 [info] Running PinchflatWeb.Endpoint with cowboy 2.10.0 at 0.0.0.0:8945 (http)
10:51:42.475 [info] Access PinchflatWeb.Endpoint at http://localhost:8945
10:51:45.036 [info] tzdata release in place is from a file last modified Fri, 22 Oct 2021 02:20:47 GMT. Release file on server was last modified Thu, 01 Feb 2024 18:40:48 GMT.
10:51:45.506 [info] Tzdata has updated the release from 2021e to 2024a

Is it possible to define where the "tzdata" is written to? change it /tmp , etc. to reduce the write holes I have to put into the root files system? If not, then perhaps add another Checking permissions for this area?

kieraneglin commented 1 month ago

Hey there, thanks for the report (:

Good call-out! Truly, I hadn't considered how this would impact a read-only FS. I'll start looking into a fix for that 🤙

kieraneglin commented 1 month ago

Fixed and will be out with the next release! You can set the TZ data directory to a container directory with the TZ_DATA_DIR env var. I recommend setting it to a value like /config/extras/elixir_tz_data or /tmp/elixir_tz_data but you sound like you know what you're doing (:

Thanks again for the report!

kieraneglin commented 1 month ago

That's out with release v2024.5.14 which will be up in ~20 minutes 🤙

reefland commented 1 month ago

Thanks for the prompt support, worked great!