-
-
Notifications
You must be signed in to change notification settings - Fork 268
pmseries, libpcp_web: add --gc mode to remove expired series data #2575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
natoscott
wants to merge
2
commits into
main
Choose a base branch
from
series-gc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| #!/bin/sh | ||
| # PCP QA Test No. 1790 | ||
| # Exercise pmseries --gc (garbage collection) and --dryrun options. | ||
| # | ||
| # Copyright (c) 2026 Red Hat. All Rights Reserved. | ||
| # | ||
|
|
||
| seq=`basename $0` | ||
| echo "QA output created by $seq" | ||
|
|
||
| # get standard environment, filters and checks | ||
| . ./common.product | ||
| . ./common.filter | ||
| . ./common.check | ||
| . ./common.keys | ||
|
|
||
| _check_series | ||
|
|
||
| _cleanup() | ||
| { | ||
| [ -n "$key_server_port" ] && $keys_cli -p $key_server_port shutdown | ||
| _restore_config $PCP_SYSCONF_DIR/pmseries | ||
| cd $here | ||
| $sudo rm -rf $tmp $tmp.* | ||
| } | ||
|
|
||
| status=1 # failure is the default! | ||
| key_server_port=`_find_free_port` | ||
| options="-p $key_server_port" | ||
|
|
||
| trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
|
|
||
| _filter_source() | ||
| { | ||
| sed \ | ||
| -e "s,$here,PATH,g" \ | ||
| #end | ||
| } | ||
|
|
||
| # real QA test starts here | ||
| _save_config $PCP_SYSCONF_DIR/pmseries | ||
| $sudo rm -f $PCP_SYSCONF_DIR/pmseries/* | ||
|
|
||
| echo "Start test key server ..." | ||
| $key_server --port $key_server_port --save "" > $tmp.keys 2>&1 & | ||
| _check_key_server_ping $key_server_port | ||
| _check_key_server $key_server_port | ||
| echo | ||
|
|
||
| _check_key_server_version $key_server_port | ||
|
|
||
| echo "== Load test archive" | ||
| pmseries $options --load "{source.path: \"$here/archives/viewqa1\"}" | _filter_source | ||
|
|
||
| echo | ||
| echo "== GC on live data (all streams present)" | ||
| pmseries $options --gc | ||
|
|
||
| echo | ||
| echo "== Count series keys before expiry" | ||
| ndesc=`$keys_cli -p $key_server_port keys 'pcp:desc:series:*' | wc -l` | ||
| nvals=`$keys_cli -p $key_server_port keys 'pcp:values:series:*' | wc -l` | ||
| echo "$ndesc desc keys, $nvals value keys" | ||
|
|
||
| echo | ||
| echo "== Simulate expiry: delete 3 value streams" | ||
| $keys_cli -p $key_server_port keys 'pcp:values:series:*' | sort | head -3 > $tmp.expired | ||
| while read key; do | ||
| $keys_cli -p $key_server_port del "$key" > /dev/null | ||
| done < $tmp.expired | ||
| nvals=`$keys_cli -p $key_server_port keys 'pcp:values:series:*' | wc -l` | ||
| echo "$nvals value keys remain" | ||
|
|
||
| echo | ||
| echo "== GC dryrun (should report but not delete)" | ||
| pmseries $options --gc --dryrun > $tmp.dryrun 2>&1 | ||
| ndryrun=`grep -c 'GC dryrun:' $tmp.dryrun` | ||
| echo "dryrun reported $ndryrun series" | ||
| grep 'GC dryrun:' $tmp.dryrun | sed 's/pmseries: \[Info\] //' | sort | ||
|
|
||
| echo | ||
| echo "== Verify dryrun preserved metadata keys" | ||
| ndesc=`$keys_cli -p $key_server_port keys 'pcp:desc:series:*' | wc -l` | ||
| echo "$ndesc desc keys (should be 11)" | ||
|
|
||
| echo | ||
| echo "== Actual GC (should clean 3 series)" | ||
| pmseries $options --gc | ||
|
|
||
| echo | ||
| echo "== Verify metadata keys removed after GC" | ||
| ndesc=`$keys_cli -p $key_server_port keys 'pcp:desc:series:*' | wc -l` | ||
| echo "$ndesc desc keys remain (should be 8)" | ||
| nmetric=`$keys_cli -p $key_server_port keys 'pcp:metric.name:series:*' | wc -l` | ||
| echo "$nmetric metric.name keys remain (should be 8)" | ||
|
|
||
| echo | ||
| echo "== Second GC (should find nothing to clean)" | ||
| pmseries $options --gc | ||
|
|
||
| echo | ||
| echo "== Error: --gc with extra query argument" | ||
| pmseries $options --gc 'kernel.all.load' 2>&1 | grep 'error' | ||
|
|
||
| echo | ||
| echo "== Error: --gc with extra series ID argument" | ||
| pmseries $options --gc 'da4a7a6fb41c07daa1e5d2a6acf66281a8c89e35' 2>&1 | grep 'error' | ||
|
|
||
| echo | ||
| echo "== Error: --dryrun without --gc" | ||
| pmseries $options --dryrun 2>&1 | grep 'error' | ||
|
|
||
| echo | ||
| echo "== Error: --gc with --load" | ||
| pmseries $options --gc --load "{source.path: \"$here/archives/viewqa1\"}" 2>&1 | grep 'error' | ||
|
|
||
| # success, all done | ||
| status=0 | ||
| exit |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| QA output created by 1790 | ||
| Start test key server ... | ||
| PING | ||
| PONG | ||
|
|
||
| == Load test archive | ||
| pmseries: [Info] processed 151 archive records from PATH/archives/viewqa1 | ||
|
|
||
| == GC on live data (all streams present) | ||
| pmseries: [Info] GC: 11 series scanned, 0 cleaned | ||
|
|
||
| == Count series keys before expiry | ||
| 11 desc keys, 11 value keys | ||
|
|
||
| == Simulate expiry: delete 3 value streams | ||
| 8 value keys remain | ||
|
|
||
| == GC dryrun (should report but not delete) | ||
| dryrun reported 3 series | ||
| GC dryrun: 03fe155a8a42dccd8534859a6cc9e3252a127099 (1 metric names, 0 instances, 1 labels) | ||
| GC dryrun: 1107fbb3f8415b6c5712cd62b2580fc23b9b8d59 (1 metric names, 1 instances, 0 labels) | ||
| GC dryrun: 55ba4725fb2dc0ddb1765366ff25f68c8a6efa44 (1 metric names, 1 instances, 0 labels) | ||
|
|
||
| == Verify dryrun preserved metadata keys | ||
| 11 desc keys (should be 11) | ||
|
|
||
| == Actual GC (should clean 3 series) | ||
| pmseries: [Info] GC: 11 series scanned, 3 cleaned | ||
|
|
||
| == Verify metadata keys removed after GC | ||
| 8 desc keys remain (should be 8) | ||
| 8 metric.name keys remain (should be 8) | ||
|
|
||
| == Second GC (should find nothing to clean) | ||
| pmseries: [Info] GC: 8 series scanned, 0 cleaned | ||
|
|
||
| == Error: --gc with extra query argument | ||
| pmseries: error - --gc does not accept extra arguments | ||
|
|
||
| == Error: --gc with extra series ID argument | ||
| pmseries: error - --gc does not accept extra arguments | ||
|
|
||
| == Error: --dryrun without --gc | ||
| pmseries: error - --dryrun requires --gc | ||
|
|
||
| == Error: --gc with --load | ||
| pmseries: error - cannot combine --gc with other operation options |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Document the current single-node GC scope.
Lines 749-750 promise cleanup across the “key-value cluster,” but this implementation currently scans only the first key-server node. State that limitation so operators do not assume a cluster-wide cleanup completed.
🤖 Prompt for AI Agents