Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion evaluator/advisory_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func TestCreateAdvisoryUpdateEvent(t *testing.T) {
WorkspaceID: wsID,
WorkspaceName: &wsName,
},
Patch: models.SystemPatch{},
}

changedAdvisoryIDs := []int64{1, 2}
Expand Down
3 changes: 3 additions & 0 deletions evaluator/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var (
enableAdvisoryUpdates bool
enableSatelliteFunctionality bool
enableTemplateAdvisoryEval bool
enableAdvisoryAccountData bool
errVmaasBadRequest = errors.New("vmaas bad request")
)

Expand Down Expand Up @@ -96,6 +97,8 @@ func configureEvaluator() {
disableCompression = !utils.PodConfig.GetBool("vmaas_call_compression", true)
// Evaluate advisories
enableAdvisoryAnalysis = utils.PodConfig.GetBool("advisory_analysis", true)
// Update legacy advisory_account_data counts during evaluation
enableAdvisoryAccountData = utils.PodConfig.GetBool("advisory_account_data", true)
// evaluate packages
enablePackageAnalysis = utils.PodConfig.GetBool("package_analysis", true)
// Look for third party repos
Expand Down
5 changes: 5 additions & 0 deletions evaluator/evaluate_advisories.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,11 @@ func updateAdvisoryAccountData(
system *models.SystemPlatformV2,
advisoriesByName extendedAdvisoryMap,
) error {
if !enableAdvisoryAccountData {
utils.LogInfo("inventoryID", system.GetInventoryID(), "advisory_account_data updates disabled, skipping")
return nil
}
Comment thread
MichaelMraka marked this conversation as resolved.

changes := calcAdvisoryChanges(system, advisoriesByName)

if len(changes) == 0 {
Expand Down
39 changes: 39 additions & 0 deletions evaluator/evaluate_advisories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,45 @@ func TestUpdateAdvisoryAccountData(t *testing.T) {
database.DeleteAdvisoryAccountData(t, system.Inventory.RhAccountID, advisoryIDs)
}

func TestUpdateAdvisoryAccountDataDisabled(t *testing.T) {
utils.SkipWithoutDB(t)
core.SetupTestEnvironment()

prev := enableAdvisoryAccountData
enableAdvisoryAccountData = false
defer func() { enableAdvisoryAccountData = prev }()

system := &models.SystemPlatformV2{
Inventory: models.SystemInventory{ID: 12, RhAccountID: 3},
Patch: models.SystemPatch{},
}
advisoryIDs := []int64{2, 3, 4}
database.CreateAdvisoryAccountData(t, system.Inventory.RhAccountID, advisoryIDs, 1)
defer database.DeleteAdvisoryAccountData(t, system.Inventory.RhAccountID, advisoryIDs)

advisoriesByName := extendedAdvisoryMap{
"ER-2": {
change: Remove,
SystemAdvisories: models.SystemAdvisories{
AdvisoryID: 2, SystemID: system.InternalSystemID(), RhAccountID: system.Inventory.RhAccountID},
},
"ER-3": {
change: Remove,
SystemAdvisories: models.SystemAdvisories{
AdvisoryID: 3, SystemID: system.InternalSystemID(), RhAccountID: system.Inventory.RhAccountID},
},
"ER-4": {
change: Remove,
SystemAdvisories: models.SystemAdvisories{
AdvisoryID: 4, SystemID: system.InternalSystemID(), RhAccountID: system.Inventory.RhAccountID},
},
}

err := updateAdvisoryAccountData(database.DB, system, advisoriesByName)
assert.NoError(t, err)
database.CheckAdvisoriesAccountData(t, system.Inventory.RhAccountID, advisoryIDs, 1)
}

func TestGetMissingAdvisories(t *testing.T) {
utils.SkipWithoutDB(t)
core.SetupTestEnvironment()
Expand Down
Loading