Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1549029

Summary: [CRI-O] Readiness probe failed: sh: cannot set terminal process group (-1): Inappropriate ioctl for device
Product: OpenShift Container Platform Reporter: DeShuai Ma <dma>
Component: ContainersAssignee: Mrunal Patel <mpatel>
Status: CLOSED CURRENTRELEASE QA Contact: DeShuai Ma <dma>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.9.0CC: amurdaca, aos-bugs, dapark, decarr, dma, dyan, jhonce, jokerman, mmccomas, mpatel, vlaad, wewang, wzheng
Target Milestone: ---   
Target Release: 3.9.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-09-06 18:29:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
pod.yaml
none
config.json none

Description DeShuai Ma 2018-02-26 09:37:40 UTC
Description of problem:
When deploy cakephp+mysql ephemeral app, the mysql app meet error “Readiness probe failed: sh: cannot set terminal process group (-1): Inappropriate ioctl for device
”

Version-Release number of selected component (if applicable):
openshift v3.9.0-0.51.0
kubernetes v1.9.1+a0ce1bc657
etcd 3.2.8
# ./crio --version
crio version 1.9.7

How reproducible:
Always

Steps to Reproduce:
Deploy cakephp+mysql ephemeral app the check mysql pod status
[root@ip-172-18-6-178 bin]# oc describe po mysql-1-bs9bn -n dma1
Name:           mysql-1-bs9bn
Namespace:      dma1
Node:           ip-172-18-14-130.ec2.internal/172.18.14.130
Start Time:     Mon, 26 Feb 2018 03:57:13 -0500
Labels:         deployment=mysql-1
                deploymentconfig=mysql
                name=mysql
Annotations:    openshift.io/deployment-config.latest-version=1
                openshift.io/deployment-config.name=mysql
                openshift.io/deployment.name=mysql-1
                openshift.io/scc=restricted
Status:         Running
IP:             10.128.0.11
Controlled By:  ReplicationController/mysql-1
Containers:
  mysql:
    Container ID:   cri-o://c9842048503ee30b9eefd89512e6a9a697682c93271d57bca8954b977046a0de
    Image:          registry.access.redhat.com/rhscl/mysql-57-rhel7@sha256:7638d886370ca1eb3cefcfecf483f8dc4dc1ca05559dd521d1585ae7c4ed668e
    Image ID:       registry.access.redhat.com/rhscl/mysql-57-rhel7@sha256:7638d886370ca1eb3cefcfecf483f8dc4dc1ca05559dd521d1585ae7c4ed668e
    Port:           3306/TCP
    State:          Running
      Started:      Mon, 26 Feb 2018 03:58:20 -0500
    Ready:          True
    Restart Count:  0
    Limits:
      memory:  512Mi
    Requests:
      memory:   512Mi
    Liveness:   tcp-socket :3306 delay=30s timeout=1s period=10s #success=1 #failure=3
    Readiness:  exec [/bin/sh -i -c MYSQL_PWD='YlOSByUhBxOYYK70' mysql -h 127.0.0.1 -u cakephp -D default -e 'SELECT 1'] delay=5s timeout=1s period=10s #success=1 #failure=3
    Environment:
      MYSQL_USER:      <set to the key 'database-user' in secret 'cakephp-mysql-example'>      Optional: false
      MYSQL_PASSWORD:  <set to the key 'database-password' in secret 'cakephp-mysql-example'>  Optional: false
      MYSQL_DATABASE:  default
    Mounts:
      /var/lib/mysql/data from data (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-kr7l4 (ro)
Conditions:
  Type           Status
  Initialized    True
  Ready          True
  PodScheduled   True
Volumes:
  data:
    Type:    EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:  
  default-token-kr7l4:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-kr7l4
    Optional:    false
QoS Class:       Burstable
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/memory-pressure:NoSchedule
Events:
  Type     Reason                 Age   From                                    Message
  ----     ------                 ----  ----                                    -------
  Normal   Scheduled              17m   default-scheduler                       Successfully assigned mysql-1-bs9bn to ip-172-18-14-130.ec2.internal
  Normal   SuccessfulMountVolume  17m   kubelet, ip-172-18-14-130.ec2.internal  MountVolume.SetUp succeeded for volume "data"
  Normal   SuccessfulMountVolume  17m   kubelet, ip-172-18-14-130.ec2.internal  MountVolume.SetUp succeeded for volume "default-token-kr7l4"
  Normal   Pulling                17m   kubelet, ip-172-18-14-130.ec2.internal  pulling image "registry.access.redhat.com/rhscl/mysql-57-rhel7@sha256:7638d886370ca1eb3cefcfecf483f8dc4dc1ca05559dd521d1585ae7c4ed668e"
  Normal   Pulled                 16m   kubelet, ip-172-18-14-130.ec2.internal  Successfully pulled image "registry.access.redhat.com/rhscl/mysql-57-rhel7@sha256:7638d886370ca1eb3cefcfecf483f8dc4dc1ca05559dd521d1585ae7c4ed668e"
  Normal   Created                16m   kubelet, ip-172-18-14-130.ec2.internal  Created container
  Normal   Started                16m   kubelet, ip-172-18-14-130.ec2.internal  Started container
  Warning  Unhealthy              16m   kubelet, ip-172-18-14-130.ec2.internal  Readiness probe failed: sh: cannot set terminal process group (-1): Inappropriate ioctl for device
sh: no job control in this shell
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)


Actual results:
Readiness probe failed

Expected results:
Readiness probe should success

Additional info:
There is same upstream issue: https://github.com/kubernetes-incubator/cri-o/issues/918

Comment 1 DeShuai Ma 2018-02-26 09:46:01 UTC
Created attachment 1400799 [details]
pod.yaml

Comment 2 DeShuai Ma 2018-02-26 09:46:35 UTC
Created attachment 1400800 [details]
config.json

Comment 3 Mrunal Patel 2018-02-26 17:23:50 UTC
I see that -i is passed to the Readiness sh command. Is that required? Can we try w/o the -i? Else we would have to ensure that the exec code sets terminal to true. 

Readiness:  exec [/bin/sh -i -c MYSQL_PWD='YlOSByUhBxOYYK70' mysql -h 127.0.0.1 -u cakephp -D default -e 'SELECT 1'] delay=5s timeout=1s period=10s #success=1 #failure=3

Comment 4 DeShuai Ma 2018-02-27 08:05:14 UTC
(In reply to Mrunal Patel from comment #3)
> I see that -i is passed to the Readiness sh command. Is that required? Can
> we try w/o the -i? Else we would have to ensure that the exec code sets
> terminal to true. 
> 
> Readiness:  exec [/bin/sh -i -c MYSQL_PWD='YlOSByUhBxOYYK70' mysql -h
> 127.0.0.1 -u cakephp -D default -e 'SELECT 1'] delay=5s timeout=1s
> period=10s #success=1 #failure=3

1) The '-i' is added in our ocp provided template file (https://github.com/openshift/openshift-ansible/blob/master/roles/openshift_examples/files/examples/v3.9/quickstart-templates/cakephp-mysql.json#L393), if you think this need remove, we can let developer experience team update it.

2) I have tried remove it, the readiness still fail. 
[root@ip-172-18-9-9 ~]# oc describe po mysql-2-sczl5
Name:           mysql-2-sczl5
Namespace:      dma
Node:           ip-172-18-9-9.ec2.internal/172.18.9.9
Start Time:     Tue, 27 Feb 2018 02:57:05 -0500
Labels:         deployment=mysql-2
                deploymentconfig=mysql
                name=mysql
Annotations:    openshift.io/deployment-config.latest-version=2
                openshift.io/deployment-config.name=mysql
                openshift.io/deployment.name=mysql-2
                openshift.io/scc=restricted
