Skip to content

gcp: set cpu_idle=false on fleet-api Cloud Run service#243

Open
robbiet480 wants to merge 1 commit into
fleetdm:mainfrom
robbiet480:fix/gcp-cpu-idle-for-cron
Open

gcp: set cpu_idle=false on fleet-api Cloud Run service#243
robbiet480 wants to merge 1 commit into
fleetdm:mainfrom
robbiet480:fix/gcp-cpu-idle-for-cron

Conversation

@robbiet480
Copy link
Copy Markdown

Summary

  • The fleet-api Cloud Run service in gcp/byo-project/cloud_run.tf was running with the Cloud Run default of cpu_idle = true (CPU only allocated during request processing).
  • This context-cancels Fleet's background cron goroutines between requests. In particular, apple_mdm_dep_profile_assigner can advance the nanodep sync cursor in nano_dep_names.syncer_cursor without committing the corresponding device upserts to host_dep_assignments, silently dropping DEP device events that Apple's DEP API will not re-emit. Only a manual cursor reset recovers.
  • This PR sets cpu_idle = false on the container's resources block so the warm instance (already enforced by min_instance_count = 1) keeps CPU allocated for cron goroutines.

Test plan

  • terraform plan shows the change as an in-place update on the existing Cloud Run service (no replacement).
  • After apply, gcloud run services describe fleet-api --region <region> --format='yaml(spec.template.metadata.annotations)' shows run.googleapis.com/cpu-throttling: 'false'.
  • Tail logs and confirm apple_mdm_dep_profile_assigner completeds cleanly each tick with no context canceled / unlock failed / update cron stats: context canceled entries.
  • Confirm no pending job might still be running, wait 1m0s stalls.

Related

🤖 Generated with Claude Code

Without this, Cloud Run defaults to throttling CPU between requests, which
context-cancels Fleet's background cron goroutines mid-tick. In particular,
apple_mdm_dep_profile_assigner can advance the nanodep sync cursor without
committing the corresponding device upserts, silently dropping DEP device
events that Apple will not re-emit.

Fixes fleetdm#242
Related: fleetdm/fleet#46235

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@BCTBB
Copy link
Copy Markdown
Contributor

BCTBB commented Jun 4, 2026

@robbiet480 Thank you for your contribution! We'll schedule the review of your proposed changes for next sprint.

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.

gcp: Cloud Run service does not set cpu_idle=false, causing cron jobs to be context-cancelled mid-run

2 participants