Skip to content

Updating cron and calendar to slog method signatures. - #40446

Merged
getvictor merged 1 commit into
mainfrom
victor/40054-cron-calendar
Feb 24, 2026
Merged

Updating cron and calendar to slog method signatures.#40446
getvictor merged 1 commit into
mainfrom
victor/40054-cron-calendar

Conversation

@getvictor

@getvictor getvictor commented Feb 24, 2026

Copy link
Copy Markdown
Member

Related issue: Resolves #40054

Checklist for submitter

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    • Changes included in previous PR

Testing

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

Summary by CodeRabbit

  • Chores
    • Improved internal logging infrastructure across calendar, MDM, and integration services to enhance operational observability and maintainability.

@getvictor

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

Copilot AI left a comment

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.

Pull request overview

Migrates cron- and calendar-related logging call sites from go-kit/log/level style to the repository’s *logging.Logger slog-backed DebugContext/InfoContext/WarnContext/ErrorContext methods, aligning these areas with the ongoing slog migration work for #40054.

Changes:

  • Replace go-kit level.*(...).Log(...) usage with *logging.Logger context-aware methods across cron, calendar, and related services.
  • Thread context.Context into a couple helper functions to support context-aware logging.
  • Remove now-unused go-kit level imports from updated files.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
server/service/calendar/calendar.go Switch error logging to ErrorContext in calendar event body generation helpers.
server/service/apple_mdm_cmd_results.go Convert warn/debug logs in VPP install verification results handler to *Context methods.
server/cron/calendar_cron.go Update cron calendar logging to *Context methods and pass context into helper logging.
ee/server/service/teams.go Convert informational/error logs to InfoContext/ErrorContext in team modification paths.
ee/server/service/orbit.go Convert setup-experience related logs to *Context methods.
ee/server/service/digicert/digicert.go Convert DigiCert debug/error logs to *Context methods.
ee/server/service/calendar.go Convert calendar webhook/service logging to *Context methods.
ee/server/calendar/google_calendar.go Convert Google Calendar implementation logs to *Context methods.
cmd/fleet/cron.go Convert vulnerability/cron logs and helpers to *Context methods; adjust helper signature to accept context.
Comments suppressed due to low confidence (1)

ee/server/calendar/google_calendar.go:272

  • withRetry logs using context.TODO(), which drops any trace/span correlation and request-scoped values available on the caller context. Please thread a real context into withRetry (e.g., accept ctx context.Context and pass through from the public methods) or store the configured context on GoogleCalendarLowLevelAPI in Configure and use that for logging.
					lowLevelAPI.logger.DebugContext(context.TODO(), "rate limited by Google calendar API", "err", err)
					return err

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai

coderabbitai Bot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR migrates logging across nine files from go-kit log/level package calls to context-aware logger methods. Changes replace level.Info/Error/Debug/Warn(logger).Log() calls with logger.InfoContext/ErrorContext/DebugContext/WarnContext(ctx, ...) variants. Two helper function signatures are updated to accept context parameters: stringSliceToUintSlice() in cmd/fleet/cron.go and logHostsWithoutAssociatedEmail() in server/cron/calendar_cron.go. All go-kit log/level imports are removed. Functional behavior and control flow remain intact.

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description is incomplete and vague. It references issue #40054 and mentions changes files from a previous PR, but lacks detail about what slog migration work was accomplished or how it was tested. Provide more specific information about which functions were updated, explain the slog migration rationale, and detail the testing approach beyond just checking the checkboxes.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: updating cron and calendar code to use slog method signatures, which aligns with all the file changes shown in the raw summary.
Linked Issues check ✅ Passed The PR successfully addresses the primary objective of issue #40054 by migrating cron and calendar code to use slog (structured logging) method signatures, replacing go-kit log/level calls with context-aware logger methods across 8 files.
Out of Scope Changes check ✅ Passed All changes are in scope and directly support the slog migration objective. Updates to logging calls, signature changes (adding context parameters to helper functions), and removal of go-kit dependencies are all aligned with the stated goal of migrating to slog method signatures.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch victor/40054-cron-calendar

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
server/cron/calendar_cron.go (1)

165-170: ⚠️ Potential issue | 🟡 Minor

Duplicate team_id key in structured log output.

Line 128 already enriches the logger with "team_id" via logger = logger.With("team_id", team.ID). Passing "team_id", team.ID again at line 166 will produce a duplicate key in the log entry.