Status:         Running
IP:             10.129.0.33
Controlled By:  ReplicationController/mysql-2
Containers:
  mysql:
    Container ID:   cri-o://ce8145f7adf89c7bc879957c9854ba312eb7ac9fdace45628003f92fd182b4eb
    Image:          registry.access.redhat.com/rhscl/mysql-57-rhel7@sha256:7638d886370ca1eb3cefcfecf483f8dc4dc1ca05559dd521d1585ae7c4ed668e
    Image ID:       registry.access.redhat.com/rhscl/mysql-57-rhel7@sha256:7638d886370ca1eb3cefcfecf483f8dc4dc1ca05559dd521d1585ae7c4ed668e
    Port:           3306/TCP
    State:          Running
      Started:      Tue, 27 Feb 2018 02:57:12 -0500
    Ready:          False
    Restart Count:  0
    Limits:
      memory:  512Mi
    Requests:
      memory:   512Mi
    Liveness:   tcp-socket :3306 delay=30s timeout=1s period=10s #success=1 #failure=3
    Readiness:  exec [/bin/sh -c MYSQL_PWD='4SPCQRPYjynTYK4S' mysql -h 127.0.0.1 -u cakephp -D default -e 'SELECT 1'] delay=5s timeout=1s period=10s #success=1 #failure=3
    Environment:
      MYSQL_USER:      <set to the key 'database-user' in secret 'cakephp-mysql-example'>      Optional: false
      MYSQL_PASSWORD:  <set to the key 'database-password' in secret 'cakephp-mysql-example'>  Optional: false
      MYSQL_DATABASE:  default
    Mounts:
      /var/lib/mysql/data from data (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-jhqng (ro)
Conditions:
  Type           Status
  Initialized    True 
  Ready          False 
  PodScheduled   True 
Volumes:
  data:
    Type:    EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:  
  default-token-jhqng:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-jhqng
    Optional:    false
QoS Class:       Burstable
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/memory-pressure:NoSchedule
Events:
  Type     Reason                 Age               From                                 Message
  ----     ------                 ----              ----                                 -------
  Normal   Scheduled              1m                default-scheduler                    Successfully assigned mysql-2-sczl5 to ip-172-18-9-9.ec2.internal
  Normal   SuccessfulMountVolume  1m                kubelet, ip-172-18-9-9.ec2.internal  MountVolume.SetUp succeeded for volume "data"
  Normal   SuccessfulMountVolume  1m                kubelet, ip-172-18-9-9.ec2.internal  MountVolume.SetUp succeeded for volume "default-token-jhqng"
  Normal   Pulled                 1m                kubelet, ip-172-18-9-9.ec2.internal  Container image "registry.access.redhat.com/rhscl/mysql-57-rhel7@sha256:7638d886370ca1eb3cefcfecf483f8dc4dc1ca05559dd521d1585ae7c4ed668e" already present on machine
  Normal   Created                1m                kubelet, ip-172-18-9-9.ec2.internal  Created container
  Normal   Started                1m                kubelet, ip-172-18-9-9.ec2.internal  Started container
  Warning  Unhealthy              7s (x10 over 1m)  kubelet, ip-172-18-9-9.ec2.internal  Readiness probe failed: /bin/sh: mysql: command not found

Comment 5 DeShuai Ma 2018-02-27 08:06:27 UTC
(In reply to Mrunal Patel from comment #3)
> I see that -i is passed to the Readiness sh command. Is that required? Can
> we try w/o the -i? Else we would have to ensure that the exec code sets
> terminal to true. 
> 
> Readiness:  exec [/bin/sh -i -c MYSQL_PWD='YlOSByUhBxOYYK70' mysql -h
> 127.0.0.1 -u cakephp -D default -e 'SELECT 1'] delay=5s timeout=1s
> period=10s #success=1 #failure=3

How ensure that the exec code sets terminal to true?

Comment 6 Antonio Murdaca 2018-02-27 16:39:31 UTC
That error happens because "/bin/sh" w/o "-i" is not reading from $PATH at all actually:

       When  bash  is  started non-interactively, to run a shell script, for example, it looks for the variable BASH_ENV in
       the environment, expands its value if it appears there, and uses the expanded value as the name of a  file  to  read
       and execute.  Bash behaves as if the following command were executed:
              if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
       but the value of the PATH variable is not used to search for the filename.


docker behaves the same, that's why we have "-i -c" in /bin/sh :(

docker run busybox /bin/sh ls -la
/bin/sh: can't open 'ls': No such file or directory

Comment 7 Mrunal Patel 2018-02-27 17:58:51 UTC
Can we give full path to mysql binary in the command?

Comment 8 Antonio Murdaca 2018-02-28 15:53:25 UTC
Should be fixed by https://github.com/kubernetes-incubator/cri-o/pull/1386

Comment 9 DeShuai Ma 2018-03-06 03:09:23 UTC
The pr inc comment 8 is merged in 1.9.8; but I have test this in ocp, still same error.

openshift v3.9.2
kubernetes v1.9.1+a0ce1bc657
etcd 3.2.16
crio version 1.9.8

[root@ip-172-18-0-131 ~]# openshift version
openshift v3.9.2
kubernetes v1.9.1+a0ce1bc657
etcd 3.2.16
[root@ip-172-18-0-131 ~]# oc describe po mysql-1-sjcdh -n dma
Name:           mysql-1-sjcdh
Namespace:      dma
Node:           ip-172-18-0-131.ec2.internal/172.18.0.131
Start Time:     Mon, 05 Mar 2018 22:02:32 -0500
Labels:         deployment=mysql-1
                deploymentconfig=mysql
                name=mysql
Annotations:    openshift.io/deployment-config.latest-version=1
                openshift.io/deployment-config.name=mysql
                openshift.io/deployment.name=mysql-1
                openshift.io/scc=restricted
Status:         Running
IP:             10.129.0.12
Controlled By:  ReplicationController/mysql-1
Containers:
  mysql:
    Container ID:   cri-o://19fa75129b28ef3642bce38b097bb6bf3a63309651077b19c596aaa08a8ffe21
    Image:          registry.access.redhat.com/rhscl/mysql-57-rhel7@sha256:7638d886370ca1eb3cefcfecf483f8dc4dc1ca05559dd521d1585ae7c4ed668e
    Image ID:       registry.access.redhat.com/rhscl/mysql-57-rhel7@sha256:7638d886370ca1eb3cefcfecf483f8dc4dc1ca05559dd521d1585ae7c4ed668e
    Port:           3306/TCP
    State:          Running
      Started:      Mon, 05 Mar 2018 22:03:47 -0500
    Ready:          True
    Restart Count:  0
    Limits:
      memory:  512Mi
    Requests:
      memory:   512Mi
    Liveness:   tcp-socket :3306 delay=30s timeout=1s period=10s #success=1 #failure=3
    Readiness:  exec [/bin/sh -i -c MYSQL_PWD='QynympECNaaI0I0h' mysql -h 127.0.0.1 -u cakephp -D default -e 'SELECT 1'] delay=5s timeout=1s period=10s #success=1 #failure=3
    Environment:
      MYSQL_USER:      <set to the key 'database-user' in secret 'cakephp-mysql-example'>      Optional: false
      MYSQL_PASSWORD:  <set to the key 'database-password' in secret 'cakephp-mysql-example'>  Optional: false
      MYSQL_DATABASE:  default
    Mounts:
      /var/lib/mysql/data from data (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-bcxmz (ro)
Conditions:
  Type           Status
  Initialized    True 
  Ready          True 
  PodScheduled   True 
Volumes:
  data:
    Type:    EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:  
  default-token-bcxmz:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-bcxmz
    Optional:    false
QoS Class:       Burstable
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/memory-pressure:NoSchedule
Events:
  Type     Reason                 Age              From                                   Message
  ----     ------                 ----             ----                                   -------
  Normal   Scheduled              6m               default-scheduler                      Successfully assigned mysql-1-sjcdh to ip-172-18-0-131.ec2.internal
  Normal   SuccessfulMountVolume  6m               kubelet, ip-172-18-0-131.ec2.internal  MountVolume.SetUp succeeded for volume "data"
  Normal   SuccessfulMountVolume  6m               kubelet, ip-172-18-0-131.ec2.internal  MountVolume.SetUp succeeded for volume "default-token-bcxmz"
  Normal   Pulling                6m               kubelet, ip-172-18-0-131.ec2.internal  pulling image "registry.access.redhat.com/rhscl/mysql-57-rhel7@sha256:7638d886370ca1eb3cefcfecf483f8dc4dc1ca05559dd521d1585ae7c4ed668e"
  Normal   Pulled                 4m               kubelet, ip-172-18-0-131.ec2.internal  Successfully pulled image "registry.access.redhat.com/rhscl/mysql-57-rhel7@sha256:7638d886370ca1eb3cefcfecf483f8dc4dc1ca05559dd521d1585ae7c4ed668e"
  Normal   Created                4m               kubelet, ip-172-18-0-131.ec2.internal  Created container
  Normal   Started                4m               kubelet, ip-172-18-0-131.ec2.internal  Started container
  Warning  Unhealthy              4m (x3 over 4m)  kubelet, ip-172-18-0-131.ec2.internal  Readiness probe failed: sh: cannot set terminal process group (-1): Inappropriate ioctl for device
sh: no job control in this shell
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)

Comment 10 Mrunal Patel 2018-03-06 23:07:29 UTC
I am unable to reproduce this issue? Can I access the test environment?

Comment 11 Wenjing Zheng 2018-04-27 07:04:01 UTC
I can reproduce this issue with 3.10 crio env:
openshift v3.10.0-0.29.0
kubernetes v1.10.0+b81c8f8
etcd 3.2.16

Normal   Created                11m   kubelet, host-172-16-120-115  Created container
  Normal   Started                11m   kubelet, host-172-16-120-115  Started container
  Warning  Unhealthy              11m   kubelet, host-172-16-120-115  Readiness probe failed: sh: cannot set terminal process group (-1): Inappropriate ioctl for device
sh: no job control in this shell
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)

Comment 12 Wenjing Zheng 2018-04-27 08:59:19 UTC
Also met this issue when test with mongodb:
 Warning  Unhealthy              6m    kubelet, host-172-16-120-115  Readiness probe failed: MongoDB shell version: 3.2.10
connecting to: 127.0.0.1:27017/sampledb
2018-04-27T08:51:45.407+0000 I NETWORK  [thread1] Socket recv() errno:104 Connection reset by peer 127.0.0.1:27017
2018-04-27T08:51:45.408+0000 I NETWORK  [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [127.0.0.1:27017] 
2018-04-27T08:51:45.408+0000 E QUERY    [thread1] Error: network error while attempting to run command 'isMaster' on host '127.0.0.1:27017'  :
connect@src/mongo/shell/mongo.js:231:14
@(connect):1:6

sh: cannot set terminal process group (-1): Inappropriate ioctl for device
sh: no job control in this shell
exception: connect failed

Comment 13 Antonio Murdaca 2018-05-21 09:31:41 UTC
Can I try and access the test environment to test this out myself and verify versions?

Comment 14 Mrunal Patel 2018-05-21 23:30:25 UTC
Wenjing,
Is the the readiness probe consistent? I have seen it fail only once while bring up sometimes while the mysqld is still coming up. Even then subsequent probes are successful and the pod is in Ready state.

Comment 15 Mrunal Patel 2018-05-21 23:31:11 UTC
Wenjing,
Is the readiness probe failure consistently happening for the same pod? I have seen it fail only once while bring up sometimes while the mysqld is still coming up which could happen if mysql takes time to come up. Even then subsequent probes are successful and the pod is in Ready state.

Comment 16 Wenjing Zheng 2018-05-23 07:23:57 UTC
(In reply to Mrunal Patel from comment #15)
> Wenjing,
> Is the readiness probe failure consistently happening for the same pod? I
> have seen it fail only once while bring up sometimes while the mysqld is
> still coming up which could happen if mysql takes time to come up. Even then
> subsequent probes are successful and the pod is in Ready state.

I cannot reproduce with openshift v3.10.0-0.50.0 now.

Comment 17 Mrunal Patel 2018-05-23 21:45:21 UTC
Thanks! Can we close the bug then?

Comment 18 DeShuai Ma 2018-05-28 02:50:01 UTC
As comment 16, move this bug to verified, when reproduce will reopen. Thanks.

Comment 19 Daein Park 2018-06-13 07:47:46 UTC
This can be reproduced on v3.9, and Red Hat SSO template with PostgreSQL also  was affected by this on OCP.

Does it have workaround except disabling readiness ?

~~~
6m          6m           3         redhat-sso-postgresql-1-wzpfc.1537a79cbe991085    Pod                     spec.containers{redhat-sso-postgresql}   Warning   Unhealthy               kubelet, node1s.ocp39.host.local   Readiness probe failed: sh: cannot set terminal process group (-1): Inappropriate ioctl for device
sh: no job control in this shell
psql: could not connect to server: Connection refused
          Is the server running on host "127.0.0.1" and accepting
          TCP/IP connections on port 5432?

~~~

Comment 20 DeShuai Ma 2018-06-13 08:06:03 UTC
reopen, as someone reproduce on 3.9

Comment 24 Antonio Murdaca 2018-06-13 10:53:54 UTC
Can you file another BZ for docker and close this one please as it was verified against CRI-O?

Comment 25 Daein Park 2018-06-13 11:18:44 UTC
Sure I've reported as new BZ[0], and you can close this BZ.

[0][https://bugzilla.redhat.com/show_bug.cgi?id=1590762]