Skip to content

fix: CoreData apply default retention policy to none autoEvent#5189

Merged
judehung merged 1 commit intoedgexfoundry:mainfrom
weichou1229:issue-5188
Jun 20, 2025
Merged

fix: CoreData apply default retention policy to none autoEvent#5189
judehung merged 1 commit intoedgexfoundry:mainfrom
weichou1229:issue-5188

Conversation

@weichou1229
Copy link
Member

CoreData apply default retention policy to events not coming from auto events

Close #5188

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/edgex-go/blob/main/.github/Contributing.md

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?)
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?)

Testing Instructions

Deploy core service and device-virtual to test the event purge.

New Dependency Instructions (If applicable)

@weichou1229 weichou1229 requested a review from judehung June 20, 2025 06:35
@codecov-commenter
Copy link

codecov-commenter commented Jun 20, 2025

Codecov Report

Attention: Patch coverage is 48.88889% with 23 lines in your changes missing coverage. Please review.

Project coverage is 26.74%. Comparing base (82c539f) to head (10d2f8b).

Files with missing lines Patch % Lines
internal/core/data/application/reading.go 53.65% 18 Missing and 1 partial ⚠️
internal/pkg/cache/device.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5189      +/-   ##
==========================================
+ Coverage   26.69%   26.74%   +0.05%     
==========================================
  Files         278      278              
  Lines       19954    19993      +39     
==========================================
+ Hits         5326     5347      +21     
- Misses      13370    13387      +17     
- Partials     1258     1259       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@weichou1229 weichou1229 force-pushed the issue-5188 branch 2 times, most recently from 08c2b66 to 7dbef6c Compare June 20, 2025 08:49
Comment on lines +317 to +320
break
}
continue
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to make these change? looks no difference to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted

}
var sources []string
for _, r := range profile.Profile.DeviceResources {
if contained := slices.ContainsFunc(device.AutoEvents, func(event models.AutoEvent) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if contained := slices.ContainsFunc(device.AutoEvents, func(event models.AutoEvent) bool {
// skip the device resource that is associated with any AutoEvent definitions.
if contained := slices.ContainsFunc(device.AutoEvents, func(event models.AutoEvent) bool {

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the comment.

}); contained {
continue
}
if r.Properties.ReadWrite == common.ReadWrite_W {
Copy link
Member

Choose a reason for hiding this comment

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

Please add comment to explain why skip resources with ReadWrite_W

}); contained {
continue
}
if c.ReadWrite == common.ReadWrite_W {
Copy link
Member

Choose a reason for hiding this comment

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

Please add comment to explain why skip device command with ReadWrite_W

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the comment.

sources = append(sources, r.Name)
}
for _, c := range profile.Profile.DeviceCommands {
if contained := slices.ContainsFunc(device.AutoEvents, func(event models.AutoEvent) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if contained := slices.ContainsFunc(device.AutoEvents, func(event models.AutoEvent) bool {
// // skip the device command that is associated with any AutoEvent definitions.
if contained := slices.ContainsFunc(device.AutoEvents, func(event models.AutoEvent) bool {

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the comment.

CoreData apply default retention policy to events not coming from auto events

Close edgexfoundry#5188

Signed-off-by: bruce <weichou1229@gmail.com>
@sonarqubecloud
Copy link

@weichou1229 weichou1229 requested a review from judehung June 20, 2025 09:54
Copy link
Member

@judehung judehung left a comment

Choose a reason for hiding this comment

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

LGTM

@judehung judehung merged commit 9304f16 into edgexfoundry:main Jun 20, 2025
7 checks passed
@weichou1229 weichou1229 deleted the issue-5188 branch June 23, 2025 00:40
FelixTing pushed a commit to FelixTing/edgex-go that referenced this pull request Oct 15, 2025
…foundry#5189)

CoreData apply default retention policy to events not coming from auto events

Close edgexfoundry#5188

Signed-off-by: bruce <weichou1229@gmail.com>
FelixTing pushed a commit to FelixTing/edgex-go that referenced this pull request Oct 15, 2025
…foundry#5189)

CoreData apply default retention policy to events not coming from auto events

Close edgexfoundry#5188

Signed-off-by: Bruce Huang <weichou1229@gmail.com>
FelixTing pushed a commit to FelixTing/edgex-go that referenced this pull request Oct 15, 2025
…foundry#5189)

CoreData apply default retention policy to events not coming from auto events

Close edgexfoundry#5188

Signed-off-by: Bruce Huang <weichou1229@gmail.com>
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.

Allow default retention policy can apply to events not coming from auto events

3 participants