[Gitea 1.16.0] Unable to find configuration file #287

Closed
opened 2022-02-01 09:05:39 +00:00 by viceice · 21 comments
viceice commented 2022-02-01 09:05:39 +00:00 (Migrated from gitea.com)

Can't currently upgrade to gitea v1.16. Getting the following errors on configure-gitea container:

==== BEGIN GITEA CONFIGURATION ====
2022/02/01 09:02:51 ...s/setting/setting.go:543:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/"/etc/gitea/app.ini"'
2022/02/01 09:02:51 ...s/setting/setting.go:543:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/"/etc/gitea/app.ini"'
2022/02/01 09:02:51 ...s/setting/setting.go:583:loadFromConf() [F] Unable to find configuration file: "/data/gitea/\"/etc/gitea/app.ini\"".
	Ensure you are running in the correct environment or set the correct configuration file with -c.
Can't currently upgrade to gitea v1.16. Getting the following errors on `configure-gitea` container: ``` ==== BEGIN GITEA CONFIGURATION ==== 2022/02/01 09:02:51 ...s/setting/setting.go:543:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/"/etc/gitea/app.ini"' 2022/02/01 09:02:51 ...s/setting/setting.go:543:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/"/etc/gitea/app.ini"' 2022/02/01 09:02:51 ...s/setting/setting.go:583:loadFromConf() [F] Unable to find configuration file: "/data/gitea/\"/etc/gitea/app.ini\"". Ensure you are running in the correct environment or set the correct configuration file with -c. ```
viceice commented 2022-02-01 09:48:56 +00:00 (Migrated from gitea.com)

Looks like GITEA_APP_INI is no longer used and we need to explicit pass it to the cli via -c ${GITEA_APP_INI} ?

Looks like `GITEA_APP_INI` is no longer used and we need to explicit pass it to the cli via `-c ${GITEA_APP_INI}` ?
viceice commented 2022-02-01 10:01:30 +00:00 (Migrated from gitea.com)

OK, looks like i need to first update to chart version v5, currently using latest v4

OK, looks like i need to first update to chart version v5, currently using latest v4
viceice commented 2022-02-01 10:51:44 +00:00 (Migrated from gitea.com)

Nope, same issue with chart v5.0.1

Nope, same issue with chart v5.0.1
viceice commented 2022-02-01 13:03:07 +00:00 (Migrated from gitea.com)
maybe also fixes this https://github.com/go-gitea/gitea/pull/18524
lunny commented 2022-02-08 01:45:29 +00:00 (Migrated from gitea.com)

You can try 1.16.1 now.

You can try 1.16.1 now.
Sindvero commented 2022-02-08 02:34:49 +00:00 (Migrated from gitea.com)

With 1.16.1, the env var is used, but the configure-gitea container can't find the app.ini file while in 1.15.10 it would find it.

Unable to find configuration file: "/data/gitea/\"/data/gitea/conf/app.ini\"". │
│ Ensure you are running in the correct environment or set the correct configuration file with -c
With 1.16.1, the env var is used, but the configure-gitea container can't find the app.ini file while in 1.15.10 it would find it. ``` Unable to find configuration file: "/data/gitea/\"/data/gitea/conf/app.ini\"". │ │ Ensure you are running in the correct environment or set the correct configuration file with -c ```
justusbunsi commented 2022-02-08 05:57:27 +00:00 (Migrated from gitea.com)

Will have a look at this today.

Will have a look at this today.
justusbunsi commented 2022-02-08 17:30:38 +00:00 (Migrated from gitea.com)

Need more time to investigate this. I wasn't even able to run a simple "gitea serv" inside the containers (rootful/rootless) when not using the entrypoint of the container.

Need more time to investigate this. I wasn't even able to run a simple "gitea serv" inside the containers (rootful/rootless) when not using the entrypoint of the container.
aleksey.sergey commented 2022-02-09 11:22:11 +00:00 (Migrated from gitea.com)

The problem is related to the code below in /usr/local/bin/gitea:
https://github.com/go-gitea/gitea/blob/main/docker/rootless/usr/local/bin/gitea#L35

....
....
if [ -z "$APP_INI_SET" ]; then
        CONF_ARG="-c \"${GITEA_APP_INI:-$APP_INI}\""
fi


# Provide docker defaults
GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" $CONF_ARG "$@"

The thing is that $CONF_ARG in the bottom line is expanded into -c '"/data/gitea/conf/app.ini"' (extra single quotes). Not sure why bash is doing this.

