Skip to content

Fix issue with fleet's docker image in k8s environments - #44373

Merged
lucasmrod merged 1 commit into
mainfrom
44298-fix-goquery-dependency-side-effects
Apr 29, 2026
Merged

Fix issue with fleet's docker image in k8s environments#44373
lucasmrod merged 1 commit into
mainfrom
44298-fix-goquery-dependency-side-effects

Conversation

@lucasmrod

@lucasmrod lucasmrod commented Apr 29, 2026

Copy link
Copy Markdown
Member

Resolves #44298

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

Testing

  • QA'd all new/changed functionality manually
  1. Running the docker image pushed by this PR with the user 3333 doesn't fail anymore:
docker run --platform linux/amd64 -it --user 3333:3333 fleetdm/fleet@sha256:1a06bcae25e13e37f871378c7c156f5a2cdf67bc3c3e3bcdc95b6afc0c6decbb
[...]
ts=2026-04-29T13:25:56Z level=warn msg="could not connect to db" err="dial tcp [::1]:3306: connect: connection refused" sleep_interval=0s
[...]

4.84.0 fails with:

docker run --platform linux/amd64 -it --user 3333:3333 fleetdm/fleet:v4.84.0@sha256:51b56ad59a840b28e074ff9b06d6d5b232b0ca2f0d999bb164820da69c7cbe15

Failed to fetch user info for home directory: user: unknown userid 33332026/04/29 13:28:08 71 <nil>
  1. strings ./build/fleet | rg github.com/AbGuthrie/goquery/v2 returns nothing in this branch and returns plenty of matches in main.
  2. Smoke tested fleetctl goquery functionality.

Summary by CodeRabbit

  • Bug Fixes
    • Resolved Docker image startup failures in Kubernetes environments caused by a dependency side effect.

Copilot AI review requested due to automatic review settings April 29, 2026 13:00
@lucasmrod
lucasmrod requested a review from a team as a code owner April 29, 2026 13:00

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@qodo-code-review

Copy link
Copy Markdown
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

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

This PR addresses Fleet server startup failures in containerized/Kubernetes environments caused by init-time side effects from the github.com/AbGuthrie/goquery/v2 dependency being transitively linked into the Fleet server binary via the fleetctl package.

Changes:

  • Isolates the goquery implementation into a goquerycmd subpackage so goquery’s init-time side effects are only linked into the fleetctl binary.
  • Adds a runner registration hook (SetGoqueryRunner) so fleetctl goquery remains available without importing goquery in the shared fleetctl package.
  • Adds a user-visible changes entry describing the fix.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
cmd/fleetctl/main.go Registers the goquery runner in the fleetctl binary entrypoint to keep goquery out of other binaries.
cmd/fleetctl/fleetctl/goquerycmd/goquery.go New isolated implementation of the fleetctl goquery REPL and Fleet-backed client adapter.
cmd/fleetctl/fleetctl/goquery.go Removes direct goquery imports; introduces SetGoqueryRunner and a nil-checking dispatcher.
changes/44298-fix-goquery-dependency-side-effects Records the user-visible fix for the container startup issue.

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

Comment thread cmd/fleetctl/fleetctl/goquerycmd/goquery.go
Comment thread cmd/fleetctl/fleetctl/goquerycmd/goquery.go
@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.

Walkthrough

The PR refactors the fleetctl goquery functionality by extracting the embedded implementation into a separate package and introducing a plugin-style registration mechanism. The goquery command in the main fleetctl package now delegates to a registered runner via SetGoqueryRunner instead of directly implementing the logic. A new goquerycmd package contains the goquery REPL implementation with Fleet client integration for host resolution, query scheduling, and result tracking. The main entrypoint wires these components together during initialization.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 44298-fix-goquery-dependency-side-effects

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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

@codecov

codecov Bot commented Apr 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.79%. Comparing base (392b485) to head (0824e0f).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
cmd/fleetctl/fleetctl/goquerycmd/goquery.go 0.00% 50 Missing ⚠️
cmd/fleetctl/fleetctl/goquery.go 0.00% 6 Missing ⚠️
cmd/fleetctl/main.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #44373      +/-   ##
==========================================
- Coverage   66.79%   66.79%   -0.01%     
==========================================
  Files        2631     2632       +1     
  Lines      211455   211466      +11     
  Branches     9543     9543              
==========================================
+ Hits       141240   141245       +5     
- Misses      57378    57385       +7     
+ Partials    12837    12836       -1     
Flag Coverage Δ
backend 68.57% <0.00%> (-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.

@lucasmrod
lucasmrod merged commit 3cadfa1 into main Apr 29, 2026
59 checks passed
@lucasmrod
lucasmrod deleted the 44298-fix-goquery-dependency-side-effects branch April 29, 2026 14:19
lucasmrod added a commit that referenced this pull request Apr 29, 2026
georgekarrv pushed a commit that referenced this pull request Apr 29, 2026
Resolves #44298

- [X] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.

## Testing

- [X] QA'd all new/changed functionality manually

1. Running the docker image pushed by this PR with the user 3333 doesn't
fail anymore:
```sh
docker run --platform linux/amd64 -it --user 3333:3333 fleetdm/fleet@sha256:1a06bcae25e13e37f871378c7c156f5a2cdf67bc3c3e3bcdc95b6afc0c6decbb
[...]
ts=2026-04-29T13:25:56Z level=warn msg="could not connect to db" err="dial tcp [::1]:3306: connect: connection refused" sleep_interval=0s
[...]
```
4.84.0 fails with:
```sh
docker run --platform linux/amd64 -it --user 3333:3333 fleetdm/fleet:v4.84.0@sha256:51b56ad59a840b28e074ff9b06d6d5b232b0ca2f0d999bb164820da69c7cbe15

Failed to fetch user info for home directory: user: unknown userid 33332026/04/29 13:28:08 71 <nil>
```
2. `strings ./build/fleet | rg github.com/AbGuthrie/goquery/v2` returns
nothing in this branch and returns plenty of matches in `main`.
3. Smoke tested `fleetctl goquery` functionality.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Resolved Docker image startup failures in Kubernetes environments
caused by a dependency side effect.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@georgekarrv

Copy link
Copy Markdown
Member

#44566

georgekarrv added a commit that referenced this pull request May 15, 2026
- **Adding vpp users table**
- **Adding ManagedAppleID to HostMDM tables to pull when installing vpp
apps to a BYOD user enrolled device**
- **Adding user create vpp apis**
- **Updating install application to support user enrolled devices**
- **Handling already installed gracefully**
- **Adding provision user logic**
- **Adding logic to associate assets on install**
- **Add license managemnt logic**
- **Adding self service ui**
- **Adding setup experience support**
- **Adding setup experience flow**
- **Fix issue with fleet's docker image in k8s environments (#44373)**
- **Changing how the appleid is captured to use idp mdm users**


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Account-based User Enrollment (iOS/iPadOS) supports VPP and in‑house
.ipa installs, including self‑service installs.
* Enrollment now applies the selected Setup experience automatically for
user‑enrolled hosts.
* Installs and license associations are scoped to account user
associations (user‑scoped installs).

* **Bug Fixes**
* Improved error messaging for license/association failures (including
per‑user device cap cases).
  * Mobile UI: self‑service now shows user‑enrolled iOS/iPadOS apps.
* “Already installed” install results are treated as acknowledged
successes.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/fleetdm/fleet/pull/45202)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

Docker/Kubernetes: Fleet 4.84.0 fails with unknown UID 3333

4 participants