Skip to content

Add combined include/exclude label targeting for MDM profiles (API and GitOps)#46437

Merged
andymFleet merged 28 commits into
mainfrom
45180-cpie-api-gitops-include-exclude-targeting
Jun 3, 2026
Merged

Add combined include/exclude label targeting for MDM profiles (API and GitOps)#46437
andymFleet merged 28 commits into
mainfrom
45180-cpie-api-gitops-include-exclude-targeting

Conversation

@andymFleet

@andymFleet andymFleet commented May 29, 2026

Copy link
Copy Markdown
Contributor

Related issue: Resolves #45180

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.

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.

Testing

  • Added/updated automated tests

  • QA'd all new/changed functionality manually

For unreleased bug fixes in a release candidate, one of:

  • Confirmed that the fix is not expected to adversely impact load test results

Summary by CodeRabbit

  • New Features

    • MDM profiles can combine label inclusion (include-all/include-any) with exclusion (exclude-any) so you can target hosts by labels while excluding specific labeled hosts.
    • Profile validation now enforces a single include-mode and explicitly rejects any label used in both include and exclude lists.
  • Bug Fixes

    • Deleting a label that’s referenced by an MDM configuration profile or declaration is blocked and returns an error to prevent broken targeting.

Copilot AI review requested due to automatic review settings May 29, 2026 12:00
@andymFleet andymFleet requested a review from a team as a code owner May 29, 2026 12: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.

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 updates MDM configuration profile label targeting so profiles/declarations can combine an include label mode with labels_exclude_any, while preventing overlapping include/exclude labels and blocking deletion of labels referenced by MDM profiles.

Changes:

  • Relaxed profile label validation across API, app config, team specs, and GitOps label usage to allow include + exclude combinations.
  • Added overlap detection for labels appearing in both include and exclude lists.
  • Added datastore-level deletion guard and tests for labels referenced by MDM profiles/declarations.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
server/service/windows_mdm_profiles.go Passes and validates excluded labels separately for Windows profiles.
server/service/testing_client_test.go Updates teardown to null MDM profile/declaration label references before deleting labels.
server/service/mdm.go Updates multipart/batch validation and profile creation dispatch for include + exclude targeting.
server/service/mdm_test.go Updates service test callers for the new profile creation signatures.
server/service/integration_mdm_profiles_test.go Updates integration coverage for valid include + exclude targeting and overlap errors.
server/service/apple_mdm.go Adds separate excluded-label handling for Apple profiles and declarations.
server/service/apple_mdm_test.go Updates Apple service tests for the new method signatures.
server/service/appconfig.go Updates app config validation for include modes and include/exclude overlap.
server/mock/service/service_mock.go Updates mock service signatures and forwarding.
server/fleet/service.go Updates service interface signatures.
server/fleet/mdm.go Adds helper for detecting include/exclude label overlap.
server/datastore/mysql/labels.go Blocks label deletion when referenced by MDM profile/declaration label rows.
server/datastore/mysql/labels_test.go Adds deletion-blocking coverage for profile/declaration label references.
ee/server/service/teams.go Updates team custom settings validation for include + exclude targeting.
cmd/fleetctl/fleetctl/gitops.go Updates GitOps label usage collection for MDM custom settings.
cmd/fleetctl/fleetctl/gitops_label_usage_test.go Adds GitOps label usage tests for include + exclude combinations.
changes/32073-cpie-integration-test2 Adds changelog entry for targeting and label deletion behavior.

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

Comment thread server/datastore/mysql/labels.go
Comment thread server/service/testing_client_test.go Outdated
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This PR allows combining labels_exclude_any with a single include mode for MDM profiles, enforces that only one include mode is specified, rejects any label present in both include and exclude lists, propagates exclude lists through profile creation APIs (Apple/Windows/Android), updates Service signatures and mocks, updates Fleetctl/GitOps label usage, prevents deleting labels referenced by MDM profiles/declarations, and updates tests and fixtures to reflect these behaviors.

Possibly related PRs

  • fleetdm/fleet#44983: Changes related to preventing deletion of referenced labels and handling NULL label_id in batch SQL, which overlaps with this PR's label-deletion-prevention and test updates.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.23% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding combined include/exclude label targeting for MDM profiles across both API and GitOps interfaces.
