Skip to content

Commit d69ab78

Browse files
authored
Self-service: Include failed installs in "Install all" (#47684)
1 parent a950e24 commit d69ab78

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

server/datastore/mysql/software_installers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3941,13 +3941,13 @@ func (ds *Datastore) GetSoftwareTitlesForInstallAll(ctx context.Context, host *f
39413941
}
39423942
}
39433943

3944-
// filter out pending or already installed software, and software not in the category if one is provided
3944+
// filter out pending or already installed software, and software not in the category if one is provided.
3945+
// Failed install/uninstall states are included so they get re-queued (matches the per-row Retry behavior).
39453946
var toInstall []*fleet.HostSoftwareWithInstaller
39463947
for _, s := range software {
39473948
if s.Status != nil {
39483949
switch *s.Status {
3949-
case fleet.SoftwareInstallPending, fleet.SoftwareUninstallPending, fleet.SoftwareInstalled,
3950-
fleet.SoftwareInstallFailed, fleet.SoftwareUninstallFailed:
3950+
case fleet.SoftwareInstallPending, fleet.SoftwareUninstallPending, fleet.SoftwareInstalled:
39513951
continue
39523952
}
39533953
}

server/datastore/mysql/software_installers_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5624,7 +5624,8 @@ func testGetSoftwareTitlesForInstallAll(t *testing.T, ds *Datastore) {
56245624
ByName: map[string]fleet.LabelIdent{lbl.Name: {LabelID: lbl.ID, LabelName: lbl.Name}},
56255625
})
56265626

5627-
// skipped for various reasons
5627+
// previously installed/pending titles are skipped; failed_install and failed_uninstall
5628+
// are included so install_all re-queues them (matches per-row Retry).
56285629
installedID, _ := newInstaller("installed", true, nil, nil, noLabels)
56295630
installedUpdateID, _ := newInstaller("installed-update", true, nil, nil, noLabels)
56305631
failedID, _ := newInstaller("failed", true, nil, nil, noLabels)
@@ -5658,11 +5659,12 @@ func testGetSoftwareTitlesForInstallAll(t *testing.T, ds *Datastore) {
56585659
_, err = ds.InsertSoftwareInstallRequest(ctx, host.ID, pendingID, fleet.HostSoftwareInstallOptions{SelfService: true})
56595660
require.NoError(t, err)
56605661

5661-
// no category: only the available titles, returned in alphabetical order by name
5662+
// no category: only the available titles, returned in alphabetical order by name.
5663+
// failed_install and failed_uninstall are included so install_all re-queues them.
56625664
got, categoryName, err := ds.GetSoftwareTitlesForInstallAll(ctx, host, nil)
56635665
require.NoError(t, err)
56645666
require.Nil(t, categoryName)
5665-
require.Equal(t, []string{"available", "label-in", "uninstalled"}, names(got))
5667+
require.Equal(t, []string{"available", "failed", "failed-uninstall", "label-in", "uninstalled"}, names(got))
56665668

56675669
// scoped to a category: only the in-category title, and the name is returned
56685670
got, categoryName, err = ds.GetSoftwareTitlesForInstallAll(ctx, host, &cat.ID)

0 commit comments

Comments
 (0)