How to change Openshift 4.2 'volumeMounts' directory mode to 0770

Viewed 168

The problem

I have this openshift 4.2 code:

   spec:
      containers:
        - envFrom:
            - secretRef:
                name: mysql
          image: >-
            joshstruktur/nextcloud@sha256:4b515d17b7e9ef2aea9d05d64b09ce0710fbb54067ad4bb79941fd7267020c9c
          imagePullPolicy: IfNotPresent
          name: nextcloud-apache-8080
          ports:
            - containerPort: 80
              protocol: TCP
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /var/www/html
              name: nextcloud-apache-8080-1
            - mountPath: /var/www/html/data
              name: nextcloud-data-volume
              subPath: data
            - mountPath: /var/www/html/config
              name: nextcloud-data-volume
              subPath: config
            - mountPath: /var/www/html/custom_apps
              name: nextcloud-data-volume
              subPath: apps
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
        - emptyDir: {}
          name: nextcloud-apache-8080-1
        - name: nextcloud-data-volume
          persistentVolumeClaim:
            claimName: nextcloud-data

But the /var/www/html/data directory has this permissions:

$ ls -lathr
total 932K
drwxrwsrwx. 14 root       1204820000 4.0K May 11 09:39 ..
-rw-r--r--.  1 1204820000 1204820000    0 May 11 09:39 index.html
-rw-r--r--.  1 1204820000 1204820000    0 May 11 09:39 .ocdata
-rw-r--r--.  1 1204820000 1204820000  542 May 11 09:39 .htaccess
drwxr-sr-x.  3 1204820000 1204820000 4.0K May 11 09:39 admin
drwxr-sr-x.  4 1204820000 1204820000 4.0K May 11 09:39 appdata_oclrijg1anjh
-rw-r--r--.  1 1204820000 1204820000 888K May 11 09:39 owncloud.db
-rw-r-----.  1 1204820000 1204820000  22K May 11 10:09 nextcloud.log
drwxrwsr-x.  4 root       1204820000 4.0K May 11 10:09 .

While the php application nextcloud (docker hub, see nextcloud:apache 18) wants it to be 0770 instead, see log message below.

Question

How to mount that directory with a different mode like 0770? I found mode and defaultMode here (3.6 Openshift) see https://docs.openshift.com/container-platform/3.6/dev_guide/projected_volumes.html but I don't understand how to apply this to my configuration, if possible at all.

Log of nextcloud

{"reqId":"Azvfb0IRRiJpT7Fygsid","level":3,"time":"2020-05-11T09:54:29+00:00","remoteAddr":"10.129.38.1","user":"admin","app":"no app in context","method":"GET","url":"/index.php/csrftoken","message":{"Exception":"Symfony\\Component\\Routing\\Exception\\RouteNotFoundException","Message":"Unable to generate a URL for the named route \"photos.page.index\" as such route does not exist.","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Route/Router.php","line":339,"function":"generate","class":"Symfony\\Component\\Routing\\Generator\\UrlGenerator","type":"->","args":["photos.page.index",[],1]},{"file":"/var/www/html/lib/private/Route/CachingRouter.php","line":59,"function":"generate","class":"OC\\Route\\Router","type":"->","args":["photos.page.index",[],false]},{"file":"/var/www/html/lib/private/URLGenerator.php","line":82,"function":"generate","class":"OC\\Route\\CachingRouter","type":"->","args":["photos.page.index",[]]},{"file":"/var/www/html/lib/private/NavigationManager.php","line":293,"function":"linkToRoute","class":"OC\\URLGenerator","type":"->","args":["photos.page.index"]},{"file":"/var/www/html/lib/private/NavigationManager.php","line":114,"function":"init","class":"OC\\NavigationManager","type":"->","args":[]},{"file":"/var/www/html/apps/theming/lib/ThemingDefaults.php","line":182,"function":"getAll","class":"OC\\NavigationManager","type":"->","args":["guest"]},{"file":"/var/www/html/lib/private/legacy/defaults.php","line":263,"function":"getShortFooter","class":"OCA\\Theming\\ThemingDefaults","type":"->","args":[]},{"file":"/var/www/html/lib/public/Defaults.php","line":169,"function":"getLongFooter","class":"OC_Defaults","type":"->","args":[]},{"file":"/var/www/html/core/templates/layout.guest.php","line":55,"function":"getLongFooter","class":"OCP\\Defaults","type":"->","args":[]},{"file":"/var/www/html/lib/private/Template/Base.php","line":179,"args":["/var/www/html/core/templates/layout.guest.php"],"function":"include"},{"file":"/var/www/html/lib/private/Template/Base.php","line":151,"function":"load","class":"OC\\Template\\Base","type":"->","args":["/var/www/html/core/templates/layout.guest.php",null]},{"file":"/var/www/html/lib/private/legacy/template.php","line":181,"function":"fetchPage","class":"OC\\Template\\Base","type":"->","args":[null]},{"file":"/var/www/html/lib/private/legacy/template.php","line":212,"function":"fetchPage","class":"OC_Template","type":"->","args":[null]},{"file":"/var/www/html/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->","args":[]},{"file":"/var/www/html/lib/private/legacy/template.php","line":274,"function":"printPage","class":"OC\\Template\\Base","type":"->","args":[]},{"file":"/var/www/html/lib/base.php","line":664,"function":"printGuestPage","class":"OC_Template","type":"::","args":["","error",{"errors":[{"error":"Your data directory is readable by other users","hint":"Please change the permissions to 0770 so that the directory cannot be listed by other users."}]}]},{"file":"/var/www/html/lib/base.php","line":1089,"function":"init","class":"OC","type":"::","args":[]},{"file":"/var/www/html/index.php","line":36,"args":["/var/www/html/lib/base.php"],"function":"require_once"}],"File":"/var/www/html/3rdparty/symfony/routing/Generator/UrlGenerator.php","Line":144,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0","version":"18.0.4.2"}
1 Answers

You can change your volume setting, such as:

   spec:
      containers:
        - envFrom:
            - secretRef:
                name: mysql
          image: >-
            joshstruktur/nextcloud@sha256:4b515d17b7e9ef2aea9d05d64b09ce0710fbb54067ad4bb79941fd7267020c9c
          imagePullPolicy: IfNotPresent
          name: nextcloud-apache-8080
          ports:
            - containerPort: 80
              protocol: TCP
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /var/www/html
              name: nextcloud-apache-8080-1
            - mountPath: /var/www/html/data
              name: nextcloud-data-volume
              subPath: data
            - mountPath: /var/www/html/config
              name: nextcloud-data-volume
              subPath: config
            - mountPath: /var/www/html/custom_apps
              name: nextcloud-data-volume
              subPath: apps
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
        - emptyDir: {}
          name: nextcloud-apache-8080-1
          projected:
            defaultMode: 0770
        - name: nextcloud-data-volume
          projected:
            defaultMode: 0770
            sources:
              - persistentVolumeClaim:
                  claimName: nextcloud-data

For more detail, please check https://docs.openshift.com/container-platform/4.2/nodes/containers/nodes-containers-projected-volumes.html

Related