Bug 803581 - active_capacity factor maybe a negative number when turn on CREATE_APP_SYMLINKS flag.
Summary: active_capacity factor maybe a negative number when turn on CREATE_APP_SYMLIN...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: Containers
Version: 1.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Dan McPherson
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-03-15 06:38 UTC by Johnny Liu
Modified: 2012-03-19 18:22 UTC (History)
0 users

Fixed In Version: rhc-node-0.88.8
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-03-19 18:22:36 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Johnny Liu 2012-03-15 06:38:45 UTC
Description of problem:
Set CREATE_APP_SYMLINKS=1, create app, stop or idle it, then run the following command:
# mc-facts active_capacity
Report for fact: active_capacity

        -2.0                                    found 1 times
        0.0                                     found 2 times

Finished processing 3 / 3 hosts in 114.90 ms


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

How reproducible:
Always

Steps to Reproduce:
1. Log into instance, make sure CREATE_APP_SYMLINKS=1 in stickshift-node.conf
2. Create an app, stop or idle it.
3. Run the following command in instance.
# mc-facts active_capacity
  
Actual results:
active_capacity factor is a negative number.

# mc-facts active_capacity
Report for fact: active_capacity

        -2.0                                    found 1 times
        0.0                                     found 2 times


Expected results:
active_capacity factor should NOT be a negative number.

Additional info:
The root cause is the logic error in <li.repo>/node/facter/libra.rb:
Facter.add(:active_capacity) do
    git_repos =  Facter.value(:git_repos).to_f
    max_active_apps = Facter.value(:max_active_apps).to_f
    stopped_app_count = 0
    Dir.glob("/var/lib/stickshift/*").each { |app_dir|
        if File.directory?(app_dir)
            active = true
            Dir.glob(File.join(app_dir, '*', 'runtime', '.state')).each {|file|
                state = File.read(file).chomp
                if 'idle' == state || 'stopped' == state
                    active = false
                end
            }
            if not active
                stopped_app_count += 1
            end
        end
    }
    active_capacity = ( (git_repos - stopped_app_count) / max_active_apps ) * 100
    setcode { active_capacity.to_s }
end


If symlink file is created in /var/lib/stickshift/ as following,
[root@ip-10-72-238-117 stickshift]# ll
total 4
drwxr-x---. 8 root e7e4c375aba54abc98cef4c445d8226b 4096 Mar 15 01:10 e7e4c375aba54abc98cef4c445d8226b
-rw-r--r--. 1 root root                                0 Mar 15 02:00 last_access.log
lrwxrwxrwx. 1 root root                               52 Mar 15 02:16 phptest-jialiu -> /var/lib/stickshift/e7e4c375aba54abc98cef4c445d8226b

one app will be counted twice, it is a duplicate counting, but for git_repos factor, factor only count one app for one time.

Comment 1 Johnny Liu 2012-03-19 11:27:38 UTC
Verified this bug with devenv_stage_146, and PASS.


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