As a workaround I added export PATH=/app/gitea/:$PATH to the top of configure_gitea.sh file. This way gitea there will run /app/gitea/gitea instead of /usr/local/bin/gitea.

The problem is related to the code below in `/usr/local/bin/gitea`: https://github.com/go-gitea/gitea/blob/main/docker/rootless/usr/local/bin/gitea#L35 ``` .... .... if [ -z "$APP_INI_SET" ]; then CONF_ARG="-c \"${GITEA_APP_INI:-$APP_INI}\"" fi # Provide docker defaults GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" $CONF_ARG "$@" ``` The thing is that $CONF_ARG in the bottom line is expanded into `-c '"/data/gitea/conf/app.ini"'` (extra single quotes). Not sure why `bash` is doing this. As a workaround I added `export PATH=/app/gitea/:$PATH` to the top of `configure_gitea.sh` file. This way `gitea` there will run `/app/gitea/gitea` instead of `/usr/local/bin/gitea`.
lunny commented 2022-02-09 13:58:41 +00:00 (Migrated from gitea.com)

It's related with https://github.com/go-gitea/gitea/pull/17846 . @zeripath

It's related with https://github.com/go-gitea/gitea/pull/17846 . @zeripath
zeripath commented 2022-02-09 15:08:54 +00:00 (Migrated from gitea.com)

Well it's more related to https://github.com/go-gitea/gitea/pull/18524 and related to the way the helm chart is passing in the variable.

(In some ways I'm slightly confused as to why that was needed in the first place because the docker-entrypoint.sh actually sets the -c ${GITEA_APP_INI} correctly so it should not have been needed if people were going through the docker-entrypoint.sh)

Not running the helm chart myself - I cannot begin to understand how or why the variable is ending up being double escaped. Nor can I test or change the script to make it work or print out what variable it is being sent. I am almost convinced that the problem has to be that helm chart is pre-quoting the environment variable - but I don't know enough to say that that is the case.

My suspicion comes from docker run -e GITEA_APP_INI="/etc/gitea/app-special.ini" gitea/gitea:1.16-dev-rootless does exactly the right thing.

Whereas, docker run -e GITEA_APP_INI="\"/etc/gitea/app-special.ini\"" gitea/gitea:1.16-dev-rootless replicates the problem.

The only thing I can think is that the helm chart is deliberately putting these quotes in and passing them to bash.

One option is to remove the \" from the shim?

But tbh docker-entrypoint.sh and docker-setup.sh should be changed to be quoting their use of ${GITEA_APP_INI} too.

Well it's more related to https://github.com/go-gitea/gitea/pull/18524 and related to the way the helm chart is passing in the variable. (In some ways I'm slightly confused as to why that was needed in the first place because the `docker-entrypoint.sh` actually sets the `-c ${GITEA_APP_INI}` correctly so it should not have been needed if people were going through the `docker-entrypoint.sh`) Not running the helm chart myself - I cannot begin to understand how or why the variable is ending up being double escaped. Nor can I test or change the script to make it work or print out what variable it is being sent. I am almost convinced that the problem has to be that helm chart is pre-quoting the environment variable - but I don't know enough to say that that is the case. My suspicion comes from `docker run -e GITEA_APP_INI="/etc/gitea/app-special.ini" gitea/gitea:1.16-dev-rootless` does exactly the right thing. Whereas, `docker run -e GITEA_APP_INI="\"/etc/gitea/app-special.ini\"" gitea/gitea:1.16-dev-rootless` replicates the problem. The only thing I can think is that the helm chart is deliberately putting these quotes in and passing them to bash. One option is to remove the `\"` from the shim? But tbh `docker-entrypoint.sh` and `docker-setup.sh` should be changed to be quoting their use of `${GITEA_APP_INI}` too.
aleksey.sergey commented 2022-02-09 15:23:44 +00:00 (Migrated from gitea.com)

From what I've seen, there's no problem with helm chart setting the GITEA_APP_INI env var.

here's the minimal sample to demonstrate the extra single quotes added by bash:

#!/usr/bin/env bash

set -x

GITEA_APP_INI=/data/gitea/conf/app.ini
CONF_ARG="-c \"${GITEA_APP_INI}\""

echo $CONF_ARG

results into:

