feat: log thing group cleanup removals at info level - #1821
Open
aws-kevinrickard wants to merge 1 commit into
Open
feat: log thing group cleanup removals at info level#1821aws-kevinrickard wants to merge 1 commit into
aws-kevinrickard wants to merge 1 commit into
Conversation
cleanupGroupData() removes GroupToRootComponents and GroupToLastDeployment config entries for thing groups the device is no longer a member of. This is a destructive, state-changing operation, but it was only logged at DEBUG, which is not visible in production by default. Bump both removal log statements to INFO and convert them to the structured logger builder pattern used elsewhere in this file, including the removed thing group name and the deployment ID that triggered the cleanup.
|
Unit Tests Coverage Report
Minimum allowed coverage is Generated by 🐒 cobertura-action against 351b58a |
|
Integration Tests Coverage Report
Minimum allowed coverage is Generated by 🐒 cobertura-action against 351b58a |
alter-mage
approved these changes
Jul 24, 2026
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.
Problem
DeploymentService.cleanupGroupData()removesGroupToRootComponentsandGroupToLastDeploymentconfig entries for thing groups the device is no longer a member of. This is a destructive, state-changing operation — once it runs, the prior group-to-component and last-deployment bookkeeping for that group is gone.Today this is only logged at DEBUG, which is disabled in production by default. If a group's
GroupToRootComponents/GroupToLastDeploymentstate unexpectedly disappears, there is no production-visible signal to confirm this code path fired, when it fired, or for which group — making the behavior difficult to diagnose after the fact.Change
cleanupGroupData()from DEBUG to INFO. This reflects normal, expected operation of the cleanup routine (not an error), so INFO rather than WARN/ERROR.logger.atInfo().kv(...).log(...)) already used elsewhere in this file, so the fields are queryable rather than embedded in a formatted string.ThingGroup: the name of the thing group whose mapping/last-deployment entry is being removed.DeploymentId: the ID of the deployment that triggered the cleanup, threaded through frompersistGroupToRootComponents()'sDeploymentDocumentparameter (the only deployment-identifying value already in scope at this call site — no broader refactor was needed to make it available).@SuppressWarnings("PMD.ExcessiveClassLength")at the class level.DeploymentServicewas already at the edge of PMD's default class-length threshold; this change (a new log-key constant plus the structured log calls) pushed it over. The same suppression already exists onMqttClientfor the same rule, so this follows established precedent in the codebase rather than introducing a new pattern.Testing
DeploymentServiceTestthat runs a deployment where a thing group present inGroupToRootComponents/GroupToLastDeploymentis absent fromGroupMembership, and asserts that both cleanup log lines fire at INFO with the expectedDeploymentIdandThingGroupfields (using the existingSlf4jLogAdapter.addGlobalListenertest pattern already used in this file for log assertions).DeploymentServiceTestsuite: 18/18 passing.