Repository navigation
Conversation
When use_smapi is false, collect QUERY ALLOC PAGE and QUERY ALLOC SPOOL on the existing host-info request and return total, used, available, percent used, and per-extent detail. Each command is one vmcp invocation with --buffer=256K. Results, including a failure such as a missing class D privilege, are reused for alloc_cache_seconds (default 60). A lock covers the refresh. There is no background thread, so repeated host-info calls do not issue a CP command on every request. A missing privilege is a warning and does not fail host info. Signed-off-by: Manuel Cabiya <ca6iya@users.noreply.github.com>
Use time.monotonic for the QUERY ALLOC cache so a wall-clock step does not keep a stale sample. When CP omits SUMMARY and an extent that is not shared or not-found has no total or used count, leave the host totals unset instead of summing the extents that did parse. Signed-off-by: Manuel Cabiya <ca6iya@users.noreply.github.com>
Pass a 5 second timeout only for the optional allocation commands so a hung vmcp cannot hold the host-info cache lock. Other _run callers are unchanged. A timeout is a warning, returns no data, and leaves the request results as they were. Signed-off-by: Manuel Cabiya <ca6iya@users.noreply.github.com>
The second call after a timeout must fail the test if QUERY ALLOC runs again. _run would otherwise swallow an AssertionError and the cached None result would still look like a pass. Signed-off-by: Manuel Cabiya <ca6iya@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Paging and spool allocation are capacity numbers CP already reports but most monitoring tools don't surface. On current z/VM systems, running out of either is rare, so the goal here is visibility and trending rather than outage prevention: spool grows quietly with dumps and leftover files, and paging use rises as guests are overcommitted. (For reference, CP warns at 90% full with HCP401I, and only when paging and spool are both exhausted does it take abend PGT004.) Monitoring tools and exporters need these values when Feilong runs with
use_smapi=Falseand can't ask SMAPI. This adds them to the VMCP host-info path from #983.The commands go through the existing
VMCPHandler._runand do not set a timeout of their own, so they stay compatible with #992 (configurable VMCP timeouts, still open). Once #992 merges, these queries use its generalvmcp_timeout_seconds(default 240s). There is no second timeout implementation.Commands
Issued only from the existing host-info request, and only when
use_smapiis False:QUERY ALLOC PAGE(IBM-defined CP privilege class D) — total, used, available, and percent used for paging space, plus per-extent detail from the same output.QUERY ALLOC SPOOL(IBM-defined CP privilege class D) — total, used, available, and percent used for spool space, plus per-extent detail.One
vmcpinvocation per query. The invocation passes--buffer=256K. vmcp's default response buffer is 8 KB (8192 bytes). When a response is larger, vmcp prints only the first 8 KB and exits with return code 2, and a system with many paging or spool extents can exceed that. 256 KB, within vmcp's 4 KB to 1 MB range, caps the response.The parsed result, including a failure such as a missing class D privilege, is cached in the Feilong process for
alloc_cache_seconds(default 60). Repeated host-info calls within that interval reuse the last sample and do not issue another CP command. A lock covers the refresh so overlapping calls share one pair of commands. There is no background thread. Callers that need a new sample should not poll host info faster than the TTL. Setalloc_cache_secondsto 0 to query on every host-info call.New host-info fields
Returned by SDK
host_get_infoandGET /host. Counts are 4 KB pages, exceptextent_startandextent_end, which are cylinder numbers on CKD volumes and page numbers on FBA volumes, as CP reports them. Each count is null, and each volume list is null, when the data was not collected (SMAPI mode, missing class D, vmcp missing, or unparsable output). Host info still succeeds in that case.paging_totalpaging_usedpaging_availablepaging_total - paging_usedpaging_percent_usedpaging_volumesspool_totalspool_usedspool_availablespool_total - spool_usedspool_percent_usedspool_volumesEach extent dict has
volid,rdev,extent_start,extent_end,total,used,high,percent_used,draining,active,dump,shared, andnot_found.activereflects theACTflag, which CP shows for a PAGE extent that is actively draining. That flag comes with Active Drain for PAGE volumes (z/VM 7.4 APAR VM66891, and 7.5), and it is always false on earlier levels.With
use_smapi=True(the default) the commands are not issued and the fields are null.Privilege class
The guest that hosts Feilong needs CP privilege class D, the IBM-defined class for QUERY ALLOC, or whatever class the installation has assigned to it with MODIFY COMMAND. A general user with only class G is not authorized. CP interprets an unauthorized option only in the formats the user is authorized for, so such a guest typically gets
HCP003E Invalid option - ALLOCrather than a privilege-specific message. The other documented QUERY ALLOC errors areHCP013E(conflicting option) andHCP1002E(volume identifier does not exist). That is logged as a warning and does not fail the host-info request. The failure is cached for the same TTL, so the next host-info call withinalloc_cache_secondsdoes not repeat the CP command.Performance
vmcpcalls on a cache miss, each with a 256 KB output cap (--buffer=256K). Parsing is one pass over the lines (regex and split).alloc_cache_seconds(default 60). A lock serializes the refresh. Callers should not poll faster than that interval.Testing
vmcpcall. Fixtures follow the QUERY ALLOC response 2 layout in the CP Commands and Utilities Reference, which is the same for z/VM 7.2 through 7.5 apart from theACTflag added in 7.4: single volume, multi-volume with a continuation line, volid repeated on every extent (DIAGNOSE buffer / vmcp style), spool DUMP / SHARED / NOT FOUND, andKsuffix counts. Also covered: HCPxxx rejections such asHCP003E, vmcp unavailable, empty output, and garbled output. A privilege failure restores the request return code so host info is not failed.vmcpagain; a call after the TTL does; a failure (None) is kept for the TTL and is not retried early.python3 -m unittest discover -s smtLayer/tests/unit— 219 passed.python3 -m unittest discover -s zvmsdk/tests/unit— 1109 passed, 4 skipped (run before this cache commit; the cache change is covered by the smtLayer host-info tests).flake8with the repotox.inipep8 settings — passed.Parsing was validated against the documented sample layout, not against a live z/VM system. A check on a real z/VM 7.3 or 7.4 system would still be worthwhile, especially for abbreviated counts and a large number of paging volumes.
Assumptions
usableline excludes draining space and, for spool, dump-only space. CP prints these lines only when all volumes are queried, which is what these commands do. On an SSI member, spool volumes owned by another member appear asSHAREDwith no allocation data. Theusableline is recognized so it is not mistaken for an extent, and it is not returned as its own fields. Extent flags include draining and dump, so a caller can derive usable space.600K,10M, ...) are read as powers of 1024. The CP reference only says K, M, G, T, and P mean kilo through peta. 1024 matches published output, where a 10,016-cylinder 3390 page extent (1,802,880 pages) is shown as1761K. CP rounds abbreviated values, so they are approximate to the last digit.HCP003Eand not as a dedicated authorization error.OMP best-practices checklist
Checked against the Open Mainframe Project TAC repository recommendations as they apply to this contribution:
687f7ea55eca2f6e64cbec88a77616f4963eb5b8signed off asSigned-off-by: Manuel Cabiya <ca6iya@users.noreply.github.com>, matching the commit author and committer.SPDX-License-Identifier: Apache-2.0, and those headers were left in place.restapi.rst,parameters.yaml), the vmcp privilege table (quickstart.rst), the sample config, and the release notes (doc/source/change.rst) are updated. Commit subjects are within the 50-character limit inCONTRIBUTING.md, and the change includes tests.GOVERNANCE.md,MAINTAINERS.txt,CODE_OF_CONDUCT.md,LICENSE, anddco_signoffs/were not modified.QUERY ALLOC PAGEandQUERY ALLOC SPOOLresults, including failures, are reused foralloc_cache_seconds(default 60) under a lock, with no background thread. The privilege table and host-info docs state the 256 KBvmcpbuffer and that callers should not poll faster than the TTL.