Bug 769995

Summary: ProcessInfo in resource context never refreshes
Product: [Other] RHQ Project Reporter: Charles Crouch <ccrouch>
Component: AgentAssignee: RHQ Project Maintainer <rhq-maint>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: high Docs Contact:
Priority: high    
Version: 3.0.1CC: hbrock, hrupp, lkrejci, mazz
Target Milestone: ---   
Target Release: JON 2.4.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 700461 Environment:
Last Closed: 2011-12-22 23:11:01 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Charles Crouch 2011-12-22 23:10:31 UTC
+++ This bug was initially created as a clone of Bug #700461 +++

Description of problem:

the ResourceContext instance the plugins can use to get info about, well, the context the resource component is running in contains the getNativeProcess() method which should contain the information about the current native process of the native resource.

This process information should be refreshed whenever the process is found not running, i.e. we should transparently handle process restarts.

If the process of the resource is restarted outside of agent control, the process info never refreshes and the component therefore has stale info.

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

How reproducible:
always

Steps to Reproduce:
1. discover and inventory an apache instance
2. Check the pid reported by the resourceContext.getNativeProcess().getPid()
3. restart apache from commandline, while the agent is running
4. repeat 2.
  
Actual results:
The pid reported in 2. and 4. is the same

Expected results:
4. should report the pid of the new apache process

Additional info:

This is not explicitly testable in any other way than by actually debugging the code, so QA will not be able to test this.

--- Additional comment from mazz on 2011-04-28 10:52:27 EDT ---

this has been an issue for at least 3 years :) From our initial git commit back in Feb 2008, you'll see this:

    public ProcessInfo getNativeProcess() {
        if ((this.processInfo == null) || !this.processInfo.isRunning()) {
            // TODO: should we null out processInfo?  if it isn't running, the old processInfo is no longer valid

The TODO shows that we knew this might be an issue. I remember talking about this issue a long time ago - not sure if we did anything about it (apparently, we didn't).

But, this would be the area that we'd have to touch to correct this (ResourceContext.java)

--- Additional comment from lkrejci on 2011-04-28 14:21:36 EDT ---

Well, the actual issue is that "this.processInfo.isRunning()" returns true even if the process no longer exists...

We need a call to processInfo.refresh() in the ResourceContext.getNativeProcess() to refresh that info.

--- Additional comment from lkrejci on 2011-05-06 11:13:11 EDT ---

Fixed in the release-3.0.1 branch:

commit e59a0a42b5447a44b0a89f2a836d5750a39f3b6b
Author: Lukas Krejci <lkrejci>
Date:   Fri Apr 29 19:12:27 2011 +0200

    BZ 700461 - ResourceContext.getNativeProcess() now always reports the current process info or null if no process exists for given resource.

--- Additional comment from mfoley on 2011-06-10 09:05:51 EDT ---

per comment #1, this is untestable.

Comment 1 Charles Crouch 2011-12-22 23:11:01 UTC
Closing, as this is not verifiable by QE