Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clear auto install policy statuses for vpp app scope changes #26121

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jahzielv
Copy link
Contributor

@jahzielv jahzielv commented Feb 5, 2025

For #26086

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements)
  • Added/updated automated tests
  • Manual QA for all new/changed functionality

@jahzielv jahzielv marked this pull request as ready for review February 6, 2025 01:36
@jahzielv jahzielv requested a review from a team as a code owner February 6, 2025 01:36
Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 77.94118% with 15 lines in your changes missing coverage. Please review.

Project coverage is 63.60%. Comparing base (4b1472d) to head (0c1db61).
Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
ee/server/service/vpp.go 75.67% 6 Missing and 3 partials ⚠️
server/datastore/mysql/software_installers.go 66.66% 2 Missing and 2 partials ⚠️
ee/server/service/software_installers.go 0.00% 0 Missing and 1 partial ⚠️
server/datastore/mysql/vpp.go 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #26121   +/-   ##
=======================================
  Coverage   63.59%   63.60%           
=======================================
  Files        1631     1631           
  Lines      156402   156486   +84     
  Branches     4037     4037           
=======================================
+ Hits        99471    99535   +64     
- Misses      49093    49110   +17     
- Partials     7838     7841    +3     
Flag Coverage Δ
backend 64.44% <77.94%> (+<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.

Copy link
Member

@iansltx iansltx left a comment

Choose a reason for hiding this comment

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

In addition to the comments here, seems like we're missing the policy status clear side effect for bulk VPP app actions (for GitOps). Given that the code paths for labels are basically the same for package-based installers and VPP apps, thinking we're missing the side effect for both, and the code for fixing one is trivially expandable to fixing both. Does that sound right?

@@ -46,6 +46,11 @@ WHERE
teamFilter = "AND vat.global_or_team_id = ?"
}

// var tmID uint
Copy link
Member

Choose a reason for hiding this comment

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

?

@@ -495,8 +500,8 @@ ON DUPLICATE KEY UPDATE
if insertOnDuplicateDidInsertOrUpdate(res) {
id, _ = res.LastInsertId()
} else {
stmt := `SELECT id FROM vpp_apps_teams WHERE adam_id = ? AND platform = ?`
if err := sqlx.GetContext(ctx, tx, &id, stmt, appID.AdamID, appID.Platform); err != nil {
stmt := `SELECT id FROM vpp_apps_teams WHERE adam_id = ? AND platform = ? AND global_or_team_id = ?`
Copy link
Member

Choose a reason for hiding this comment

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

Yay for finding another unreleased bug while fixing the first one 😅

updateAppReq := &updateAppStoreAppRequest{TeamID: &team.ID, SelfService: false, LabelsIncludeAny: []string{lbl2.Name}}
s.Do("PATCH", fmt.Sprintf("/api/latest/fleet/software/titles/%d/app_store_app", vppAppTitleID), updateAppReq, http.StatusOK)

// Result should have been cleared for the policy
Copy link
Member

Choose a reason for hiding this comment

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

Wait...this doesn't seem right? Moving out of scope shouldn't clear the policy status, since we don't need the reset until the automation might need to fire. Moving back in should. Or am I getting things swapped around?

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.

2 participants