go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.27k stars 5.51k forks source link

Gitea won't start after upgrade #26946

Closed MomentQYC closed 1 year ago

MomentQYC commented 1 year ago

Description

When all data storage methods are set to minio, an error routers/init.go:60:mustInit() [F] code.gitea.io/gitea/modules/storage.Init failed: permission denied is reported at startup. I've given the appropriate permissions, but the bottom line is that when I start Gitea with the root user by changing the code to bypass the restrictions, it still reports this error.

Gitea Version

1.20.3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.25.1

Operating System

Ubuntu 20.04

How are you running Gitea?

I compiled Gitea myself by downloading the source code and following the documentation, and this happens both when running it manually and using systemd.

Database

MySQL/MariaDB

lunny commented 1 year ago

Can you paste your configurations?

MomentQYC commented 1 year ago
APP_NAME = Gitea
RUN_USER = git
RUN_MODE = prod
WORK_PATH = /path/to/gitea

[server]
DOMAIN = example.com
ROOT_URL = https://example.com/
HTTP_PORT = 3000
DISABLE_SSH = false
SSH_DOMAIN = %(DOMAIN)s
SSH_PORT = 22
OFFLINE_MODE = false
LFS_START_SERVER = true
LFS_JWT_SECRET = secret1

[database]
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = gitea
USER = gitea
PASSWD = secret2
LOG_SQL = false

[security]
INSTALL_LOCK = true
SECRET_KEY = secret3
INTERNAL_TOKEN = secret4
LOGIN_REMEMBER_DAYS = 14
COOKIE_USERNAME = gitea_awesome
COOKIE_REMEMBER_NAME = gitea_incredible
PASSWORD_HASH_ALGO = pbkdf2

[oauth2]
ENABLE = true
JWT_SECRET = secret5

[log]
MODE = console
LEVEL = Error
logger.router.MODE = ,

[git]
PATH =

[service]
REGISTER_EMAIL_CONFIRM = true
ENABLE_NOTIFY_MAIL = true
ENABLE_CAPTCHA = true
REQUIRE_CAPTCHA_FOR_LOGIN = true
CAPTCHA_TYPE = cfturnstile
CF_TURNSTILE_SITEKEY = secret6
CF_TURNSTILE_SECRET = secret7
DEFAULT_KEEP_EMAIL_PRIVATE = true
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
DEFAULT_USER_IS_RESTRICTED = false
ENABLE_USER_HEATMAP = true
ENABLE_TIMETRACKING = true
DEFAULT_ENABLE_TIMETRACKING = true
NO_REPLY_ADDRESS =  hidemail.example.com
SHOW_REGISTRATION_BUTTON = true

[indexer]
ISSUE_INDEXER_NAME = gitea_issues
REPO_INDEXER_ENABLED = true
REPO_INDEXER_NAME = gitea_codes

[mailer]
ENABLED = true
SUBJECT_PREFIX = Gitea
SMTP_ADDR = smtp.example.com
SMTP_PORT = 587
FROM = "Gitea" <noreply@example.com>
USER = username
PASSWD = secret8

[session]
PROVIDER = db
COOKIE_NAME = gitea_session
COOKIE_SECURE = true

[picture]
GRAVATAR_SOURCE = https://example.com/gravatar/
ENABLE_FEDERATED_AVATAR = true

[attachment]
ENABLED = true
MAX_SIZE = 4
MAX_FILES = 3
STORAGE_TYPE = minio
SERVE_DIRECT = false
PATH = data/attachments
MINIO_ENDPOINT = 127.0.0.1:9000
MINIO_ACCESS_KEY_ID = secret9
MINIO_SECRET_ACCESS_KEY = secret10
MINIO_BUCKET = gitea
MINIO_LOCATION = global
MINIO_BASE_PATH = attachments/
MINIO_USE_SSL = false
MINIO_INSECURE_SKIP_VERIFY = true
MINIO_CHECKSUM_ALGORITHM = default

[i18n]
LANGS = en-US,zh-CN
NAMES = English,简体中文

[other]
SHOW_FOOTER_VERSION = false
SHOW_FOOTER_TEMPLATE_LOAD_TIME = false
ENABLE_SITEMAP = true
ENABLE_FEED = true

[packages]
ENABLED = true
STORAGE_TYPE = minio
MINIO_BASE_PATH = packages/
CHUNKED_UPLOAD_PATH = tmp/package-upload

[storage]
STORAGE_TYPE = minio

[repo-archive]
MINIO_BASE_PATH = repo-archive/

[storage.repo-archive]
STORAGE_TYPE = minio

[lfs]
STORAGE_TYPE = minio
PATH = data/lfs
MINIO_BASE_PATH = lfs/

[storage.packages]
STORAGE_TYPE = minio