+ GITEA_APP_INI=/data/gitea/conf/app.ini
+ CONF_ARG='-c "/data/gitea/conf/app.ini"'
+ echo -c '"/data/gitea/conf/app.ini"'
-c "/data/gitea/conf/app.ini"
From what I've seen, there's no problem with helm chart setting the GITEA_APP_INI env var. here's the minimal sample to demonstrate the extra single quotes added by bash: ```bash #!/usr/bin/env bash set -x GITEA_APP_INI=/data/gitea/conf/app.ini CONF_ARG="-c \"${GITEA_APP_INI}\"" echo $CONF_ARG ``` results into: ```text + GITEA_APP_INI=/data/gitea/conf/app.ini + CONF_ARG='-c "/data/gitea/conf/app.ini"' + echo -c '"/data/gitea/conf/app.ini"' -c "/data/gitea/conf/app.ini" ```
aleksey.sergey commented 2022-02-09 15:53:27 +00:00 (Migrated from gitea.com)

My suspicion comes from docker run -e GITEA_APP_INI="/etc/gitea/app-special.ini" gitea/gitea:1.16-dev-rootless does exactly the right thing.

It works because docker-entrypoint.sh passes the -c <ini_path> into /usr/local/bin/gitea and the latter doesn't hit the faulty branch.
The thing is that init containers in helm chart override the entrypoint from Dockerfile (docker-entrypoint.sh) with init/config scripts and /usr/local/bin/gitea has to deduce the config filepath on it's own (from GITEA_APP_INI env var).

> My suspicion comes from docker run -e GITEA_APP_INI="/etc/gitea/app-special.ini" gitea/gitea:1.16-dev-rootless does exactly the right thing. It works because `docker-entrypoint.sh` passes the `-c <ini_path>` into `/usr/local/bin/gitea` and the latter doesn't hit the faulty branch. The thing is that `init` containers in helm chart **override** the entrypoint from Dockerfile (`docker-entrypoint.sh`) with init/config scripts and `/usr/local/bin/gitea` has to deduce the config filepath on it's own (from GITEA_APP_INI env var).
aleksey.sergey commented 2022-02-09 15:58:42 +00:00 (Migrated from gitea.com)

shellcheck reports an error for line 35 in /usr/local/bin/gitea
I think it might be related to the problem.
https://github.com/go-gitea/gitea/blob/main/docker/rootless/usr/local/bin/gitea#L35

Quotes/backslashes will be treated literally. Use an array.shellcheck(SC2089)
https://github-wiki-see.page/m/koalaman/shellcheck/wiki/SC2089

`shellcheck` reports an error for line 35 in `/usr/local/bin/gitea` I think it might be related to the problem. https://github.com/go-gitea/gitea/blob/main/docker/rootless/usr/local/bin/gitea#L35 > Quotes/backslashes will be treated literally. Use an array.shellcheck(SC2089) https://github-wiki-see.page/m/koalaman/shellcheck/wiki/SC2089
zeripath commented 2022-02-09 16:17:38 +00:00 (Migrated from gitea.com)

My suspicion comes from docker run -e GITEA_APP_INI="/etc/gitea/app-special.ini" gitea/gitea:1.16-dev-rootless does exactly the right thing.

It works because docker-entrypoint.sh passes the -c <ini_path> into /usr/local/bin/gitea and the latter doesn't hit the faulty branch.

aha...

I've replicated it by just using the command line.

docker exec -it musing_brahmagupta bash 

OK that at least means I can fix the damned problem.

> > My suspicion comes from docker run -e GITEA_APP_INI="/etc/gitea/app-special.ini" gitea/gitea:1.16-dev-rootless does exactly the right thing. > It works because docker-entrypoint.sh passes the -c <ini_path> into /usr/local/bin/gitea and the latter doesn't hit the faulty branch. aha... I've replicated it by just using the command line. ```bash docker exec -it musing_brahmagupta bash ``` OK that at least means I can fix the damned problem.
zeripath commented 2022-02-09 16:21:52 +00:00 (Migrated from gitea.com)
#!/bin/bash

###############################################################
# This script sets defaults for gitea to run in the container #
###############################################################

# It assumes that you place this script as gitea in /usr/local/bin
#
# And place the original in /usr/lib/gitea with working files in /data/gitea
GITEA="/app/gitea/gitea"
WORK_DIR="/var/lib/gitea"
APP_INI="/etc/gitea/app.ini"

APP_INI_SET=""
for i in "$@"; do
	case "$i" in
	"-c")
		APP_INI_SET=1
		;;
	"-c="*)
		APP_INI_SET=1
		;;
	"--config")
		APP_INI_SET=1
		;;
	"--config="*)
		APP_INI_SET=1
		;;
	*)
	;;
	esac
