osixia / docker-phpLDAPadmin

phpLDAPadmin container image 🐳🌴
MIT License
844 stars 197 forks source link

Phpldapadmin pod fails with "No such file or directory" error #45

Open eromanova opened 5 years ago

eromanova commented 5 years ago

Description I'm using kubernetes to deploy phpLDAPadmin. If I set --copy-service argument in phpLDAPadmin deployment, pod fails with No such file or directory: '/container/service/:runit/download.sh'")] error. Steps to reproduce Create deployment.yaml file with configuration below and run kubectl create -f deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: phpldapadmin
  labels:
    app: phpldapadmin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: phpldapadmin
  template:
    metadata:
      name: phpldapadmin
      labels:
        app: phpldapadmin
    spec:
      initContainers:
      containers:
      - name: ldap
        image: docker.io/osixia/phpldapadmin:0.7.1
        imagePullPolicy: Always
        args: ["--copy-service"]
        env:
        - name: PHPLDAPADMIN_HTTPS
          value: "false"
        - name: PHPLDAPADMIN_LDAP_HOSTS
          value: ldap

Expected result PhpLDAPadmin pod status is RUNNING.

Actual result Pod fails with CrashLoopBackOff status.

Logs

Name:           phpldapadmin-b86776f8d-fkfsk
Namespace:      phpadmintest
Node:           kq-zi2miedhorh3tht6nghxad4h7i-1-ckit7cqvdfr7nvgs/10.1.0.6
Start Time:     Tue, 28 Aug 2018 19:12:58 +0400
Labels:         app=phpldapadmin
                pod-template-hash=642332948
Annotations:    <none>
Status:         Running
IP:             10.233.101.104
Controlled By:  ReplicaSet/phpldapadmin-b86776f8d
Containers:
  ldap:
    Container ID:  docker://ad02313095568c03c1909dbb191fc841d939a81b20674e184cf5af0fe2654f4c
    Image:         docker.io/osixia/phpldapadmin:0.7.1
    Image ID:      docker-pullable://docker-prod-local.artifactory.mirantis.com/mirantis/map/phpldapadmin@sha256:2c78c0ed0400eae8011663610e6f82828de64e91e2a5d4e501d53541df350c40
    Port:          <none>
    Args:
      --copy-service
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Tue, 28 Aug 2018 19:16:13 +0400
      Finished:     Tue, 28 Aug 2018 19:16:14 +0400
    Ready:          False
    Restart Count:  5
    Environment:
      PHPLDAPADMIN_HTTPS:       false
      PHPLDAPADMIN_LDAP_HOSTS:  ldap
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-nwgxj (ro)
Conditions:
  Type           Status
  Initialized    True 
  Ready          False 
  PodScheduled   True 
Volumes:
  default-token-nwgxj:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-nwgxj
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     <none>
Events:
  Type     Reason                 Age              From                                                       Message
  ----     ------                 ----             ----                                                       -------
  Normal   Scheduled              4m               default-scheduler                                          Successfully assigned phpldapadmin-b86776f8d-fkfsk to kq-zi2miedhorh3tht6nghxad4h7i-1-ckit7cqvdfr7nvgs
  Normal   SuccessfulMountVolume  4m               kubelet, kq-zi2miedhorh3tht6nghxad4h7i-1-ckit7cqvdfr7nvgs  MountVolume.SetUp succeeded for volume "default-token-nwgxj"
  Normal   Pulled                 4m (x4 over 4m)  kubelet, kq-zi2miedhorh3tht6nghxad4h7i-1-ckit7cqvdfr7nvgs  Successfully pulled image "docker.io/osixia/phpldapadmin:0.7.1"
  Normal   Created                4m (x4 over 4m)  kubelet, kq-zi2miedhorh3tht6nghxad4h7i-1-ckit7cqvdfr7nvgs  Created container
  Normal   Started                4m (x4 over 4m)  kubelet, kq-zi2miedhorh3tht6nghxad4h7i-1-ckit7cqvdfr7nvgs  Started container
  Warning  BackOff                3m (x7 over 4m)  kubelet, kq-zi2miedhorh3tht6nghxad4h7i-1-ckit7cqvdfr7nvgs  Back-off restarting failed container
  Normal   Pulling                3m (x5 over 4m)  kubelet, kq-zi2miedhorh3tht6nghxad4h7i-1-ckit7cqvdfr7nvgs  pulling image "docker.io/osixia/phpldapadmin:0.7.1"
eromanova@ubuntu:~/projects/phpldapadmintest$ kubectl logs po/phpldapadmin-b86776f8d-fkfsk -n phpadmintest*** CONTAINER_LOG_LEVEL = 3 (info)
*** Copy /container/service to /container/run/service
*** Killing all processes...
Traceback (most recent call last):
  File "/container/tool/run", line 890, in <module>
    main(args)
  File "/container/tool/run", line 775, in main
    setup_run_directories(args)
  File "/container/tool/run", line 376, in setup_run_directories
    copy_service_to_run_dir()
  File "/container/tool/run", line 442, in copy_service_to_run_dir
    shutil.copytree(IMPORT_SERVICE_DIR, RUN_SERVICE_DIR)
  File "/usr/lib/python2.7/shutil.py", line 208, in copytree
    raise Error, errors
shutil.Error: [('/container/service/:runit/download.sh', '/container/run/service/:runit/download.sh', "[Errno 2] No such file or directory: '/container/service/:runit/download.sh'")]

Workaround If I deploy without args, no error occurs. Another workaround is to set command inside spec.container:

...
        env:
        - name: PHPLDAPADMIN_HTTPS
          value: "false"
        - name: PHPLDAPADMIN_LDAP_HOSTS
          value: ldap
        command:
        - /bin/sh
        - ce
        - /container/tool/run

Without such argument I may have some problems with mounted files on some systems (as written in README.md). How can I avoid this problem?

degorenko commented 5 years ago

Looks like this is because of broken permissions/ownership on file:

root@ldap:/# ls -la /container/service/:runit/ ls: cannot access '/container/service/:runit/download.sh': No such file or directory total 12 drwxrwxr-x 2 root root 4096 Sep 4 2018 . drwxr-xr-x 1 root root 4096 Jul 11 13:51 .. c????????? ? ? ? ? ? download.sh`

Defected image built?