Skip to content

Commit

Permalink
RHINENG-8141: update function doc comments to adhere to go conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dugowitch committed Aug 7, 2024
1 parent f570014 commit ac7d368
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions evaluator/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func Evaluate(ctx context.Context, event *mqueue.PlatformEvent, inventoryID, eva
return nil
}

// Runs Evaluate method in Goroutines
// RunEvaluate runs Evaluate method in Goroutines
func runEvaluate(
ctx context.Context,
event mqueue.PlatformEvent, // makes a copy to avoid races
Expand Down Expand Up @@ -447,8 +447,8 @@ func commitWithObserve(tx *gorm.DB) error {
return nil
}

// First, load advisories and packages (including change evaluation).
// Then, in a single transaction, do the deletions, updates, and insertions.
// EvaluateAndStore first loads advisories and packages (including change evaluation)
// and then executes all deletions, updates, and insertions in a single transaction.
func evaluateAndStore(system *models.SystemPlatform,
vmaasData *vmaas.UpdatesV3Response, event *mqueue.PlatformEvent) error {
advisoriesByName, err := lazySaveAndLoadAdvisories(system, vmaasData)
Expand Down
12 changes: 7 additions & 5 deletions evaluator/evaluate_advisories.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
"gorm.io/gorm/clause"
)

// Lazy save missing advisories from reported, load stored ones, and evaluate changes between the two.
// LazySaveAndLoadAdvisories lazy saves missing advisories from reported, loads stored ones from DB,
// and evaluates changes between the two.
func lazySaveAndLoadAdvisories(system *models.SystemPlatform, vmaasData *vmaas.UpdatesV3Response) (
extendedAdvisoryMap, error) {
if !enableAdvisoryAnalysis {
Expand All @@ -38,7 +39,7 @@ func lazySaveAndLoadAdvisories(system *models.SystemPlatform, vmaasData *vmaas.U
return merged, nil
}

// Create extendedAdvisoryMap from `stored` and `reported` advisories. It tracks changes between the two.
// PasrseReported evaluates changes of type Add/Update/Keep and tracks them in extendedAdvisoryMap.
func pasrseReported(stored SystemAdvisoryMap, reported map[string]int) (extendedAdvisoryMap, []string) {
extendedAdvisories := make(extendedAdvisoryMap, len(reported)+len(stored))
missingNames := make([]string, 0, len(reported))
Expand Down Expand Up @@ -104,7 +105,8 @@ func parseStored(stored SystemAdvisoryMap, reported map[string]int, extendedAdvi
}
}

// Evaluate changes to all advisories based on `stored` advisories from DB and `reported` advisories from VMaaS.
// EvaluateChanges calls functions that evaluate all types of changes between stored advisories from DB
// and reported advisories from VMaaS.
func evaluateChanges(vmaasData *vmaas.UpdatesV3Response, stored SystemAdvisoryMap) (
extendedAdvisoryMap, error) {
reported := getReportedAdvisories(vmaasData)
Expand All @@ -120,7 +122,7 @@ func evaluateChanges(vmaasData *vmaas.UpdatesV3Response, stored SystemAdvisoryMa
return extendedAdvisories, nil
}

// From names reported by VMaaS, find advisories missing in the DB and lazy-save them.
// LazySaveAdvisories finds advisories reported by VMaaS and missing in the DB and lazy saves them.
func lazySaveAdvisories(vmaasData *vmaas.UpdatesV3Response, inventoryID string) error {
reportedNames := getReportedAdvisoryNames(vmaasData)
if len(reportedNames) < 1 {
Expand Down Expand Up @@ -186,7 +188,7 @@ func getAdvisoryMetadataByNames(names []string) (models.AdvisoryMetadataSlice, e
return metadata, err
}

// Determine if advisories from DB are properly stored based on advisory metadata existence.
// GetMissingAdvisories determines if advisories from DB are properly stored based on advisory metadata existence.
func getMissingAdvisories(advisoryNames []string) ([]string, error) {
advisoryMetadata, err := getAdvisoryMetadataByNames(advisoryNames)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions evaluator/evaluate_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func lazySaveAndLoadPackages(system *models.SystemPlatform, vmaasData *vmaas.Upd
return pkgByName, installed, installable, applicable, nil
}

// Add unknown EVRAs into the db if needed
// LazySavePackages adds unknown EVRAs into the db if needed.
func lazySavePackages(vmaasData *vmaas.UpdatesV3Response) error {
if !enableLazyPackageSave {
return nil
Expand Down Expand Up @@ -89,7 +89,7 @@ func getMissingPackage(nevra string) *models.Package {
return &pkg
}

// Get packages with known name but version missing in db/cache
// GetMissingPackages gets packages with a known name but a version missing in db/cache.
func getMissingPackages(vmaasData *vmaas.UpdatesV3Response) models.PackageSlice {
updates := vmaasData.GetUpdateList()
packages := make(models.PackageSlice, 0, len(updates))
Expand Down Expand Up @@ -130,7 +130,7 @@ func updatePackageNameDB(missing *models.PackageName) error {
return nil
}

// Find relevant package data based on vmaas results
// LoadPackages finds relevant package data based on vmaas results.
func loadPackages(system *models.SystemPlatform, vmaasData *vmaas.UpdatesV3Response) (
map[string]namedPackage, int, int, int, error) {
defer utils.ObserveSecondsSince(time.Now(), evaluationPartDuration.WithLabelValues("packages-load"))
Expand Down

0 comments on commit ac7d368

Please sign in to comment.