-
Notifications
You must be signed in to change notification settings - Fork 34
HMS-5913: add package dates from RHEL lifecycle #1106
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
base: main
Are you sure you want to change the base?
Conversation
5ffcf35
to
afc5730
Compare
afc5730
to
7133cb6
Compare
Adds package streams info to package_sources. Pulls package stream info from the roadmap API and adds it to package sources if the RPM name matches. Also adds RHEL EoL as the end date for any package source that is not in the roadmap API. Uses the end date for the latest released version of the matching RHEL major version.
7133cb6
to
c49cc13
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds package stream and RHEL lifecycle information to package sources by integrating with the roadmap API. Key changes include:
- Retrieving and appending package stream details for RPMs via new roadmap API calls.
- Adding fallback logic to include RHEL lifecycle end dates if package stream data is not available.
- Updating tests, mocks, and cache interfaces to accommodate the new lifecycle functionality.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
pkg/dao/rpms_test.go | Added test cases for RHEL repo configurations and lifecycle info. |
pkg/dao/rpms.go | Updated search logic to add package sources and lifecycle info. |
pkg/clients/roadmap_client/roadmap_client_mock.go | Added mocks for lifecycle API calls. |
pkg/clients/roadmap_client/roadmap.go | Introduced lifecycle response types and functions. |
pkg/clients/roadmap_client/client.go | Updated client interface for new lifecycle methods. |
pkg/cache/redis.go | Added cache functions for RHEL lifecycle data. |
pkg/cache/noop.go | Added no-op implementations for RHEL lifecycle caching. |
pkg/cache/cache_mock.go | Added mocks for the new RHEL lifecycle cache functions. |
pkg/cache/cache.go | Extended cache interface to include lifecycle methods. |
} | ||
|
||
packageMap := make(map[string]int) | ||
for _, pkg := range res { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing pkg.Versions[0] without checking if the Versions slice is non-empty might lead to a runtime panic. Please add a check to ensure the slice is not empty before attempting conversion.
for _, pkg := range res { | |
for _, pkg := range res { | |
if len(pkg.Versions) == 0 { | |
continue // Skip if Versions slice is empty | |
} |
Copilot uses AI. Check for mistakes.
@@ -64,3 +64,12 @@ func (c *noOpCache) GetRoadmapAppstreams(ctx context.Context) ([]byte, error) { | |||
// SetRoadmapAppstreams a NoOp version to store cached roadmap appstreams check | |||
func (c *noOpCache) SetRoadmapAppstreams(ctx context.Context, response []byte) { | |||
} | |||
|
|||
// GetRoadmapAppstreams a NoOp version to fetch a cached roadmap rhel lifecycle check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment for GetRoadmapRhelLifecycle incorrectly refers to 'Appstreams' instead of 'RhelLifecycle'. Please update the comment to accurately describe its purpose.
// GetRoadmapAppstreams a NoOp version to fetch a cached roadmap rhel lifecycle check | |
// GetRoadmapRhelLifecycle a NoOp version to fetch a cached roadmap rhel lifecycle check |
Copilot uses AI. Check for mistakes.
return nil, NotFound | ||
} | ||
|
||
// SetRoadmapAppstreams a NoOp version to store cached roadmap rhel lifecycle check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment for SetRoadmapRhelLifecycle seems to be a copy of the Appstreams comment; please update it to correctly refer to storing the RHEL lifecycle information.
// SetRoadmapAppstreams a NoOp version to store cached roadmap rhel lifecycle check | |
// SetRoadmapRhelLifecycle a NoOp version to store cached roadmap RHEL lifecycle information |
Copilot uses AI. Check for mistakes.
db := r.db.Debug().WithContext(ctx). | ||
Select("DISTINCT ON(rpms.name) rpms.name as package_name", "rpms.summary", "rpms.uuid"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The use of db.Debug() may have been left unintentionally and can clutter production logs. Consider removing it or gating the debug logging for production use.
db := r.db.Debug().WithContext(ctx). | |
Select("DISTINCT ON(rpms.name) rpms.name as package_name", "rpms.summary", "rpms.uuid"). | |
db := r.db.WithContext(ctx) | |
if config.Get().Debug { // Enable debug logging if the debug flag is set | |
db = db.Debug() | |
} | |
db = db.Select("DISTINCT ON(rpms.name) rpms.name as package_name", "rpms.summary", "rpms.uuid"). |
Copilot uses AI. Check for mistakes.
if startDate.Before(currentDate) || startDate.Equal(currentDate) { | ||
if existing, found := rhelEolMap[item.Major]; !found || (item.Minor > existing.Minor) { | ||
rhelEolMap[item.Major] = item | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chatted privately, but we actually want to pick the earliest start date and latest end date for a given RHEL major release (9)
|
||
func (c *redisCache) SetRoadmapRhelLifecycle(ctx context.Context, response []byte) { | ||
key := roadmapRhelLifecycleKey(ctx) | ||
c.client.Set(ctx, key, string(response), config.Get().Clients.Redis.Expiration.SubscriptionCheck) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it probably makes sense to set this per service (for example subscription check should probably once an hour, but the roadmap expiration could be once per day). thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought subscription check is once a day, but I agree it should probably be separate. I'll fix that
Summary
Adds package streams info to package_sources. Pulls package stream info from the roadmap API and adds it to package sources if the RPM name matches.
Also adds RHEL EoL as the end date for any package source that is not in the roadmap API. Uses the end date for the latest released version of the matching RHEL major version.
Testing steps
To test package streams:
To test the rhel lifecycle info: