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

PR #2095 broke post-installation scripts in k8s #2114

Closed
Sad-Soul-Eater opened this issue Dec 5, 2023 · 2 comments · Fixed by #2115
Closed

PR #2095 broke post-installation scripts in k8s #2114

Sad-Soul-Eater opened this issue Dec 5, 2023 · 2 comments · Fixed by #2115

Comments

@Sad-Soul-Eater
Copy link
Contributor

In PR #2095, the next line was added:

find "${hook_folder_path}" -type f -maxdepth 1 -iname '*.sh' -print | sort | while read -r script_file_path; do

The main problem is in the -type f filter because Kubernetes mounts ConfigMap as a directory with symlinks, not files, thus leading to to incapability of the find utility to find scripts because of the -type f filter.

This issue can be fixed by changing the -type f filter to -type f,l. I tested the entrypoint.sh that includes this change - it working as expected.

Nextcloud deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: &app nextcloud
  labels:
    app: *app
spec:
  replicas: 1

  strategy:
    type: Recreate

  selector:
    matchLabels:
      app: *app

  template:
    metadata:
      labels:
        app: *app

    spec:
      containers:
        - name: nextcloud
          image: nextcloud:27.1.4-apache

          volumeMounts:
            - name: nextcloud-scripts-post-installation
              mountPath: /docker-entrypoint-hooks.d/post-installation

      volumes:
        - name: nextcloud-scripts-post-installation
          configMap:
            name: nextcloud-scripts-post-installation
            defaultMode: 0555
/docker-entrypoint-hooks.d/post-installation content
root@nextcloud-596db956c4-bs2rd:/docker-entrypoint-hooks.d/post-installation# ls -lah
total 4.0K
drwxrwsrwx 3 root www-data 4.0K Dec  5 09:38 .
drwxr-xr-x 7 root root      117 Nov 28 18:29 ..
drwxr-sr-x 2 root www-data  164 Dec  5 09:38 ..2023_12_05_09_38_13.2954059579
lrwxrwxrwx 1 root www-data   32 Dec  5 09:38 ..data -> ..2023_12_05_09_38_13.2954059579
lrwxrwxrwx 1 root www-data   25 Dec  5 09:38 01-disable-apps.sh -> ..data/01-disable-apps.sh
lrwxrwxrwx 1 root www-data   23 Dec  5 09:38 01-oidc-setup.sh -> ..data/01-oidc-setup.sh
lrwxrwxrwx 1 root www-data   20 Dec  5 09:38 01-theming.sh -> ..data/01-theming.sh
lrwxrwxrwx 1 root www-data   27 Dec  5 09:38 02-configure-ldap.sh -> ..data/02-configure-ldap.sh
lrwxrwxrwx 1 root www-data   25 Dec  5 09:38 02-install-apps.sh -> ..data/02-install-apps.sh
lrwxrwxrwx 1 root www-data   32 Dec  5 09:38 99-install-notify-push.sh -> ..data/99-install-notify-push.sh
@daluca
Copy link

daluca commented Dec 21, 2023

Using -type f,l is an invalid argument for find on Alpine but works with Debian.

Using -type f -o -type l fixes the issue and will work with find on both BusyBox and GNU implementations on Alpine and Debian respectively.

@Sad-Soul-Eater
Copy link
Contributor Author

@daluca Yep, you are right, that was already discussed here #2115 (comment), and the latest fix variant should work with Alpine. PR is waiting for review and approval.

@J0WI J0WI closed this as completed in #2115 Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants