Skip to content

Commit

Permalink
Improve logging around report chunking (#32731)
Browse files Browse the repository at this point in the history
* Improve logging around report chunking

* address comments

* Restyled by whitespace

* Restyled by clang-format

* Update src/app/reporting/Engine.cpp

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Update src/app/reporting/Engine.cpp

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Update src/app/reporting/Engine.cpp

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Update src/app/reporting/Engine.cpp

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Update src/app/reporting/Engine.cpp

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Update Engine.cpp

* Update Engine.cpp

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
  • Loading branch information
3 people authored and pull[bot] committed Apr 24, 2024
1 parent e07877d commit fa6ab76
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/app/reporting/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,16 @@ CHIP_ERROR Engine::BuildSingleReportDataAttributeReportIBs(ReportDataMessage::Bu
pathForRetrieval, &encodeState);
if (err != CHIP_NO_ERROR)
{
ChipLogError(DataManagement,
"Error retrieving data from clusterId: " ChipLogFormatMEI ", err = %" CHIP_ERROR_FORMAT,
ChipLogValueMEI(pathForRetrieval.mClusterId), err.Format());

// If error is not an "out of writer space" error, rollback and encode status.
// Otherwise, if partial data allowed, save the encode state.
// Otherwise roll back. If we have already encoded some chunks, we are done; otherwise encode status.

if (encodeState.AllowPartialData() && IsOutOfWriterSpaceError(err))
{
ChipLogDetail(DataManagement,
"List does not fit in packet, chunk between list items for clusterId: " ChipLogFormatMEI
", attributeId: " ChipLogFormatMEI,
ChipLogValueMEI(pathForRetrieval.mClusterId), ChipLogValueMEI(pathForRetrieval.mAttributeId));
// Encoding is aborted but partial data is allowed, then we don't rollback and save the state for next chunk.
// The expectation is that RetrieveClusterData has already reset attributeReportIBs to a good state (rolled
// back any partially-written AttributeReportIB instances, reset its error status). Since AllowPartialData()
Expand All @@ -230,6 +230,11 @@ CHIP_ERROR Engine::BuildSingleReportDataAttributeReportIBs(ReportDataMessage::Bu

if (!IsOutOfWriterSpaceError(err))
{
ChipLogError(DataManagement,
"Fail to retrieve data, roll back and encode status on clusterId: " ChipLogFormatMEI
", attributeId: " ChipLogFormatMEI "err = %" CHIP_ERROR_FORMAT,
ChipLogValueMEI(pathForRetrieval.mClusterId), ChipLogValueMEI(pathForRetrieval.mAttributeId),
err.Format());
// Try to encode our error as a status response.
err = attributeReportIBs.EncodeAttributeStatus(pathForRetrieval, StatusIB(err));
if (err != CHIP_NO_ERROR)
Expand All @@ -239,6 +244,14 @@ CHIP_ERROR Engine::BuildSingleReportDataAttributeReportIBs(ReportDataMessage::Bu
attributeReportIBs.Rollback(attributeBackup);
}
}
else
{
ChipLogDetail(DataManagement,
"Next attribute value does not fit in packet, roll back on clusterId: " ChipLogFormatMEI
", attributeId: " ChipLogFormatMEI ", err = %" CHIP_ERROR_FORMAT,
ChipLogValueMEI(pathForRetrieval.mClusterId), ChipLogValueMEI(pathForRetrieval.mAttributeId),
err.Format());
}
}
}
SuccessOrExit(err);
Expand Down

0 comments on commit fa6ab76

Please sign in to comment.