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

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

Open
4 tasks done
SwingCosmic opened this issue May 8, 2024 · 5 comments
Open
4 tasks done

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

SwingCosmic opened this issue May 8, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@SwingCosmic
Copy link

SwingCosmic commented May 8, 2024

Please make sure of the following things

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

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

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

  • 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 SwingCosmic added the bug Something isn't working label May 8, 2024
Copy link

welcome bot commented May 8, 2024

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

@xhofe
Copy link
Member

xhofe commented May 8, 2024

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

请检查版本

@SwingCosmic
Copy link
Author

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

请检查版本

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

@gowy222
Copy link

gowy222 commented May 11, 2024

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

@gowy222
Copy link

gowy222 commented May 11, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants