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

Failed to initialize issue indexer: mkdir data: permission denied in several situations #6959

Closed
2 of 7 tasks
Frickeldave opened this issue May 15, 2019 · 14 comments
Closed
2 of 7 tasks
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail

Comments

@Frickeldave
Copy link

  • Gitea version (or commit ref): 1.7.2 & 1.8.0
  • Git version: 2.2.0
  • Operating system: Alpine 3.9 within Docker
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

i created my own docker image, based on alpine 3.9. I use gitea 1.7.2 currently. The docker-host is a current CentOS.
I have the issue, that it is not possible to update something in a repo and to do merges with the webinterface (i think they belong together). When i try to do that, i get the following messages:

Edit something in the webinterface and commit:
UpdateLocalCopyBranch [branch: master]: git clone master: mkdir data: permission denied (Message appera in web ui)

Try to merge something within the webinterface
[…routers/repo/pull.go:589 MergePullRequest()] [E] Merge: Failed to create dir data/tmp/local-repo/merge-302991419.git: mkdir data: permission denied (Message appear in logfile)

The environment
In the docker image i created a user “appuser” with UID and GID 140000. The gitea binaries are stored in /home/appuser/app, the configuration files are stored in /home/appuser/data. Of course, the appuser has access to both directories. I have a startscript (start.sh) as entrypoint defined. In this startscript i set all needed variables:

_export USER=$(whoami)
export USERNAME=$(whoami)
export GITEA_CUSTOM=/home/appuser/data/custom
export GITEA_WORK_DIR=/home/appuser/data_

I start gitea with /home/appuser/app/gitea -c /home/appuser/data/gitea.ini within the start.sh script.

No i tried to update to gitea 1.8.0 before opening this ticket. Now the server isn't starting anymore within exact the same docker image. The output of the console is

/ $ /home/appuser/app/gitea -c /home/appuser/data/gitea.ini
2019/05/15 14:03:35 [T] AppPath: /home/appuser/app/gitea
2019/05/15 14:03:35 [T] AppWorkPath: /home/appuser/app
2019/05/15 14:03:35 [T] Custom path: /home/appuser/data/custom
2019/05/15 14:03:35 [T] Log path: /home/appuser/data/log
/ $

In the logfile i have the following message:
2019/05/15 14:03:35 [I] Log Mode: File(Debug)
2019/05/15 14:03:35 [I] XORM Log Mode: File(Debug)
2019/05/15 14:03:35 [I] Cache Service Enabled
2019/05/15 14:03:35 [I] Session Service Enabled
2019/05/15 14:03:35 [I] Mail Service Enabled
2019/05/15 14:03:35 [I] Beginning ORM engine initialization.
2019/05/15 14:03:35 [I] ORM engine initialization attempt #1/10...
2019/05/15 14:03:35 [I] ORM engine initialization successful!
2019/05/15 14:03:35 [I] Git Version: 2.20.1
2019/05/15 14:03:35 [...itea/routers/init.go:95 GlobalInit()] [E] Failed to initialize issue indexer: mkdir data: permission denied

In gitea.ini the "APP" and "ROOT" pathes are specified as followed:

STATIC_ROOT_PATH = /home/appuser/app
APP_DATA_PATH = /home/appuser/data

From my point of view the cause of these issues is the same.
I also found issues #4672 and #6398 which are probably related, bot are closed and reference to #6367 which is a complete other topic (from my point of view, possibly i am wrong).

Would be cool to get help here...

Thanks in advance

Dave

@lunny
Copy link
Member

lunny commented May 17, 2019

Merge pull request should be a known issue.

@Frickeldave
Copy link
Author

But as described before, it's not only an issue with pull requests, also with editing in web and with version 1.8.0 during startup...

@lunny
Copy link
Member

lunny commented May 20, 2019

@Frickeldave I think you should check your filesystem permission since the log said permission denied.

@lunny lunny added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label May 20, 2019
@Frickeldave
Copy link
Author

Hi,

that was the first thing i have done. But i think the permissions are not the problem. The path /home/appuser/app and /home/appuser/data is fully writable for the user.

drwxr-sr-x 1 appuser appuser 26 May 17 06:58 .
drwxr-xr-x 1 root root 21 Feb 22 07:57 ..
-rw------- 1 appuser appuser 90 May 20 07:44 .ash_history
-rw-r--r-- 1 appuser appuser 150 May 15 15:29 .bashrc
drwxr-sr-x 1 appuser appuser 16 May 15 15:28 app
drwxr-sr-x 11 appuser appuser 269 May 17 06:49 data

Is it possile, that gitea tries to write to another path?

Regards

Dave

@Frickeldave
Copy link
Author

Hi,

any ideas regarding that issue? Any more feedback needed?

Regards

Dave

@zeripath
Copy link
Contributor

zeripath commented May 22, 2019

The issue indexer path is determined here:

Indexer.IssuePath = sec.Key("ISSUE_INDEXER_PATH").MustString(path.Join(AppDataPath, "indexers/issues.bleve"))

AppDataPath is determined here:

AppDataPath = sec.Key("APP_DATA_PATH").MustString(path.Join(AppWorkPath, "data"))

And AppWorkPath is either:

  • DIRECTORY_OF_GITEA_BINARY
  • $GITEA_WORK_DIR

In 1.9 you will be able to set this using the --work-dir option.

Looking at the information you've provided it looks like you need to set GITEA_WORK_DIR=/home/appuser/data

I suggest you shadow Gitea with a script that sets these for you.

@Frickeldave
Copy link
Author

Hi,

thank you very much. I already have a wrapper script. In my inital post this is already described:

I have a startscript (start.sh) as entrypoint defined. In this startscript i set all needed variables:

_
export USER=$(whoami)
export USERNAME=$(whoami)
export GITEA_CUSTOM=/home/appuser/data/custom
export GITEA_WORK_DIR=/home/appuser/data
_

I start gitea with /home/appuser/app/gitea -c /home/appuser/data/gitea.ini within the start.sh script.

Regards

Dave

@zeripath
Copy link
Contributor

I don't think your Gitea work dir export is working properly 2019/05/15 14:03:35 [T] AppWorkPath: /home/appuser/app

@zeripath
Copy link
Contributor

There's another place things get written to (!) $HOME/gitea-repositories but I can't remember off the top of my head which config that corresponds to.

@Frickeldave
Copy link
Author

Possibly. Here is a print from my console output:

_
/ $ echo "" > /home/appuser/data/log/gitea.log
/ $ cat /home/appuser/data/log/gitea.log

/ $ echo $GITEA_WORK_DIR
/home/appuser/data
/ $ /home/appuser/app/gitea web -c /home/appuser/data/gitea.ini
2019/05/22 12:23:36 [T] AppPath: /home/appuser/app/gitea
2019/05/22 12:23:36 [T] AppWorkPath: /home/appuser/data
2019/05/22 12:23:36 [T] Custom path: /home/appuser/data/custom
2019/05/22 12:23:36 [T] Log path: /home/appuser/data/log
/ $ cat /home/appuser/data/log/gitea.log

2019/05/22 12:23:36 [I] Log Mode: File(Info)
2019/05/22 12:23:36 [I] XORM Log Mode: File(Info)
2019/05/22 12:23:36 [I] Cache Service Enabled
2019/05/22 12:23:36 [I] Session Service Enabled
2019/05/22 12:23:36 [I] Beginning ORM engine initialization.
2019/05/22 12:23:36 [I] ORM engine initialization attempt #1/10...
2019/05/22 12:23:36 [I] ORM engine initialization successful!
2019/05/22 12:23:36 [I] Git Version: 2.20.1
2019/05/22 12:23:36 [...itea/routers/init.go:95 GlobalInit()] [E] Failed to initialize issue indexer: mkdir indexers: permission denied
_

As you can see, in the current console session, GITEA_WORK_DIR is set properly. Any other thing i can check?

Attached you will find my gitea.ini file.

Regards

Dave

gitea.ini.zip

@zeripath
Copy link
Contributor

It looks like you've just copied the whole of app.ini.sample as your app.ini... That's unnecessary and a very good way of ending up over-configuring things and perhaps even breaking things.

You should only copy what you need. For example, the log section is not meant to copied over exactly the way you have done - did you read it? I'm also concerned that you say you're using 1.7.2 (or maybe 1.8.0) but that app.ini.sample is the 1.9 sample. (You're definitely not running 1.9 I can tell from the logging.) I would seriously recommend paring down your app.ini so that it represents what you need to configure and only what you need to configure.

Further are you telling me that you're ending up with different configuration between starting gitea on the console and starting it through your start.sh script? If so the problem lies in your start.sh script. Is it possible that your options are being overridden somewhere else? On the admin pages of gitea you should be able to check where it thinks it is looking for things. In particular it will say if GITEA_WORK_DIR is set and/or GITEA_CUSTOM.

You really should also upgrade your Gitea to at least 1.8.1.

@Frickeldave
Copy link
Author

Thank you very much for the time you invest.
Currently in 1.8.0 i have the situtation, that gitea isn't starting, therefore i cannot look into the admin page. It just write out the 4 lines at the console i have posted before. In the version 1.7.2 gitea is starting with the same configuration file (1.7.2 is our prod system, 1.8.0 my dev system).
Currently i ran gitea from an interactive console just for testing (and to exclude every issue that should come from the start.sh script). I execute the 4 export command and then run gitea as shown before.
Regarding the app.ini version: I will compare with the 1.8.0 version, and let you know the results here.

@Frickeldave
Copy link
Author

Fixed the error regarding the failed start of gitea 1.8.0. The default value for ISSUE_INDEXER_PATH and ISSUE_INDEXER_QUEUE_DIR are set to "indexers/issue.bleve / indexers/issue.queue". This works in 1.7.2 but not in 1.8.0. I changed the pathes to an absolute path (/home/appuser/data/indexers/.... )and now the server starts. At next i will try to find out why its not possible to edit files within web editor or do merges within web editor.

@Frickeldave
Copy link
Author

WIth the previous describes change also the web-based editor as well as pull requests are working now. Closing ticket.

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail
Projects
None yet
Development

No branches or pull requests

3 participants