Proposed fix
 	logger.DebugContext(ctx, "summary",
-		"team_id", team.ID,
 		"passing_hosts", len(passingHosts),
 		"failing_hosts", len(failingHosts),
 		"failing_hosts_without_associated_email", len(failingHostsWithoutAssociatedEmail),
 	)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/cron/calendar_cron.go` around lines 165 - 170, The structured log call
passes "team_id" twice: it was already added via logger = logger.With("team_id",
team.ID), so remove the duplicate arguments from the logger.DebugContext call
(the "team_id", team.ID pair) in the DebugContext invocation; keep the other
fields (passing_hosts, failing_hosts, failing_hosts_without_associated_email)
unchanged so the log still reports those metrics using logger.DebugContext.
🧹 Nitpick comments (2)
server/cron/calendar_cron.go (2)

94-94: Error logged at Info level — intentional?

This logs a potentially actionable per-team error (err) at InfoContext. If the original code also used level.Info, this is just a faithful migration, but consider whether ErrorContext or WarnContext would be more appropriate so that operators can filter on severity.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/cron/calendar_cron.go` at line 94, The current logging call uses
logger.InfoContext to record per-team errors (logger.InfoContext(ctx, "events
calendar cron", "team_id", team.ID, "err", err)); change this to an appropriate
higher severity (e.g., logger.ErrorContext or logger.WarnContext) so actionable
errors are surfaced correctly, and keep the same context fields ("events
calendar cron", "team_id", team.ID) while including the err value; update any
surrounding logic in the function that calls logger.InfoContext to use the new
logger method.

738-740: fmt.Sprintf in the message arg is unnecessary with structured logging.

With slog-style logging, the message should be a static string and dynamic data should go into key-value pairs. The domain value is already available as a field on the logger or can be passed as a separate key.

Proposed fix
-	logger.DebugContext(ctx, fmt.Sprintf("no %s Google account associated with the hosts", domain),
-		"host_ids", fmt.Sprintf("%+v", hostIDs),
+	logger.DebugContext(ctx, "no Google account associated with the hosts",
+		"domain", domain,
+		"host_ids", hostIDs,
 	)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/cron/calendar_cron.go` around lines 738 - 740, The log call uses
fmt.Sprintf for the message; change the DebugContext call so the message is a
static string and pass domain and hostIDs as separate key-value fields: update
the call to logger.DebugContext(ctx, "no Google account associated with the
hosts", "domain", domain, "host_ids", hostIDs) (referencing DebugContext, the
domain variable and hostIDs) so structured logging carries dynamic data instead
of embedding it in the message.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@server/cron/calendar_cron.go`:
- Around line 165-170: The structured log call passes "team_id" twice: it was
already added via logger = logger.With("team_id", team.ID), so remove the
duplicate arguments from the logger.DebugContext call (the "team_id", team.ID
pair) in the DebugContext invocation; keep the other fields (passing_hosts,
failing_hosts, failing_hosts_without_associated_email) unchanged so the log
still reports those metrics using logger.DebugContext.

---

Nitpick comments:
In `@server/cron/calendar_cron.go`:
- Line 94: The current logging call uses logger.InfoContext to record per-team
errors (logger.InfoContext(ctx, "events calendar cron", "team_id", team.ID,
"err", err)); change this to an appropriate higher severity (e.g.,
logger.ErrorContext or logger.WarnContext) so actionable errors are surfaced
correctly, and keep the same context fields ("events calendar cron", "team_id",
team.ID) while including the err value; update any surrounding logic in the
function that calls logger.InfoContext to use the new logger method.
- Around line 738-740: The log call uses fmt.Sprintf for the message; change the
DebugContext call so the message is a static string and pass domain and hostIDs
as separate key-value fields: update the call to logger.DebugContext(ctx, "no
Google account associated with the hosts", "domain", domain, "host_ids",
hostIDs) (referencing DebugContext, the domain variable and hostIDs) so
structured logging carries dynamic data instead of embedding it in the message.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6110e3d and 162e593.

📒 Files selected for processing (9)
  • cmd/fleet/cron.go
  • ee/server/calendar/google_calendar.go
  • ee/server/service/calendar.go
  • ee/server/service/digicert/digicert.go
  • ee/server/service/orbit.go
  • ee/server/service/teams.go
  • server/cron/calendar_cron.go
  • server/service/apple_mdm_cmd_results.go
  • server/service/calendar/calendar.go

@getvictor
getvictor marked this pull request as ready for review February 24, 2026 22:06
@getvictor
getvictor requested a review from a team as a code owner February 24, 2026 22:06
@codecov

codecov Bot commented Feb 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 38.20225% with 55 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.29%. Comparing base (81c75b4) to head (162e593).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
cmd/fleet/cron.go 41.37% 17 Missing ⚠️
server/cron/calendar_cron.go 28.57% 15 Missing ⚠️
ee/server/service/calendar.go 14.28% 12 Missing ⚠️
ee/server/calendar/google_calendar.go 44.44% 5 Missing ⚠️
ee/server/service/teams.go 50.00% 2 Missing ⚠️
server/service/apple_mdm_cmd_results.go 33.33% 2 Missing ⚠️
ee/server/service/digicert/digicert.go 66.66% 1 Missing ⚠️
server/service/calendar/calendar.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #40446      +/-   ##
==========================================
+ Coverage   66.26%   66.29%   +0.03%     
==========================================
  Files        2460     2461       +1     
  Lines      197220   197395     +175     
  Branches     8716     8702      -14     
==========================================
+ Hits       130682   130860     +178     
+ Misses      54713    54685      -28     
- Partials    11825    11850      +25     
Flag Coverage Δ
backend 68.14% <38.20%> (+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.

@sgress454 sgress454 left a comment

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.

once again my frail human orbs have detected no issues 👁️

@getvictor
getvictor merged commit 7516e58 into main Feb 24, 2026
52 checks passed
@getvictor
getvictor deleted the victor/40054-cron-calendar branch February 24, 2026 22:51
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.

slog migration (2)

3 participants