alist icon indicating copy to clipboard operation
alist copied to clipboard

重启容器时config.json的修改被回滚

Open SwingCosmic opened this issue 1 year ago • 8 comments
trafficstars

Please make sure of the following things

  • [X] I have read the documentation. 我已经阅读了文档

  • [X] I'm sure there are no duplicate issues or discussions. 我确定没有重复的issue或讨论。

  • [X] I'm sure it's due to AList and not something else(such as Network ,Dependencies or Operational). 我确定是AList的问题,而不是其他原因(例如网络依赖操作)。

  • [X] I'm sure this issue is not fixed in the latest version. 我确定这个问题在最新版本中没有被修复。

AList Version / AList 版本

v3.9.2触发,更新到v3.34.0复现(全新重装v3.34.0可以解决)

Driver used / 使用的存储驱动

local

Describe the bug / 问题描述

使用k8s + OpenEBS local卷 + PVC挂载本地硬盘文件夹到容器内的/opt/alist/data,可读写。 第一次启动前文件夹是空的

当删除Pod或者进行伸缩以重启容器时,config.json的内容被还原到初始状态

Reproduction / 复现链接

  1. 将alist副本数调整为0,取消data目录的挂载
  2. 直接修改openebs所挂载的物理路径/var/openebs/local/pvc-xxxxxxxx/config.json的文件,修改配置,例如s3配置并启用,保存
  3. 使用其他deployment挂载该pvc以进行测试,使用终端访问可以确认该文件内容确实发生了修改,然后取消挂载
  4. 重新对alist的/opt/alist/data目录挂载pvc,并将副本调整为1启动
  5. alist并未增加s3的配置菜单,并且直接访问硬盘物理文件发现内容被回滚

Config / 配置

初始配置(v3.9.2)

{
  "force": false,
  "address": "0.0.0.0",
  "port": 5244,
  "site_url": "",
  "cdn": "",
  "jwt_secret": "xxxx",
  "token_expires_in": 48,
  "database": {
    "type": "sqlite3",
    "host": "",
    "port": 0,
    "user": "",
    "password": "",
    "name": "",
    "db_file": "data/data.db",
    "table_prefix": "x_",
    "ssl_mode": ""
  },
  "scheme": {
    "https": false,
    "cert_file": "",
    "key_file": ""
  },
  "temp_dir": "data/temp",
  "bleve_dir": "data/bleve",
  "log": {
    "enable": true,
    "name": "data/log/log.log",
    "max_size": 10,
    "max_backups": 5,
    "max_age": 28,
    "compress": false
  },
  "max_connections": 0
}

k8s deployment

kind: Deployment
apiVersion: apps/v1
metadata:
  name: alist
  namespace: default
  labels:
    app: alist
spec:
  replicas: 1
  selector:
    matchLabels:
      app: alist
  template:
    metadata:
      labels:
        app: alist
    spec:
      volumes:
        - name: volume-xl4o13
          persistentVolumeClaim:
            claimName: alist-config
        - name: volume-wyddal
          persistentVolumeClaim:
            claimName: alist-data
      containers:
        - name: container-z2joj2
          image: 'xhofe/alist:v3.9.2'
          ports:
            - name: tcp-5244
              containerPort: 5244
              protocol: TCP
          env:
            - name: PGID
              valueFrom:
                configMapKeyRef:
                  name: alist-env
                  key: PGID
            - name: PUID
              valueFrom:
                configMapKeyRef:
                  name: alist-env
                  key: PUID
            - name: UMASK
              valueFrom:
                configMapKeyRef:
                  name: alist-env
                  key: UMASK
          resources: {}
          volumeMounts:
            - name: volume-xl4o13
              mountPath: /opt/alist/data
            - name: volume-wyddal
              mountPath: /data
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%

---

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: alist-data
  namespace: default
  annotations:
    pv.kubernetes.io/bind-completed: 'yes'
    pv.kubernetes.io/bound-by-controller: 'yes'
    volume.beta.kubernetes.io/storage-provisioner: openebs.io/local
    volume.kubernetes.io/selected-node: yourhost.com
    volume.kubernetes.io/storage-provisioner: openebs.io/local
  finalizers:
    - kubernetes.io/pvc-protection
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 512Gi
  volumeName: pvc-xxxxxx1
  storageClassName: local
  volumeMode: Filesystem

---

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: alist-config
  namespace: default
  annotations:
    pv.kubernetes.io/bind-completed: 'yes'
    pv.kubernetes.io/bound-by-controller: 'yes'
    volume.beta.kubernetes.io/storage-provisioner: openebs.io/local
    volume.kubernetes.io/selected-node: yourhost.com
    volume.kubernetes.io/storage-provisioner: openebs.io/local
  finalizers:
    - kubernetes.io/pvc-protection
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  volumeName: pvc-xxxxxx2
  storageClassName: local
  volumeMode: Filesystem

Logs / 日志

 INFO[2024-05-08 06:49:14] reading config file: data/config.json        

 INFO[2024-05-08 06:49:14] load config from env with prefix:            

 INFO[2024-05-08 06:49:14] init logrus...                               

 WARN[2024-05-08 06:49:15] not enable search                            

 INFO[2024-05-08 06:49:15] start server @ 0.0.0.0:5244                  

 INFO[2024-05-08 06:49:15] success load storage: [/nfs], driver: [Local] 

 INFO[2024-05-08 06:49:15] Aria2 not ready.    

SwingCosmic avatar May 08 '24 07:05 SwingCosmic

Thanks for opening your first issue here! Be sure to follow the issue template!

welcome[bot] avatar May 08 '24 07:05 welcome[bot]

看起来似乎在使用一个旧的版本 alist启动时会格式化当前配置文件为支持的配置。

请检查版本

xhofe avatar May 08 '24 11:05 xhofe

看起来似乎在使用一个旧的版本 alist启动时会格式化当前配置文件为支持的配置。

请检查版本

这个是最新版容器第一次起动的时候就自动生成的内容,原来文件夹是空的

SwingCosmic avatar May 09 '24 02:05 SwingCosmic

分享下我的解决方案, K8S 给alist配置一个sidecar容器 用sh脚本远程拉取配置文件 注入到alist.. 连pv pvc都省掉了。 而且不用担心alist版本问题,毕竟cron job定期强制重新拉取最新alist镜像.. 一劳永逸, 直接修改远程配置文件,下一轮K8S启动alist,sidecar容器 会自动重新拉取最新配置... 或者直接在sidecar 的sh脚本里面做定时校验配置文件是否有更新,有更新触发重新注入配置。

gowy222 avatar May 11 '24 08:05 gowy222

@xhofe 借楼说话,大佬,alist 考虑支持下配置文件远程订阅功能?通过环境变量提供配置订阅url。自动时间周期拉取检查订阅是否有变动?

gowy222 avatar May 11 '24 08:05 gowy222

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 24 '24 10:06 stale[bot]

@xhofe 3.35版本容器重启后配置依然会被重置 https://github.com/alist-org/alist/blob/270587723579f717d6da0c3e5b7131d72f919b1a/internal/bootstrap/config.go#L45 这边的配置被default配置覆盖后写回到了json文件里

LoadingZhang avatar Jul 07 '24 04:07 LoadingZhang

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 20 '24 05:08 stale[bot]

Hello @, this issue was closed due to inactive more than 52 days. You can reopen or recreate it if you think it should continue. Thank you for your contributions again.

github-actions[bot] avatar Aug 29 '24 00:08 github-actions[bot]