Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. OpenProject
  3. Frequent 500s because of permission denied /app/code/tmp/cache

Frequent 500s because of permission denied /app/code/tmp/cache

Scheduled Pinned Locked Moved Solved OpenProject
28 Posts 8 Posters 4.1k Views 8 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A adrw

    @nebulon Clicking around any page (ie. enter a project, see work packages...) frequently encounter the above posted specific cache miss error or the below generic 500 making navigating the app nearly impossible. Often refreshing the page a few times does let it finally load successfully. I've increased the RAM to 2GB and have not seen any other errors that seem to indicate that these are results of tunable performance bottlenecks vs potentially some change in how the app does caching that is incompatible with the existing Cloudron packaging. Does it work seemingly "normal" in your test instances? Maybe my Cloudron box has another problem that's contributing.

    Screen Shot 2020-12-20 at 22.09.18.png

    A Offline
    A Offline
    adrw
    wrote on last edited by
    #4

    @adrw I did try the previous fix for other apps that have worked of hitting save in the Location to regenerate proxy and Nginx configuration and that seems to have helped a lot. I'll report back if I see the 500s again.

    Thanks @girish for fixing this for the upcoming release.

    1 Reply Last reply
    0
    • girishG Offline
      girishG Offline
      girish
      Staff
      wrote on last edited by
      #5

      I think what's happening is that /tmp/cache is probably a symlink into /tmp. We have a tmpcleaner which periodically cleans out temporary files inside app containers. We should probably symlink it to /run instead of /tmp . I have to check the package and confirm.

      1 Reply Last reply
      1
      • girishG Offline
        girishG Offline
        girish
        Staff
        wrote on last edited by
        #6

        I was wrong. That directory is already symlinked to /run/openproject_tmp. So the problem is something else.

        A 1 Reply Last reply
        1
        • girishG girish

          I was wrong. That directory is already symlinked to /run/openproject_tmp. So the problem is something else.

          A Offline
          A Offline
          adrw
          wrote on last edited by
          #7

          @girish And to clarify, /run/* isn't read-only for the app?

          girishG 1 Reply Last reply
          0
          • A adrw

            @girish And to clarify, /run/* isn't read-only for the app?

            girishG Offline
            girishG Offline
            girish
            Staff
            wrote on last edited by
            #8

            @adrw Yes, /run/ is writable. If you get the app into same error state, please do a ls -l on the directory and let's try to see what is happening.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lolliop
              wrote on last edited by lolliop
              #9

              I'm getting the same errors as @adrw as well.
              This is on a fresh install of Ubuntu 20.04 and OpenProject.

              This is the log:

              Dec 24 15:22:40 E, [2020-12-24T08:46:40.026946 #259] ERROR -- : [current_user=Anonymous] Permission denied @ dir_s_mkdir - /app/code/tmp/cache/DD6/B70: Permission denied @ dir_s_mkdir - /app/code/tmp/cache/DD6/B70

              And when I checked the permissions:

              drwxr-xr-x 21 www-data www-data 4096 Dec 24 08:45 DD5/
              drwxr-xr-x  3 root     root     4096 Dec 24 06:10 DD6/
              drwxr-xr-x 21 www-data www-data 4096 Dec 24 08:48 DD7/
              

              Is it the issue with the directory, DD6, being not writable by www-data?

              Edit: There were 3 directories owned by root among 49 directories.

              nebulonN 1 Reply Last reply
              0
              • L lolliop

                I'm getting the same errors as @adrw as well.
                This is on a fresh install of Ubuntu 20.04 and OpenProject.

                This is the log:

                Dec 24 15:22:40 E, [2020-12-24T08:46:40.026946 #259] ERROR -- : [current_user=Anonymous] Permission denied @ dir_s_mkdir - /app/code/tmp/cache/DD6/B70: Permission denied @ dir_s_mkdir - /app/code/tmp/cache/DD6/B70

                And when I checked the permissions:

                drwxr-xr-x 21 www-data www-data 4096 Dec 24 08:45 DD5/
                drwxr-xr-x  3 root     root     4096 Dec 24 06:10 DD6/
                drwxr-xr-x 21 www-data www-data 4096 Dec 24 08:48 DD7/
                

                Is it the issue with the directory, DD6, being not writable by www-data?

                Edit: There were 3 directories owned by root among 49 directories.

                nebulonN Offline
                nebulonN Offline
                nebulon
                Staff
                wrote on last edited by
                #10

                @lolliop that is a good clue. The app should chown those directories on startup, however maybe they get created by some root process during runtime. If you restart the app, does the issue with that specific folder get sorted out (temporarily at least)?

                L 1 Reply Last reply
                0
                • nebulonN nebulon

                  @lolliop that is a good clue. The app should chown those directories on startup, however maybe they get created by some root process during runtime. If you restart the app, does the issue with that specific folder get sorted out (temporarily at least)?

                  L Offline
                  L Offline
                  lolliop
                  wrote on last edited by
                  #11

                  @nebulon,

                  So right after I restarted, the cache directory got emptied out and began creating 6 new directories which are all owned by www-data.

                  But after a few minutes, more directories appeared, and one of them was owned by root. Again, after a few more minutes, more directories were created and another root owned directory appeared. All these happened without any user interactions (e.g. Clicking a link or logging in to OpenProject).

                  A 1 Reply Last reply
                  1
                  • L lolliop

                    @nebulon,

                    So right after I restarted, the cache directory got emptied out and began creating 6 new directories which are all owned by www-data.

                    But after a few minutes, more directories appeared, and one of them was owned by root. Again, after a few more minutes, more directories were created and another root owned directory appeared. All these happened without any user interactions (e.g. Clicking a link or logging in to OpenProject).

                    A Offline
                    A Offline
                    adrw
                    wrote on last edited by
                    #12

                    Here's another error I've encountered, similar to the above. Any ideas @nebulon ?

                    Screen Shot 2021-01-01 at 23.43.37.png

                    L 1 Reply Last reply
                    0
                    • A adrw

                      Here's another error I've encountered, similar to the above. Any ideas @nebulon ?

                      Screen Shot 2021-01-01 at 23.43.37.png

                      L Offline
                      L Offline
                      lolliop
                      wrote on last edited by lolliop
                      #13

                      @adrw A quick and crude solution I found was to change the permissions of the files and directories under /app/code/tmp/cache:

                      docker exec -it OPENPROJECT-CONTAINER_ID chown -R www-data:www-data /app/code/tmp/cache

                      docier ps to get the container ID of your OpenProject.

                      However, the issue here is that new root owned directories will be arbitrarily created from time to time depending on your usage, so that aforementioned command needs to be executed accordingly. I'm thinking to put it in a cron job and make it run every 5 minutes.

                      Please note that I've had only a few hours of testing of this, and I don't know how it can impact the system in the long run.

                      We definitely need a proper and permanent solution.

                      Reference here, but it doesn't really apply to our issues.

                      robiR 1 Reply Last reply
                      1
                      • L lolliop

                        @adrw A quick and crude solution I found was to change the permissions of the files and directories under /app/code/tmp/cache:

                        docker exec -it OPENPROJECT-CONTAINER_ID chown -R www-data:www-data /app/code/tmp/cache

                        docier ps to get the container ID of your OpenProject.

                        However, the issue here is that new root owned directories will be arbitrarily created from time to time depending on your usage, so that aforementioned command needs to be executed accordingly. I'm thinking to put it in a cron job and make it run every 5 minutes.

                        Please note that I've had only a few hours of testing of this, and I don't know how it can impact the system in the long run.

                        We definitely need a proper and permanent solution.

                        Reference here, but it doesn't really apply to our issues.

                        robiR Offline
                        robiR Offline
                        robi
                        wrote on last edited by
                        #14

                        @lolliop sounds like their ruby app isn't dropping privileges correctly or running in the right user context.

                        Conscious tech

                        1 Reply Last reply
                        2
                        • nebulonN Offline
                          nebulonN Offline
                          nebulon
                          Staff
                          wrote on last edited by
                          #15

                          I have published a new app package with an attempt to fix the issue. Essentially all processes as well as apache2 only run as www-data so they don't have to drop privileges on their own. Especially phusion passenger for ruby gets loaded as root through apache, this is now fixed. Also all rake tasks are now run as www-data.

                          Please let us know if this indeed fixes the issue or not. I was not able to reliably reproduce the issue.

                          BenoitB 1 Reply Last reply
                          1
                          • nebulonN nebulon

                            I have published a new app package with an attempt to fix the issue. Essentially all processes as well as apache2 only run as www-data so they don't have to drop privileges on their own. Especially phusion passenger for ruby gets loaded as root through apache, this is now fixed. Also all rake tasks are now run as www-data.

                            Please let us know if this indeed fixes the issue or not. I was not able to reliably reproduce the issue.

                            BenoitB Offline
                            BenoitB Offline
                            Benoit
                            translator
                            wrote on last edited by
                            #16

                            Hi @nebulon,
                            i sent you an email because the last update of the openproject app doesn't work well. It can't restart after the update.
                            Log file : "Jan 22 09:46:31 `/var/www` is not writable."
                            Thanks for your help

                            nebulonN 1 Reply Last reply
                            0
                            • BenoitB Benoit

                              Hi @nebulon,
                              i sent you an email because the last update of the openproject app doesn't work well. It can't restart after the update.
                              Log file : "Jan 22 09:46:31 `/var/www` is not writable."
                              Thanks for your help

                              nebulonN Offline
                              nebulonN Offline
                              nebulon
                              Staff
                              wrote on last edited by
                              #17

                              @benoit ah only saw this now after answering your support mail. This is expected since bundler should not run as root and thus should not have access to /var/www. In fact that folder is not really being utilized. Bundler anyways falls back to /tmp.

                              I didn't get the restart issue though, can you explain that one?

                              BenoitB 1 Reply Last reply
                              0
                              • nebulonN nebulon

                                @benoit ah only saw this now after answering your support mail. This is expected since bundler should not run as root and thus should not have access to /var/www. In fact that folder is not really being utilized. Bundler anyways falls back to /tmp.

                                I didn't get the restart issue though, can you explain that one?

                                BenoitB Offline
                                BenoitB Offline
                                Benoit
                                translator
                                wrote on last edited by
                                #18

                                @nebulon the app is running but we have this on the screen "This app is currently not responding. Try refreshing the page."
                                This happened this night after app updated.

                                1 Reply Last reply
                                0
                                • nebulonN Offline
                                  nebulonN Offline
                                  nebulon
                                  Staff
                                  wrote on last edited by
                                  #19

                                  Oh I see. Since I had access to your instance for fixing the issue anyways, I saw that the app was healthy and running, but the nginx reverse proxy config wasn't correctly updated.
                                  This may actually be a bug in Cloudron. The reason likely is that I've changed the app's internal port from 80 to 8000 to not require apache to run as root.

                                  To fix this quickly, I've just submitted the location form of the app configure, which triggers a recreation of the reverse proxy files.

                                  At least for me the app is now reachable.

                                  BenoitB BrutalBirdieB 2 Replies Last reply
                                  2
                                  • nebulonN nebulon

                                    Oh I see. Since I had access to your instance for fixing the issue anyways, I saw that the app was healthy and running, but the nginx reverse proxy config wasn't correctly updated.
                                    This may actually be a bug in Cloudron. The reason likely is that I've changed the app's internal port from 80 to 8000 to not require apache to run as root.

                                    To fix this quickly, I've just submitted the location form of the app configure, which triggers a recreation of the reverse proxy files.

                                    At least for me the app is now reachable.

                                    BenoitB Offline
                                    BenoitB Offline
                                    Benoit
                                    translator
                                    wrote on last edited by
                                    #20

                                    @nebulon yes it works now ! Great ! That it means this problem can occur on a new app install ? And what about a restart or restore of an openproject app ? Thanks

                                    nebulonN 1 Reply Last reply
                                    0
                                    • BenoitB Benoit

                                      @nebulon yes it works now ! Great ! That it means this problem can occur on a new app install ? And what about a restart or restore of an openproject app ? Thanks

                                      nebulonN Offline
                                      nebulonN Offline
                                      nebulon
                                      Staff
                                      wrote on last edited by
                                      #21

                                      @benoit this is only an issue once during that one update.

                                      1 Reply Last reply
                                      1
                                      • nebulonN Offline
                                        nebulonN Offline
                                        nebulon
                                        Staff
                                        wrote on last edited by
                                        #22

                                        So the was indeed a bug in the platform code with the port change. This is now fixed and will be part of the next Cloudron release.

                                        1 Reply Last reply
                                        1
                                        • P Offline
                                          P Offline
                                          Peter Newman
                                          wrote on last edited by
                                          #23

                                          Based on my diagnosis, this is caused by the "worker" scheduler/cron task. Every time that runs (based on the log), I see a new file in /app/code/tmp/cache owned by root. Sometimes this new file is in a new directory (as the cache splits the storage across multiple directories on demand based on the random file name). When this newly created root owned folder is used by the normal process (running as www-data), it fails the permission check and users see the error message.

                                          I've been "fixing" this by manually running

                                          /app/code/tmp/cache# find -user root -exec chown www-data:www-data {} \;
                                          

                                          at the terminal.

                                          nebulonN 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Bookmarks
                                          • Search