Skip to content

Add more deprecation logs and mute by default#40305

Merged
sgress454 merged 17 commits intomainfrom
sgress454/40122-mute-deprecation-logs
Feb 24, 2026
Merged

Add more deprecation logs and mute by default#40305
sgress454 merged 17 commits intomainfrom
sgress454/40122-mute-deprecation-logs

Conversation

@sgress454
Copy link
Copy Markdown
Contributor

Related issue: Resolves #40122

Details

  • Adds deprecation warnings to fleetctl apply
  • Adds alias conflict errors (i.e. using both new and deprecated keys in the same spec) to fleetctl apply
  • Adds logic around all deprecated field warnings to check the topic first
  • Disables deprecation warnings by default for fleet serve, fleetctl gitops and fleetctl apply
  • Enables deprecation warnings for dogfood via env var

To turn on warnings:

  • In fleet serve, use either --logging_enable_topics=deprecated-field-names or the FLEET_LOGGING_ENABLE_TOPICS=deprecated-field-names env var
  • In fleetctl gitops / fleetctl apply use either --enable-log-topics=deprecated-field-names or FLEET_ENABLE_LOG_TOPICS=deprecated-field-names

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

tested in fleetctl apply, fleet serve and fleet gitops that warnings are suppressed by default and added when the appropriate env var or CLI option is used

OTEL_EXPORTER_OTLP_ENDPOINT = "https://otlp.signoz.dogfood.fleetdm.com"
# FLEET_LOGGING_TRACING_ENABLED = "true"
# FLEET_LOGGING_TRACING_TYPE = "elasticapm"
FLEET_LOGGING_ENABLE_TOPICS = "deprecated-field-names"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@rfairburn I think this is the right place to add an env var for our Dogfood server, let me know if there's a different place I need to change. This will turn on deprecation warnings on Dogfood so we can see them. The warnings will be turned off by default for the upcoming release.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

Comment thread cmd/fleet/serve.go
Comment thread cmd/fleetctl/fleetctl/apply.go
Comment thread cmd/fleetctl/fleetctl/gitops.go
Comment thread pkg/spec/spec.go
// key names back to old (json tag) names so that structs can be unmarshaled
// correctly when input uses the new key names.
func rewriteNewToOldKeys(raw json.RawMessage, target any) json.RawMessage {
func rewriteNewToOldKeys(raw json.RawMessage, target any) (json.RawMessage, map[string]string, error) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to return the set of deprecated keys used, if any, for use in warning logs.

Comment thread pkg/spec/spec.go

// GroupFromBytes parses a Group from concatenated YAML specs.
func GroupFromBytes(b []byte) (*Group, error) {
func GroupFromBytes(b []byte, options ...GroupFromBytesOpts) (*Group, error) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added optional param so that you can send a logger in to GroupFromBytes, which is a more centralized place to log deprecation warnings. Passing the deprecated keys back to the caller would mean having to implement the same logs in several places.

@sgress454 sgress454 marked this pull request as ready for review February 23, 2026 17:56
rfairburn
rfairburn previously approved these changes Feb 23, 2026
Copy link
Copy Markdown
Contributor

@rfairburn rfairburn left a comment

Choose a reason for hiding this comment

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

Terraform change looks fine

Comment thread changes/40122-mute-deprecation-warnings Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 79.76190% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.37%. Comparing base (b0cc888) to head (74c2cbb).
⚠️ Report is 39 commits behind head on main.

Files with missing lines Patch % Lines
pkg/spec/spec.go 78.04% 5 Missing and 4 partials ⚠️
server/service/appconfig.go 40.00% 5 Missing and 1 partial ⚠️
cmd/fleet/serve.go 0.00% 1 Missing ⚠️
server/platform/endpointer/json_key_rewriter.go 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #40305      +/-   ##
==========================================
+ Coverage   66.28%   66.37%   +0.09%     
==========================================
  Files        2459     2456       -3     
  Lines      196811   196815       +4     
  Branches     8714     8577     -137     
==========================================
+ Hits       130451   130643     +192     
+ Misses      54542    54349     -193     
- Partials    11818    11823       +5     
Flag Coverage Δ
backend 68.14% <79.76%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@iansltx iansltx left a comment

Choose a reason for hiding this comment

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

Minor feedback/questions here. Quessing the reason for having to gate topics this way is we have a number of cases where we're using a very basic logFn rather than slog? Are there any places where the built-in topic handling actually benefits us?

Comment thread cmd/fleetctl/fleetctl/apply_test.go Outdated
Comment thread cmd/fleetctl/fleetctl/apply_test.go Outdated
Comment thread cmd/fleetctl/fleetctl/apply_test.go Outdated
Comment thread server/service/endpoint_utils.go
Comment thread server/platform/endpointer/json_key_rewriter.go
Comment thread server/service/appconfig.go
@sgress454
Copy link
Copy Markdown
Contributor Author

Updated to use t.Setenv and split test as suggested.

@sgress454
Copy link
Copy Markdown
Contributor Author

@rfairburn can you re-👍 when you have a sec? (no changes to the terraform stuff)

@sgress454 sgress454 merged commit 772fb12 into main Feb 24, 2026
53 checks passed
@sgress454 sgress454 deleted the sgress454/40122-mute-deprecation-logs branch February 24, 2026 05:09
sgress454 added a commit that referenced this pull request Feb 24, 2026
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #40122

# Details

* Adds deprecation warnings to `fleetctl apply`
* Adds alias conflict errors (i.e. using both new and deprecated keys in
the same spec) to `fleetctl apply`
* Adds logic around all deprecated field warnings to check the topic
first
* Disables deprecation warnings by default for `fleet serve`, `fleetctl
gitops` and `fleetctl apply`
* Enables deprecation warnings for dogfood via env var

To turn on warnings:
* In `fleet serve`, use either
`--logging_enable_topics=deprecated-field-names` or the
`FLEET_LOGGING_ENABLE_TOPICS=deprecated-field-names` env var
* In `fleetctl gitops` / `fleetctl apply` use either
`--enable-log-topics=deprecated-field-names` or
`FLEET_ENABLE_LOG_TOPICS=deprecated-field-names`

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [X] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

## Testing

- [X] Added/updated automated tests
- [X] QA'd all new/changed functionality manually

tested in `fleetctl apply`, `fleet serve` and `fleet gitops` that
warnings are suppressed by default and added when the appropriate env
var or CLI option is used

(cherry picked from commit 772fb12)
sgress454 added a commit that referenced this pull request Feb 24, 2026
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.

Mute API deprecation warnings for "team*" and "query*" fields

3 participants