[storage.my_minio]
STORAGE_TYPE = minio
MINIO_ENDPOINT = 127.0.0.1:9000
MINIO_ACCESS_KEY_ID = secret9
MINIO_SECRET_ACCESS_KEY = secret10
MINIO_BUCKET = gitea
MINIO_LOCATION = global
MINIO_USE_SSL = false
MINIO_INSECURE_SKIP_VERIFY = true

[actions]
ENABLED = true
DEFAULT_ACTIONS_URL = github

[storage.actions_log]
STORAGE_TYPE = minio
lunny commented 1 year ago

All

STORAGE_TYPE = minio

should be

STORAGE_TYPE = my_minio
MomentQYC commented 1 year ago

All

STORAGE_TYPE = minio

should be

STORAGE_TYPE = my_minio
[attachment]
;; Storage type for attachments, `local` for local disk or `minio` for s3 compatible
;; object storage service, default is `local`.
STORAGE_TYPE = minio

Does it need to be changed here too?

MomentQYC commented 1 year ago

All

STORAGE_TYPE = minio

should be

STORAGE_TYPE = my_minio

...s/setting/setting.go:109:LoadCommonSettings() [F] Unable to load settings from config: unsupported storage type "my_minio"

lunny commented 1 year ago

According to your configurations, I guess you can remove all related storage configuration and just leave one like below.

[storage]
STORAGE_TYPE = minio
MINIO_ENDPOINT = 127.0.0.1:9000
MINIO_ACCESS_KEY_ID = secret9
MINIO_SECRET_ACCESS_KEY = secret10
MINIO_BUCKET = gitea
MINIO_LOCATION = global
MINIO_USE_SSL = false
MINIO_INSECURE_SKIP_VERIFY = true
MomentQYC commented 1 year ago

According to your configurations, I guess you can remove all related storage configuration and just leave one like below.

[storage]
STORAGE_TYPE = minio
MINIO_ENDPOINT = 127.0.0.1:9000
MINIO_ACCESS_KEY_ID = secret9
MINIO_SECRET_ACCESS_KEY = secret10
MINIO_BUCKET = gitea
MINIO_LOCATION = global
MINIO_USE_SSL = false
MINIO_INSECURE_SKIP_VERIFY = true

When I run gitea migrate-storage it reports an error 2023/09/11 15:50:07 ...d/migrate_storage.go:188:runMigrateStorage() [F] Path must be given when storage is local I'm sure there's no storage type explicitly set to local

CaiCandong commented 1 year ago

Is it possible to communicate further via QQ(1290147055)? This makes it easier to pinpoint why this error occurs.

MomentQYC commented 1 year ago

Is it possible to communicate further via QQ(1290147055)? This makes it easier to pinpoint why this error occurs.

It seems that I'm unable to add you as a QQ friend (Privacy settings don't allow friending).

CaiCandong commented 1 year ago

It seems that I'm unable to add you as a QQ friend (Privacy settings don't allow friending).

I forgot to turn off my privacy settings, it should work now

CaiCandong commented 1 year ago
./gitea migrate-storage help
NAME:
   Gitea migrate-storage - Migrate the storage

USAGE:
   Gitea migrate-storage command [command options] [arguments...]

DESCRIPTION:
   Copies stored files from storage configured in app.ini to parameter-configured storage

COMMANDS:
   help, h  Shows a list of commands or help for one command

OPTIONS:
   --help, -h                        show help
   --custom-path value, -C value     Set custom path (defaults to '{WorkPath}/custom')
   --config value, -c value          Set custom config file (defaults to '{WorkPath}/custom/conf/app.ini')
   --work-path value, -w value       Set Gitea's working path (defaults to the Gitea's binary directory)
   --type value, -t value            Type of stored files to copy.  Allowed types: 'attachments', 'lfs', 'avatars', 'repo-avatars', 'repo-archivers', 'packages', 'actions-log'
   --storage value, -s value         New storage type: local (default) or minio
   --path value, -p value            New storage placement if store is local (leave blank for default)
   --minio-endpoint value            Minio storage endpoint
   --minio-access-key-id value       Minio storage accessKeyID
   --minio-secret-access-key value   Minio storage secretAccessKey
   --minio-bucket value              Minio storage bucket
   --minio-location value            Minio storage location to create bucket
   --minio-base-path value           Minio storage base path on the bucket
   --minio-use-ssl                   Enable SSL for minio (default: false)
   --minio-insecure-skip-verify      Skip SSL verification (default: false)
   --minio-checksum-algorithm value  Minio checksum algorithm (default/md5)

DEFAULT CONFIGURATION:
   AppPath:    D:/code/golang_code/gitea/gitea.exe
   WorkPath:   D:\code\golang_code\gitea
   CustomPath: D:\code\golang_code\gitea\custom
   ConfigFile: D:\code\golang_code\gitea\custom\conf\app.ini
CaiCandong commented 1 year ago

The problem is caused by the user's improper use of the migrate-storage command