Skip to content

Skip VPP label validation in dry runs - #46106

Merged
jkatz01 merged 3 commits into
mainfrom
45844-vpp-dry-run-new-label
May 25, 2026
Merged

Skip VPP label validation in dry runs #46106
jkatz01 merged 3 commits into
mainfrom
45844-vpp-dry-run-new-label

Conversation

@jkatz01

@jkatz01 jkatz01 commented May 22, 2026

Copy link
Copy Markdown
Member

Related issue: Resolves #45844
Skips label validation against the database in dry runs, because if new ones are being applied in the same run then they wouldnt be in the db ahead of time.

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

Summary by CodeRabbit

Release Notes

Bug Fixes

  • GitOps dry runs no longer fail when a VPP app references a label that is introduced within the same run.

Review Change Stack

}

// test vpp apps and packages dont validate labels on a dry run (issue #45844)
func (s *enterpriseIntegrationGitopsTestSuite) TestGitOpsTeamLabelAndSoftwareSameApply() {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm conflicted on if this test is actually necessary or not, but decided to include it and also test custom packages here.

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.

I think this is fine to have to catch this issue in the future if we end up removing it by accident etc.

@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.82%. Comparing base (2ef8049) to head (b546792).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
ee/server/service/vpp.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #46106      +/-   ##
==========================================
- Coverage   66.82%   66.82%   -0.01%     
==========================================
  Files        2754     2754              
  Lines      220158   220160       +2     
  Branches    10996    10996              
==========================================
+ Hits       147131   147132       +1     
  Misses      59733    59733              
- Partials    13294    13295       +1     
Flag Coverage Δ
backend 68.63% <60.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.

@jkatz01
jkatz01 marked this pull request as ready for review May 23, 2026 00:53
@jkatz01
jkatz01 requested a review from a team as a code owner May 23, 2026 00:53

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

@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR resolves an issue where fleetctl gitops --dry-run fails when a VPP app references a label created within the same apply. The fix moves label validation inside an if !dryRun guard in BatchAssociateVPPApps, allowing dry-run to proceed without querying the database for labels that have not yet been persisted. An integration test confirms that both dry-run and real apply succeed when team labels and VPP apps with matching labels_include_any are configured together. A changelog entry documents the fix.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Skip VPP label validation in dry runs' accurately summarizes the main change and is clear, concise, and specific to the primary modification in the changeset.
Description check ✅ Passed The description includes the related issue (#45844), explains the motivation for skipping validation, and confirms completion of relevant checklist items including changes file, automated tests, and manual QA.
Linked Issues check ✅ Passed The changes comprehensively address issue #45844 by skipping label validation during dry runs, adding test coverage for the specific scenario, and providing appropriate user-facing documentation via a changes file.
Out of Scope Changes check ✅ Passed All changes are directly related to resolving issue #45844: modifications to VPP label validation logic, a corresponding integration test, and a changes file documenting the fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 45844-vpp-dry-run-new-label

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: 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 `@ee/server/service/vpp.go`:
- Around line 335-340: The current gating of ValidateSoftwareLabels behind if
!dryRun skips structural validation (mutual-exclusivity of
payload.LabelsIncludeAny / LabelsExcludeAny / LabelsIncludeAll) during dry-run;
change the call so structural validation always runs: either call
ValidateSoftwareLabels unconditionally (keeping the existing ctx, svc, teamID,
payload.* and assigning validatedLabels) or refactor ValidateSoftwareLabels to
accept a flag (e.g., skipDBChecks bool) and invoke it with skipDBChecks=true for
dryRun so DB existence checks are skipped but mutual-exclusivity and other
structural checks still run; keep the existing error wrapping (ctxerr.Wrap) and
return behavior.
🪄 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: 48467db9-31ea-47ae-b24e-9b5ec1acf4a2

📥 Commits

Reviewing files that changed from the base of the PR and between a276ae2 and b546792.

📒 Files selected for processing (3)
  • changes/45844-gitops-vpp-dry-run-label-validation
  • cmd/fleetctl/integrationtest/gitops/gitops_enterprise_integration_test.go
  • ee/server/service/vpp.go

Comment thread ee/server/service/vpp.go
Comment on lines +335 to 340
if !dryRun {
validatedLabels, err = ValidateSoftwareLabels(ctx, svc, teamID, payload.LabelsIncludeAny, payload.LabelsExcludeAny, payload.LabelsIncludeAll)
if err != nil {
return nil, ctxerr.Wrap(ctx, err, "validating software labels for batch adding vpp app")
}
}

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Dry-run now skips structural label validation, not just DB existence checks.

On Line 335, gating the full ValidateSoftwareLabels call behind !dryRun also skips the mutual-exclusivity check (labels_include_any vs labels_exclude_any vs labels_include_all). That means invalid payloads can pass dry-run but fail on real apply.

Suggested fix
 			var validatedLabels *fleet.LabelIdentsWithScope
-			if !dryRun {
+			if dryRun {
+				// Keep dry-run fidelity for payload shape while skipping DB existence checks.
+				sets := 0
+				if len(payload.LabelsIncludeAny) > 0 {
+					sets++
+				}
+				if len(payload.LabelsExcludeAny) > 0 {
+					sets++
+				}
+				if len(payload.LabelsIncludeAll) > 0 {
+					sets++
+				}
+				if sets > 1 {
+					return nil, &fleet.BadRequestError{
+						Message: `Only one of "labels_include_all", "labels_include_any" or "labels_exclude_any" can be included.`,
+					}
+				}
+			} else {
 				validatedLabels, err = ValidateSoftwareLabels(ctx, svc, teamID, payload.LabelsIncludeAny, payload.LabelsExcludeAny, payload.LabelsIncludeAll)
 				if err != nil {
 					return nil, ctxerr.Wrap(ctx, err, "validating software labels for batch adding vpp app")
 				}
 			}
🤖 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 `@ee/server/service/vpp.go` around lines 335 - 340, The current gating of
ValidateSoftwareLabels behind if !dryRun skips structural validation
(mutual-exclusivity of payload.LabelsIncludeAny / LabelsExcludeAny /
LabelsIncludeAll) during dry-run; change the call so structural validation
always runs: either call ValidateSoftwareLabels unconditionally (keeping the
existing ctx, svc, teamID, payload.* and assigning validatedLabels) or refactor
ValidateSoftwareLabels to accept a flag (e.g., skipDBChecks bool) and invoke it
with skipDBChecks=true for dryRun so DB existence checks are skipped but
mutual-exclusivity and other structural checks still run; keep the existing
error wrapping (ctxerr.Wrap) and return behavior.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This seems to also be the case in BatchSetSoftwareInstallers, maybe ValidateSoftwareLabels should take in a dry_run parameter. Not addressing in this PR though.

@jkatz01
jkatz01 merged commit 5d59b0e into main May 25, 2026
46 checks passed
@jkatz01
jkatz01 deleted the 45844-vpp-dry-run-new-label branch May 25, 2026 16:04
jkatz01 added a commit that referenced this pull request May 27, 2026
Cherry-pick of #46106 into the RC branch.

Resolves #45844
Introduced to main in #46106
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.

GitOps dry-run fails when a new label is referenced by a vpp app in the same apply

2 participants