LibrePhotos / librephotos-docker

You can find here the Dockerfiles for the automated build process of LibrePhotos.
MIT License
157 stars 101 forks source link

Permission issue with /data_models/clip-embeddings/0_CLIPModel/ViT-B-32.pt in k8s deployment #86

Closed marco-lia-blog closed 1 year ago

marco-lia-blog commented 1 year ago

I have an k8s deployment of librephotos running, using the LibrePhotos/librephotos-docker/k8s yamls. Everytime a user scans for new Images the calculate_clip_embeddings job fails and I have to delete it as admin user.

I found following error in the log:

2023-01-03 16:14:18,302 : batch_jobs.py : batch_calculate_clip_embedding : 87 : ERROR : Error in batch_calculate_clip_embedding: [Errno 13] Permission denied: '/data_models/clip-embeddings/0_CLIPModel/ViT-B-32.pt'

Permissions of the path /data_models/clip-embeddings/0_CLIPModel are at least readable till to the file ViT-B-32.pt which is

-rw------- 1 1000 1000 353976522 Jan  4  2021 ViT-B-32.pt

If I understand the deployment correctly the application runs as nobody because of following seccontext in the backend.yaml:

      securityContext:
        runAsUser: 65534
        runAsGroup: 65534
        fsGroup: 65534

Kustomize images are set as following:

images:
- name: backend-placeholder
  newName: reallibrephotos/librephotos
  newTag: 2022w50
- name: frontend-placeholder
  newName: reallibrephotos/librephotos-frontend
  newTag: 2022w50
- name: proxy-placeholder
  newName: reallibrephotos/librephotos-proxy
  newTag: 2022w45

Is that an error on my side or is there a chmod missing during image creation?

marco-lia-blog commented 1 year ago

I was able to workaround this by mounting a new persistent volume in /data_models and redownloading the contents of the original data_models directory in a poststart hook and changing permissionsin the backend as in:

    spec:
      containers:
      - name: backend
        image: backend-placeholder
        lifecycle:
          postStart:
            exec:
              command:  ["/bin/sh", "-c", "curl -SL https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/places365.tar.gz | tar -zxC /data_models/ && \
        curl -SL https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/im2txt.tar.gz | tar -zxC /data_models/ && \
        curl -SL https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/clip-embeddings.tar.gz | tar -zxC /data_models/ && \
        chmod -R 777 /data_models/clip-embeddings"]
…

But this is not a lasting solution because of the ridiculous long startup time for the deployment and the need for constant availability of the downloaded files.

I would suggest to change filepermissions inside of clip-embeddings.tar.gz.

marco-lia-blog commented 1 year ago

I think this has been fixed in https://github.com/LibrePhotos/librephotos-docker/releases/tag/2023w12