Bug 1116135 - Use of "pgrep -F" in the bash SDK is unreliable
Summary: Use of "pgrep -F" in the bash SDK is unreliable
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Containers
Version: 1.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 2.x
Assignee: Jhon Honce
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks: 1117004
TreeView+ depends on / blocked
 
Reported: 2014-07-03 20:22 UTC by Andy Grimm
Modified: 2016-11-08 03:47 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1117004 (view as bug list)
Environment:
Last Closed: 2014-10-10 00:48:16 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Andy Grimm 2014-07-03 20:22:49 UTC
Description of problem:

The process_running function in node/misc/usr/lib/cartridge_sdk/bash/sdk uses "pgrep -F" to determine whether a cartridge's processes are running.  The problem is that with this option, pgrep checks for these PIDs by traversing /proc.  It turns out that if another gear has a process with the pid being checked, pgrep -F will find it.  As a result, if gear A has a stale pidfile containing a pid matching a long-running process belonging to gear B, gear B will effectively prevent gear A from running, unless the owner knows to go remove the stale pid file.

Version-Release number of selected component (if applicable):

rubygem-openshift-origin-node-1.26.8-1.el6oso.noarch

How reproducible:

Easily

Steps to Reproduce:
1. rhc app create bztest nodejs-0.10 postgresql-9.2
2. rhc app stop
3. rhc ssh bztest
4. look in /proc for a process belonging to another gear (referred to below as $PID)
5. echo $PID > postgresql/pid/postgres.pid
6. gear start

Actual results:

start will fail for postgres with code 70

Expected results:

start should succeed

Comment 1 Jhon Honce 2014-07-07 17:04:34 UTC
Fixed in https://github.com/openshift/origin-server/pull/5575

Comment 2 openshift-github-bot 2014-07-07 17:54:29 UTC
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/16eb8a6e98def5a8c830757ad9fa9c0a3a3b4afe
Bug 1116135 - Add -u to bash sdk pgrep calls

* Since gears can "see" another gears pid files in the /proc filesystem,
  a stale pid file could block a cartridge from starting via the check
  in sdk#process_running()

Comment 3 Meng Bo 2014-07-08 03:35:52 UTC
Checked on devenv_4944, issue has been fixed.

cartridge pid file contains pid owned by other user will not block the gear start.


Note You need to log in before you can comment on or make changes to this bug.