done

if [ -z "$APP_INI_SET" ]; then
	CONF_ARG=("-c" "${GITEA_APP_INI:-$APP_INI}")
fi


# Provide docker defaults
GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" "${CONF_ARG[@]}" "$@"

fixes the problem

```bash #!/bin/bash ############################################################### # This script sets defaults for gitea to run in the container # ############################################################### # It assumes that you place this script as gitea in /usr/local/bin # # And place the original in /usr/lib/gitea with working files in /data/gitea GITEA="/app/gitea/gitea" WORK_DIR="/var/lib/gitea" APP_INI="/etc/gitea/app.ini" APP_INI_SET="" for i in "$@"; do case "$i" in "-c") APP_INI_SET=1 ;; "-c="*) APP_INI_SET=1 ;; "--config") APP_INI_SET=1 ;; "--config="*) APP_INI_SET=1 ;; *) ;; esac done if [ -z "$APP_INI_SET" ]; then CONF_ARG=("-c" "${GITEA_APP_INI:-$APP_INI}") fi # Provide docker defaults GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" "${CONF_ARG[@]}" "$@" ``` fixes the problem
zeripath commented 2022-02-09 16:25:48 +00:00 (Migrated from gitea.com)
https://github.com/go-gitea/gitea/pull/18690
justusbunsi commented 2022-02-10 13:16:03 +00:00 (Migrated from gitea.com)

Can confirm that the current 1.16-dev(-rootless) image works again.

Can confirm that the current 1.16-dev(-rootless) image works again.
pat-s commented 2022-02-12 17:40:24 +00:00 (Migrated from gitea.com)

FWIW I also face troubles on a fresh install using chart v5.0.0 and

  • Gitea 1.15.10
  • Gitea 1.16.1
  • Gitea 1.16-dev
Processing additionals...
find: /env-to-ini-mounts/additionals/: No such file or directory

=== All configuration sources loaded ===

2022/02/12 16:39:29 ...nvironment-to-ini.go:109:runEnvironmentToIni() [W] Custom config '/data/gitea/conf/app.ini' not found, ignore this if you're running first time
2022/02/12 16:39:29 ...nvironment-to-ini.go:89:main() [F] Failed to run app with [environment-to-ini -o /data/gitea/conf/app.ini -p ENV_TO_INI]: open /data/gitea/conf/app.ini: no such file or directory

but I am not sure, it might be a different error.

I am almost running the vanilla chart, with only changes to ingress and config.database which should not have an effect on the app.ini location.

EDIT: Probably related to a different issue, see https://gitea.com/gitea/helm-chart/issues/296.

FWIW I also face troubles on a **fresh** install using chart v5.0.0 and - Gitea 1.15.10 - Gitea 1.16.1 - Gitea 1.16-dev ``` Processing additionals... find: /env-to-ini-mounts/additionals/: No such file or directory === All configuration sources loaded === 2022/02/12 16:39:29 ...nvironment-to-ini.go:109:runEnvironmentToIni() [W] Custom config '/data/gitea/conf/app.ini' not found, ignore this if you're running first time 2022/02/12 16:39:29 ...nvironment-to-ini.go:89:main() [F] Failed to run app with [environment-to-ini -o /data/gitea/conf/app.ini -p ENV_TO_INI]: open /data/gitea/conf/app.ini: no such file or directory ``` but I am not sure, it might be a different error. I am almost running the vanilla chart, with only changes to `ingress` and `config.database` which should not have an effect on the `app.ini` location. EDIT: Probably related to a different issue, see https://gitea.com/gitea/helm-chart/issues/296.
pi3ch commented 2022-02-17 00:13:56 +00:00 (Migrated from gitea.com)

Can confirm that the current 1.16-dev(-rootless) image works again.

Yes, it works with 1.16-dev ?

> Can confirm that the current 1.16-dev(-rootless) image works again. Yes, it works with `1.16-dev` ?
pi3ch commented 2022-03-05 18:45:25 +00:00 (Migrated from gitea.com)

Just to add it works but it fails SSH authentication via public key even when SSH key is Verified in gitea. Not sure if this is related to this bug. No issue when root-mode is used.

Just to add it works but it fails SSH authentication via public key even when SSH key is `Verified` in gitea. Not sure if this is related to this bug. No issue when root-mode is used.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: lunny/helm-chart#287
No description provided.