Bug 1284417
| Summary: | Python PMAPI pmSetMode does not allow None timeval | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Marko Myllynen <myllynen> | ||||
| Component: | pcp | Assignee: | Nathan Scott <nathans> | ||||
| Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||
| Severity: | unspecified | Docs Contact: | |||||
| Priority: | unspecified | ||||||
| Version: | 23 | CC: | brolley, fche, lberk, mgoodwin, nathans, pcp, scox | ||||
| Target Milestone: | --- | Keywords: | Reopened | ||||
| Target Release: | --- | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | pcp-3.10.9-1.fc23 pcp-3.10.9-1.fc22 pcp-3.11.1-1.el5 | Doc Type: | Bug Fix | ||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2016-04-06 14:55:24 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: |
|
||||||
If I'm reading the ctypes docs correctly, the patch below should work ... could you try it out Marko, if you have a use-case for this already?
cheers.
diff --git a/src/python/pcp/pmapi.py b/src/python/pcp/pmapi.py
index f9805a7..b3f126b 100644
--- a/src/python/pcp/pmapi.py
+++ b/src/python/pcp/pmapi.py
@@ -1551,7 +1551,10 @@ class pmContext(object):
status = LIBPCP.pmUseContext(self.ctx)
if status < 0:
raise pmErr(status)
- status = LIBPCP.pmSetMode(mode, pointer(timeVal), delta)
+ when = None
+ if timeVal != None:
+ when = pointer(timeVal)
+ status = LIBPCP.pmSetMode(mode, when, delta)
if status < 0:
raise pmErr(status)
return status
Thanks, I tested the change and it seems to work in that sense that my test code runs. I see only one in-tree user pmSetMode(PM_MODE_FORW, NULL, 0) (src/pmlogreduce/scan.c) but I'm not yet sure would this be useful elsewhere.
However, there's also one case where the man pages could be clarified a bit:
The pmSetMode(1) man page states:
...
As a special case, if when is NULL then the mode and delta arguments
are used as described above, but the current time in the archive is not
altered.
...
The pmFetchArchive(1) man page states:
...
The result is instantiated with all of the metrics (and instances) from
the next archive record, consequently there is no notion of a list of
desired metrics, and the instance profile of the PMAPI context is
ignored.
...
But with code like:
...
self.context.pmSetMode(c_api.PM_MODE_FORW, None, 0)
while self.context.type == c_api.PM_CONTEXT_ARCHIVE and True:
result = self.context.pmFetchArchive()
print "Fetch @ " + str(result.contents.timestamp)
...
I see:
...
$ python ~/pmapi-test.py -a pVZ3Sj.localhost
Fetch @ 1448379062.065
Fetch @ 1448379064.064
Fetch @ 1448379066.065
...
Based on the above quotes from pmSetMode(1) and pmFetchArchive(1) I was perhaps expecting 1448379062.065 being printed repeatedly here.
I'll attach the test archive and the crude test script just in case (I see the same behaviour with both pmFetch() pmFetchArchive()).
Thanks.
Created attachment 1098255 [details]
test.tar.gz
(In reply to Marko Myllynen from comment #2) > > However, there's also one case where the man pages could be clarified a bit: > > Based on the above quotes from pmSetMode(1) and pmFetchArchive(1) I was > perhaps expecting 1448379062.065 being printed repeatedly here. Err, nevermind, I completely misunderstood/misread the pages; pmSetMode with NULL timeval doesn't alter the time during pmSetMode() call, of course pmFetchArchive() then moves it to the next record according to the mode set earlier by pmSetMode(). So no additional changes needed here. Thanks. Fixed upstream, will be in pcp-3.10.9. pcp-3.10.9-1.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2015-d08245c076 pcp-3.10.9-1.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2015-2b40815137 pcp-3.10.9-1.el5 has been submitted as an update to Fedora EPEL 5. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2015-2ac90519bc pcp-3.10.9-1.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report. If you want to test the update, you can install it with $ su -c 'dnf --enablerepo=updates-testing update pcp' You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-2b40815137 pcp-3.10.9-1.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report. If you want to test the update, you can install it with $ su -c 'dnf --enablerepo=updates-testing update pcp' You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-d08245c076 pcp-3.10.9-1.el5 has been pushed to the Fedora EPEL 5 testing repository. If problems still persist, please make note of it in this bug report. If you want to test the update, you can install it with $ su -c 'yum --enablerepo=epel-testing update pcp' You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2015-2ac90519bc pcp-3.10.9-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report. pcp-3.10.9-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report. pcp-3.11.0-1.el5 has been submitted as an update to Fedora EPEL 5. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-57b7efb2d7 pcp-3.11.0-1.el5 has been pushed to the Fedora EPEL 5 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-57b7efb2d7 pcp-3.11.1-1.el5 has been pushed to the Fedora EPEL 5 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-5b519318e0 pcp-3.11.1-1.el5 has been pushed to the Fedora EPEL 5 stable repository. If problems still persist, please make note of it in this bug report. |
Description of problem: From pmSetMode(1): ... int pmSetMode(int mode, const struct timeval *when, int delta); ... As a special case, if when is NULL then the mode and delta arguments are used as described above, but the current time in the archive is not altered. ... But the Python pmSetMode does not allow this: ... def pmSetMode(self, mode, timeVal, delta): """PMAPI - set interpolation mode for reading archive files code = pmSetMode(c_api.PM_MODE_INTERP, timeval, 0) """ status = LIBPCP.pmUseContext(self.ctx) if status < 0: raise pmErr(status) status = LIBPCP.pmSetMode(mode, pointer(timeVal), delta) if status < 0: raise pmErr(status) return status ...