Uploaded image for project: 'OpenVZ'
  1. OpenVZ
  2. OVZ-4181

line 200: echo: write error: Broken pipe while restarting OpenVZ

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Fix Version/s: OpenVZ-legacy
    • Component/s: Containers::Userspace
    • Security Level: Public
    • Environment:
      Operating System: RHEL/CentOS 5
      Platform: x86_64 (AMD64)

      Description

      node = ts27 (x86_64)
      kernel = 2.6.18-92.1.13.el5.028stab059.1 #1 SMP Tue Sep 30 21:58:19 MSD 2008
      vzctl-lib-3.0.22-1
      vzctl-3.0.22-1
      bash-3.2-21.el5
      grep-2.5.1-54.2.el5

      1. Restarted OpenVZ and got this "error: Broken pipe":
      [root@ts27 ~]# /sbin/service vz restart
      Stopping OpenVZ: [ OK ]
      /etc/init.d/vz: line 200: echo: write error: Broken pipe
      /etc/init.d/vz: line 200: echo: write error: Broken pipe
      Starting OpenVZ: [ OK ]
      Bringing up interface venet0: [ OK ]
      Configuring interface venet0: [ OK ]

      2. This is the piece of /etc/init.d/vz, line 200 is marked:


      {
              test -r /proc/config.gz || return 0

              local conf opt err=0
              local opt_must="SIM_FS VE VE_CALLS VZ_GENCALLS"
              get_kernel_version
              # For kernels >= 2.6.9 VZ_DEV must be set.
              test "${KERNEL_MINOR}" -ge 6 &&
                      test "${KERNEL_PATCHLEVEL}" -gt 9 &&
                              opt_must="${opt_must} VZ_DEV"
              local opt_rec="SCHED_VCPU FAIRSCHED VZ_QUOTA VZ_QUOTA_UGID VE_NETDEV VE_ETHDEV
                              VE_IPTABLES VZ_CHECKPOINT VZ_WDOG"

              conf="`zcat /proc/config.gz 2>/dev/null | grep -E -v '^#|^$'`"

              for opt in $opt_must; do
                      if ! echo "${conf}" | grep -q "${opt}="; then # <-- LINE 200
                              echo "ERROR: Missing kernel config option: CONFIG_$opt"
                              err=1
                      fi
              done
              if [ $err != 0 ]; then
                      print_failure "Please recompile your kernel."
                      exit 1
              fi
      }

      3. This bug doesn't reproduces each time when OpenVZ is restarted, but it does pretty often, say 3 times out of 5.

        Activity

        Hide
        igor Igor Sukhih added a comment -

        The size of 'zcat /proc/config.gz 2>/dev/null | grep -E -v '#|$'`'
        about 40K, looks like bash has some problem with such huge variable.
        Proposed fix is:

        • if ! echo "$ {conf}

          " | grep -q "$

          {opt}="; then
          + if ! zcat /proc/config.gz 2>/dev/null | grep -E -v '#|$' | grep -q "${opt}

          ="; then

        Show
        igor Igor Sukhih added a comment - The size of 'zcat /proc/config.gz 2>/dev/null | grep -E -v ' #| $'`' about 40K, looks like bash has some problem with such huge variable. Proposed fix is: if ! echo "$ {conf} " | grep -q "$ {opt}="; then + if ! zcat /proc/config.gz 2>/dev/null | grep -E -v ' #| $' | grep -q "${opt} ="; then
        Hide
        kir Kir Kolyshkin added a comment -

        (In reply to comment #1)
        > looks like bash has some problem with such huge variable.

        Not at all. I tried using longer variables and it all went fine.

        The exact problem here is grep -q exits immediately when it finds the first match,
        so sending side of the pipe receives SIGPIPE. If that would be say /bin/echo
        then it would exit too and everything will be OK. But since built-in echo
        from bash is used it is bash who is receiving SIGPIPE.

        Apparently bash can't realise that this SIGPIPE refers to echo and thus echo
        should stop trying to write to the pipe. So, echo calls another write()
        and gets EPIPE. This is the error bash reports about.

        Possible solutions are
        (1) as Igor suggested, run zcat a few times. zcat is a program (not built-in) which will react to SIGPIPE the way it should (i.e. exit).
        (2) use /bin/echo program instead of built-in. It will also react to SIGPIPE in a correct way.
        (3) just redirect echo stderr to /dev/null, suppressing the 'write failed' error which in this very case is perfectly normal.

        I do not like solution (1) since it slows down the process. Solution (2) is fine, but I like (3) even better.

        Show
        kir Kir Kolyshkin added a comment - (In reply to comment #1) > looks like bash has some problem with such huge variable. Not at all. I tried using longer variables and it all went fine. The exact problem here is grep -q exits immediately when it finds the first match, so sending side of the pipe receives SIGPIPE. If that would be say /bin/echo then it would exit too and everything will be OK. But since built-in echo from bash is used it is bash who is receiving SIGPIPE. Apparently bash can't realise that this SIGPIPE refers to echo and thus echo should stop trying to write to the pipe. So, echo calls another write() and gets EPIPE. This is the error bash reports about. Possible solutions are (1) as Igor suggested, run zcat a few times. zcat is a program (not built-in) which will react to SIGPIPE the way it should (i.e. exit). (2) use /bin/echo program instead of built-in. It will also react to SIGPIPE in a correct way. (3) just redirect echo stderr to /dev/null, suppressing the 'write failed' error which in this very case is perfectly normal. I do not like solution (1) since it slows down the process. Solution (2) is fine, but I like (3) even better.
        Hide
        kir Kir Kolyshkin added a comment -
        Show
        kir Kir Kolyshkin added a comment - fixed in git http://git.openvz.org/?p=vzctl;a=commit;h=79f91681e87b352a7511f52283105295c6e3a258 will be available in vzctl >= 3.0.23
        Hide
        sergeyb Sergey Bronnikov (Inactive) added a comment -

        Bug was fixed more than one year ago and there were no complains from reporter after fix. We believe bug fix helped and mark bug as closed.

        Show
        sergeyb Sergey Bronnikov (Inactive) added a comment - Bug was fixed more than one year ago and there were no complains from reporter after fix. We believe bug fix helped and mark bug as closed.

          People

          • Assignee:
            kir Kir Kolyshkin
            Reporter:
            shams@openvz.org Lesya Novaselskaya
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: