Skip to content

Conversation

@aphralG
Copy link
Contributor

@aphralG aphralG commented Nov 27, 2025

Proposed changes

If config applys were preformed in quick succession there was a chance that unmanaged files would be marked as managed.
This updates the resource plugin so that when it creates the config context it then reads the manifest to determine what files are unmanaged and updates them in the config context.

Also fixes issue where file watcher wasn't properly disabled.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • I have run make install-tools and have attached any dependency changes to this pull request
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • If applicable, I have updated any relevant documentation (README.md)
  • If applicable, I have tested my cross-platform changes on Ubuntu 22, Redhat 8, SUSE 15 and FreeBSD 13

@aphralG aphralG self-assigned this Nov 27, 2025
@aphralG aphralG requested a review from a team as a code owner November 27, 2025 14:22
@github-actions github-actions bot added bug Something isn't working chore Pull requests for routine tasks labels Nov 27, 2025
@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

❌ Patch coverage is 39.28571% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.29%. Comparing base (98514ea) to head (f0fee76).

Files with missing lines Patch % Lines
internal/resource/resource_service.go 37.50% 14 Missing and 1 partial ⚠️
internal/watcher/file/file_watcher_service.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1417      +/-   ##
==========================================
- Coverage   86.39%   86.29%   -0.11%     
==========================================
  Files         102      102              
  Lines       12622    12649      +27     
==========================================
+ Hits        10905    10915      +10     
- Misses       1236     1251      +15     
- Partials      481      483       +2     
Files with missing lines Coverage Δ
internal/watcher/file/file_watcher_service.go 81.29% <50.00%> (-0.95%) ⬇️
internal/resource/resource_service.go 62.80% <37.50%> (-2.69%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98514ea...f0fee76. Read the comment docs.

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

@aphralG aphralG changed the title Fix bug with unmanaged files Ensure Unmanaged Field Is Stored Correctly In Manifest Nov 27, 2025
if fws.enabled.Load() {
fws.checkForUpdates(ctx, ch)
} else {
slog.DebugContext(ctx, "Skipping check for file updates, file watcher is disabled")
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to log this every tick? It might be more beneficial to just log once whenever the watcher is enabled or disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied the same behaviour as the instance watcher, this wont be logged every tick it will only be logged if we are skipping a file update that hasnt cleared the channel by the time we disable it.

}

func (r *ResourceService) manifestFile() (map[string]*model.ManifestFile, error) {
if _, err := os.Stat(r.agentConfig.LibDir + "/manifest.json"); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could the manifest file name be stored in a variable, maybe as a const somewhere? It will save us having to change it in a lot of places if the name changes in future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This whole function will be removed in a PR that is coming up soon to remove the file plugin, I also don't see us changing the name of the manifest as it would cause a lot of confusion

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

Labels

bug Something isn't working chore Pull requests for routine tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants