Skip to content

bridge: Skip unreadable PCP archives instead of failing the whole history - #23304

Open
officialasishkumar wants to merge 1 commit into
cockpit-project:mainfrom
officialasishkumar:pcp-skip-unreadable-archives
Open

bridge: Skip unreadable PCP archives instead of failing the whole history#23304
officialasishkumar wants to merge 1 commit into
cockpit-project:mainfrom
officialasishkumar:pcp-skip-unreadable-archives

Conversation

@officialasishkumar

Copy link
Copy Markdown
Contributor

Problem

The metrics channel globs every *.index file in the pmlogger archive
directory and opens each one as a PCP archive context. Until now only
PM_ERR_LOGFILE (a missing data volume) was tolerated when opening an
archive; any other error raised ChannelError('not-found'), which
aborted reading of all archives in the directory.

As a result a single damaged archive disabled the entire metrics history
in the web UI, even though the remaining archives were perfectly
readable. This shows up in practice in two reported ways:

In both cases the user only sees "Metrics history could not be loaded"
with no indication of which file is at fault.

Fix

Treat an unreadable individual archive the same way as a missing data
volume: log a warning naming the offending file and skip it, so the
history from the healthy archives keeps loading. When no archive in the
directory can be read at all, get_archives() still reports not-found,
matching the behaviour of an empty or non-existent source.

Testing

  • New test_pcp_partially_broken_archive puts a healthy archive next to
    an unreadable one and asserts the healthy archive's samples are still
    returned. It fails before the change and passes after.
  • test_pcp_broken_archive is updated to assert that a directory where
    every archive is unreadable still reports a bare not-found.
  • Full test/pytest/test_pcp.py suite passes (17 tests).

Fixes: #23023
Fixes: #23214

Metrics history survives a single corrupt PCP archive

A single corrupted or empty PCP archive (for example one left behind by an
interrupted or freshly rotated pmlogger) no longer disables the whole
metrics history page. Cockpit now skips the unreadable archive, logs a
warning naming it, and shows the data from the remaining healthy archives.

…tory

The metrics channel globs every *.index file in the pmlogger archive
directory and opens each one as a PCP archive context. Until now only
PM_ERR_LOGFILE (a missing data volume) was tolerated; any other error
while opening a single archive raised ChannelError('not-found'), which
aborted reading of *all* archives in the directory.

As a result a single damaged archive disabled the entire metrics history
in the web UI even though the remaining archives were perfectly readable.
This happens in practice with an empty *.index file left behind by a
freshly rotated or interrupted pmlogger (PM_ERR_NODATA / PM_ERR_LABEL)
and with a corrupted record (PM_ERR_LOGREC).

Treat an unreadable individual archive the same way as a missing data
volume: log a warning and skip it, so the history from the healthy
archives keeps loading. When no archive in the directory can be read at
all, get_archives() still reports 'not-found', matching an empty or
non-existent source.

Fixes: cockpit-project#23023
Fixes: cockpit-project#23214
# healthy archives in this directory. Skip it and carry on;
# get_archives() still reports 'not-found' when *no* archive in
# the directory can be read.
if exc.errno() != c_api.PM_ERR_LOGFILE:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we already skip unreadable archive files as PM_ERR_LOGFILE is:

#define PM_ERR_LOGFILE          (-PM_ERR_BASE-30)   /* Missing PCP archive file */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty metrics history file in pmlogger causes metrics page to fail loading in web UI Performance Metrics Archive Logger fails on corrupted record.

2 participants