Description check ✅ Passed The PR description is mostly complete with the related issue linked and key checklist items marked as completed, though some sections were omitted as noted in instructions.
Linked Issues check ✅ Passed The changeset comprehensively addresses all objectives from issue #45180: allows mixing include-any/include-all with exclude labels [multiple files], prevents mixing include-any with include-all [gitops.go, appconfig.go, service/mdm.go], blocks label deletion when referenced by profiles [labels.go], and updates all integration tests [integration_mdm_profiles_test.go].
Out of Scope Changes check ✅ Passed All changes are directly scoped to the objectives: label validation logic, MDM profile creation signatures, database constraints, test updates, and mock service updates—no unrelated modifications found.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 45180-cpie-api-gitops-include-exclude-targeting

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.

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (1)
server/service/mdm.go (1)

1843-1895: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Enforce the include/exclude overlap rule in the service method.

NewMDMAndroidConfigProfile validates both label sets separately, but it never rejects a label that appears in both labels and labelsExcludeAny. That means a direct service caller can still persist the contradictory targeting this PR is supposed to forbid, even though the request decoders and batch validator already block it.

Suggested fix
 func (svc *Service) NewMDMAndroidConfigProfile(ctx context.Context, teamID uint, profileName string, data []byte, labels []string, labelsMembershipMode fleet.MDMLabelsMode, labelsExcludeAny []string) (*fleet.MDMAndroidConfigProfile, error) {
 	if err := svc.authz.Authorize(ctx, &fleet.MDMConfigProfileAuthz{TeamID: &teamID}, fleet.ActionWrite); err != nil {
 		return nil, ctxerr.Wrap(ctx, err)
 	}
@@
 	if err := cp.ValidateUserProvided(license.IsPremium(ctx)); err != nil {
 		err := &fleet.BadRequestError{Message: "Couldn't add. " + err.Error()}
 		return nil, ctxerr.Wrap(ctx, err, "validate profile")
 	}
+
+	if overlap := fleet.ProfileLabelOverlap(labels, labelsExcludeAny); overlap != "" {
+		return nil, ctxerr.Wrap(ctx,
+			fleet.NewInvalidArgumentError("labels_exclude_any",
+				fmt.Sprintf(`Label %q cannot appear in both include and exclude lists.`, overlap)),
+			"validate profile labels",
+		)
+	}
 
 	labelMap, err := svc.validateProfileLabels(ctx, &teamID, labels)
 	if err != nil {
 		return nil, ctxerr.Wrap(ctx, err, "validating labels")
 	}
🧹 Nitpick comments (3)
server/service/integration_mdm_profiles_test.go (1)

3833-3837: ⚡ Quick win

Narrow the broken-label simulation update scope.

At Line 3836, WHERE label_id = ? updates all associations for that label in the test DB. Scope it to the three profiles created in this test to keep isolation robust.

💡 Suggested diff
 mysqltest.ExecAdhocSQL(t, s.ds, func(q sqlx.ExtContext) error {
-	_, err := q.ExecContext(ctx, `UPDATE mdm_configuration_profile_labels SET label_id = NULL WHERE label_id = ?`, lblFoo.ID)
+	_, err := q.ExecContext(ctx, `
+		UPDATE mdm_configuration_profile_labels
+		SET label_id = NULL
+		WHERE label_id = ?
+		  AND apple_profile_uuid IN (?, ?, ?)`,
+		lblFoo.ID, tm2ProfF.ProfileUUID, tm2ProfG.ProfileUUID, tm2ProfH.ProfileUUID)
 	return err
 })

As per coding guidelines: “When reviewing SQL queries that are added or modified, ensure that appropriate filtering criteria are applied… check for missing WHERE clauses or incorrect filtering that could lead to incorrect or non-deterministic results.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/service/integration_mdm_profiles_test.go` around lines 3833 - 3837,
The SQL update currently nullifies all rows for lblFoo via
mysqltest.ExecAdhocSQL on mdm_configuration_profile_labels WHERE label_id = ?,
which affects every association for that label; restrict the update to only the
three profiles created in this test by adding an explicit filter on profile IDs
(e.g., WHERE label_id = ? AND profile_id IN (...)) using the test's profile ID
variables (the slice/vars holding the three created profile IDs) so only those
three associations are nullified.
server/service/testing_client_test.go (1)

183-191: 💤 Low value

Consider deleting label association records instead of nulling them.

The current approach sets label_id = NULL in the MDM profile/declaration label tables to work around the new RESTRICT FK constraints. While this allows label deletion to proceed, it leaves orphaned records in mdm_configuration_profile_labels and mdm_declaration_labels.

For cleaner test state, consider deleting these records entirely:

DELETE FROM mdm_configuration_profile_labels WHERE label_id IS NOT NULL
DELETE FROM mdm_declaration_labels WHERE label_id IS NOT NULL

This would ensure no leftover association records accumulate across test runs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/service/testing_client_test.go` around lines 183 - 191, Replace the
UPDATE-null workaround with deletes so we remove association rows instead of
leaving orphans: inside the mysqltest.ExecAdhocSQL block that currently executes
UPDATE mdm_configuration_profile_labels and UPDATE mdm_declaration_labels,
execute DELETE FROM mdm_configuration_profile_labels WHERE label_id IS NOT NULL
and DELETE FROM mdm_declaration_labels WHERE label_id IS NOT NULL instead (i.e.,
update the SQL executed by mysqltest.ExecAdhocSQL in testing_client_test.go to
perform deletes rather than setting label_id = NULL).
cmd/fleetctl/fleetctl/gitops_label_usage_test.go (1)

73-98: ⚡ Quick win

Add the overlap rejection case here too.

These cases only prove that include+exclude is allowed. They don't cover the required failure mode where the same label appears in both lists, so the current regression in getLabelUsage would still pass the test suite.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/fleetctl/fleetctl/gitops_label_usage_test.go` around lines 73 - 98,
Update TestGetLabelUsageIncludeAndExcludeAllowed to also assert the overlap
rejection: add a case where the same label appears in both an include list and
an exclude list (e.g., LabelsIncludeAny/LabelsIncludeAll and LabelsExcludeAny
using the same string) for a fleet.MDMProfileSpec, call getLabelUsage(config)
and require that it returns a non-nil error (rather than succeeding), and ensure
the test checks that this overlapping-label scenario is treated as invalid by
getLabelUsage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/fleetctl/fleetctl/gitops.go`:
- Around line 853-857: The code currently only rejects using both
LabelsIncludeAll and LabelsIncludeAny together but does not prevent the same
label appearing in an include list and in LabelsExcludeAny; add a check before
calling updateLabelUsage to detect any overlap between setting.LabelsExcludeAny
and the union of setting.LabelsIncludeAll and setting.LabelsIncludeAny (compute
intersection of those slices), and if any conflicting labels are found return an
error (include filepath.Base(setting.Path) and the conflicting label names) so
the profile is rejected early; keep using the same symbols
(setting.LabelsIncludeAll, setting.LabelsIncludeAny, setting.LabelsExcludeAny,
updateLabelUsage) to locate where to insert the check.

In `@server/service/windows_mdm_profiles.go`:
- Around line 80-86: When validating labelsExcludeAny in windows_mdm_profiles.go
(the block that calls svc.validateProfileLabels and assigns
cp.LabelsExcludeAny), add a check that rejects any label that appears in both
the include set (cp.Labels or labels from the earlier validateProfileLabels
call) and the exclude set: compute the intersection between the validated
include labels (cp.Labels or the map returned for labels) and the excludeMap
returned for labelsExcludeAny, and if any overlap exists return an error (use
ctxerr.Wrap for consistency) indicating conflicting include/exclude labels so
contradictory profiles cannot be created.

---

Nitpick comments:
In `@cmd/fleetctl/fleetctl/gitops_label_usage_test.go`:
- Around line 73-98: Update TestGetLabelUsageIncludeAndExcludeAllowed to also
assert the overlap rejection: add a case where the same label appears in both an
include list and an exclude list (e.g., LabelsIncludeAny/LabelsIncludeAll and
LabelsExcludeAny using the same string) for a fleet.MDMProfileSpec, call
getLabelUsage(config) and require that it returns a non-nil error (rather than
succeeding), and ensure the test checks that this overlapping-label scenario is
treated as invalid by getLabelUsage.

In `@server/service/integration_mdm_profiles_test.go`:
- Around line 3833-3837: The SQL update currently nullifies all rows for lblFoo
via mysqltest.ExecAdhocSQL on mdm_configuration_profile_labels WHERE label_id =
?, which affects every association for that label; restrict the update to only
the three profiles created in this test by adding an explicit filter on profile
IDs (e.g., WHERE label_id = ? AND profile_id IN (...)) using the test's profile
ID variables (the slice/vars holding the three created profile IDs) so only
those three associations are nullified.

In `@server/service/testing_client_test.go`:
- Around line 183-191: Replace the UPDATE-null workaround with deletes so we
remove association rows instead of leaving orphans: inside the
mysqltest.ExecAdhocSQL block that currently executes UPDATE
mdm_configuration_profile_labels and UPDATE mdm_declaration_labels, execute
DELETE FROM mdm_configuration_profile_labels WHERE label_id IS NOT NULL and
DELETE FROM mdm_declaration_labels WHERE label_id IS NOT NULL instead (i.e.,
update the SQL executed by mysqltest.ExecAdhocSQL in testing_client_test.go to
perform deletes rather than setting label_id = NULL).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3f8c8a7e-6021-4208-bff6-a3bd1709c02e

📥 Commits

Reviewing files that changed from the base of the PR and between 4462067 and 7aa45c4.

📒 Files selected for processing (17)
  • changes/32073-cpie-integration-test2
  • cmd/fleetctl/fleetctl/gitops.go
  • cmd/fleetctl/fleetctl/gitops_label_usage_test.go
  • ee/server/service/teams.go
  • server/datastore/mysql/labels.go
  • server/datastore/mysql/labels_test.go
  • server/fleet/mdm.go
  • server/fleet/service.go
  • server/mock/service/service_mock.go
  • server/service/appconfig.go
  • server/service/apple_mdm.go
  • server/service/apple_mdm_test.go
  • server/service/integration_mdm_profiles_test.go
  • server/service/mdm.go
  • server/service/mdm_test.go
  • server/service/testing_client_test.go
  • server/service/windows_mdm_profiles.go

Comment thread cmd/fleetctl/fleetctl/gitops.go
Comment thread server/service/windows_mdm_profiles.go Outdated
@andymFleet andymFleet marked this pull request as draft May 29, 2026 12:16
@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.75630% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.90%. Comparing base (790bfa8) to head (2141be5).

Files with missing lines Patch % Lines
server/service/apple_mdm.go 66.66% 3 Missing and 2 partials ⚠️
server/datastore/mysql/labels.go 80.00% 1 Missing and 1 partial ⚠️
server/service/mdm.go 95.91% 1 Missing and 1 partial ⚠️
server/service/windows_mdm_profiles.go 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #46437   +/-   ##
=======================================
  Coverage   66.90%   66.90%           
=======================================
  Files        2831     2831           
  Lines      224929   224943   +14     
  Branches    11524    11487   -37     
=======================================
+ Hits       150481   150494   +13     
  Misses      60796    60796           
- Partials    13652    13653    +1     
Flag Coverage Δ
backend 68.61% <90.75%> (+<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.

@andymFleet andymFleet changed the title 45180 cpie api gitops include exclude targeting Add combined include/exclude label targeting for MDM profiles (API and GitOps) May 29, 2026
@andymFleet andymFleet marked this pull request as ready for review May 29, 2026 15:57
@andymFleet andymFleet marked this pull request as draft May 29, 2026 20:03
@andymFleet andymFleet marked this pull request as ready for review May 29, 2026 21:11

@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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/datastore/mysql/apple_mdm_test.go`:
- Around line 310-312: The UPDATE in ExecAdhocSQL currently nulls label_id for
all rows matching lbl.ID in mdm_configuration_profile_labels; narrow the WHERE
clause to the specific profile under test by adding the profile identifier (e.g.
apple_profile_uuid or the profile id) to the predicate so the ExecContext call
only updates rows where label_id = ? AND apple_profile_uuid = <profileUUID> (or
the corresponding profile id variable) to avoid cross-row mutations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 18e2ac4e-89f4-47ac-b747-28cafba289d1

📥 Commits

Reviewing files that changed from the base of the PR and between 8f43c6b and d448e88.

📒 Files selected for processing (7)
  • cmd/fleetctl/fleetctl/gitops_test.go
  • cmd/fleetctl/fleetctl/testdata/gitops/global_windows_custom_settings_invalid_label_mix.yml
  • server/datastore/mysql/apple_mdm_test.go
  • server/datastore/mysql/mdm_test.go
  • server/datastore/mysql/microsoft_mdm_test.go
  • server/service/integration_mdm_profiles_test.go
  • server/service/mdm.go
✅ Files skipped from review due to trivial changes (1)
  • cmd/fleetctl/fleetctl/testdata/gitops/global_windows_custom_settings_invalid_label_mix.yml
🚧 Files skipped from review as they are similar to previous changes (2)
  • server/service/integration_mdm_profiles_test.go
  • server/service/mdm.go

Comment thread server/datastore/mysql/apple_mdm_test.go

@JordanMontgomery JordanMontgomery left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One other comment I'm wondering about is if the label validation function can be updated to only do a single validation, rather than once for include labels and once for exclude labels. The reason I ask is it looks like the existing Batch endpoint already does that which makes me think the function probably supports it just fine, though not sure if it makes the code any more or less readable it would reduce the number of hits to the DB for a profile upload

Comment thread server/fleet/service.go Outdated
Comment thread server/service/windows_mdm_profiles.go Outdated

@MagnusHJensen MagnusHJensen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good overall!

Comment thread cmd/fleetctl/fleetctl/gitops.go Outdated
Comment thread server/fleet/mdm.go Outdated
Comment thread cmd/fleetctl/fleetctl/gitops_label_usage_test.go
Comment thread ee/server/service/teams.go Outdated
Comment thread server/service/appconfig.go Outdated
Comment thread server/service/mdm.go
Comment thread server/fleet/service.go
@andymFleet andymFleet force-pushed the 45180-cpie-api-gitops-include-exclude-targeting branch from d02215d to 2a305c6 Compare June 3, 2026 13:21
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

CI Feedback 🧐

A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

Action: aggregate-result

Failed stage: Check for failures [❌]

Failed test name: vuln-mysql8.0.44

Failure summary:

The action failed because one of the downloaded test job status artifacts reported a failure:
- The
status file ./vuln-mysql8.0.44-status/status contained fail (log lines 166-167), so the script added
vuln-mysql8.0.44 to failed_tests.
- The workflow then exited with code 1 when failed_tests was
non-empty, reporting ❌ One or more test jobs failed: vuln-mysql8.0.44 (log lines 157-160, 184-185).

Relevant error logs:
1:  ##[group]Runner Image Provisioner
2:  Hosted Compute Agent
...

119:  Artifact download completed successfully.
120:  Extracting artifact entry: /home/runner/work/fleet/fleet/integration-enterprise-mysql8.0.44-status/status
121:  Artifact download completed successfully.
122:  Extracting artifact entry: /home/runner/work/fleet/fleet/fast-status/status
123:  Artifact download completed successfully.
124:  Extracting artifact entry: /home/runner/work/fleet/fleet/service-mysql8.0.44-status/status
125:  Artifact download completed successfully.
126:  Extracting artifact entry: /home/runner/work/fleet/fleet/integration-core-mysql8.0.44-status/status
127:  Artifact download completed successfully.
128:  Extracting artifact entry: /home/runner/work/fleet/fleet/scripts-status/status
129:  Artifact download completed successfully.
130:  Extracting artifact entry: /home/runner/work/fleet/fleet/vuln-mysql8.0.44-status/status
131:  Artifact download completed successfully.
132:  Total of 10 artifact(s) downloaded
133:  Download artifact has finished successfully
134:  ##[group]Run failed_tests=""
135:  �[36;1mfailed_tests=""�[0m
136:  �[36;1mstatus_count=0�[0m
137:  �[36;1m# Find all status files (they are in directories like 'fleetctl-mysql8.0.44-status/status')�[0m
138:  �[36;1mfor status_file in $(find ./ -type f -name 'status'); do�[0m
139:  �[36;1m  status_count=$((status_count + 1))�[0m
140:  �[36;1m  # Extract test name from parent directory (e.g., 'fleetctl-mysql8.0.44-status')�[0m
141:  �[36;1m  test_dir=$(basename $(dirname "$status_file"))�[0m
142:  �[36;1m  # Remove '-status' suffix to get the test name�[0m
143:  �[36;1m  test_name="${test_dir%-status}"�[0m
144:  �[36;1m  status_content=$(cat "$status_file")�[0m
145:  �[36;1m  echo "Processing: $status_file (Test: $test_name) with status content: $status_content"�[0m
146:  �[36;1m  if grep -q "fail" "$status_file"; then�[0m
147:  �[36;1m    echo "  ❌ Test failed: $test_name"�[0m
148:  �[36;1m    failed_tests="${failed_tests}${test_name}, "�[0m
149:  �[36;1m  else�[0m
150:  �[36;1m    echo "  ✅ Test passed: $test_name"�[0m
151:  �[36;1m  fi�[0m
152:  �[36;1mdone�[0m
153:  �[36;1mif [[ $status_count -eq 0 ]]; then�[0m
154:  �[36;1m  echo "❌ ERROR: No status files found! This indicates a workflow issue."�[0m
155:  �[36;1m  exit 1�[0m
156:  �[36;1mfi�[0m
157:  �[36;1mif [[ -n "$failed_tests" ]]; then�[0m
158:  �[36;1m  echo "❌ One or more test jobs failed: ${failed_tests%, }"�[0m
159:  �[36;1m  exit 1�[0m
160:  �[36;1mfi�[0m
161:  �[36;1mecho "✅ All test jobs succeeded."�[0m
162:  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
163:  ##[endgroup]
164:  Processing: ./integration-core-mysql8.0.44-status/status (Test: integration-core-mysql8.0.44) with status content: success
165:  ✅ Test passed: integration-core-mysql8.0.44
166:  Processing: ./vuln-mysql8.0.44-status/status (Test: vuln-mysql8.0.44) with status content: fail
167:  ❌ Test failed: vuln-mysql8.0.44
168:  Processing: ./service-mysql8.0.44-status/status (Test: service-mysql8.0.44) with status content: success
169:  ✅ Test passed: service-mysql8.0.44
170:  Processing: ./main-mysql8.0.44-status/status (Test: main-mysql8.0.44) with status content: success
171:  ✅ Test passed: main-mysql8.0.44
172:  Processing: ./fleetctl-mysql8.0.44-status/status (Test: fleetctl-mysql8.0.44) with status content: success
173:  ✅ Test passed: fleetctl-mysql8.0.44
174:  Processing: ./integration-enterprise-mysql8.0.44-status/status (Test: integration-enterprise-mysql8.0.44) with status content: success
175:  ✅ Test passed: integration-enterprise-mysql8.0.44
176:  Processing: ./fast-status/status (Test: fast) with status content: success
177:  ✅ Test passed: fast
178:  Processing: ./mysql-mysql8.0.44-status/status (Test: mysql-mysql8.0.44) with status content: success
179:  ✅ Test passed: mysql-mysql8.0.44
180:  Processing: ./integration-mdm-mysql8.0.44-status/status (Test: integration-mdm-mysql8.0.44) with status content: success
181:  ✅ Test passed: integration-mdm-mysql8.0.44
182:  Processing: ./scripts-status/status (Test: scripts) with status content: success
183:  ✅ Test passed: scripts
184:  ❌ One or more test jobs failed: vuln-mysql8.0.44
185:  ##[error]Process completed with exit code 1.
186:  Post job cleanup.

@MagnusHJensen MagnusHJensen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good work

@andymFleet andymFleet merged commit d7d9a96 into main Jun 3, 2026
43 of 45 checks passed
@andymFleet andymFleet deleted the 45180-cpie-api-gitops-include-exclude-targeting branch June 3, 2026 14:24
@coderabbitai coderabbitai Bot mentioned this pull request Jul 10, 2026
4 tasks
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.

CPIE: API + gitops changes to allow upload of labels targeting include+exclude rules, prevent broken labels

4 participants