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 for flux plugin: clean up old charts from chart cache after repo update #4115 #5644

Merged
merged 17 commits into from
Nov 21, 2022

Conversation

gfichtenholt
Copy link
Contributor

@gfichtenholt gfichtenholt commented Nov 16, 2022

fix for long-standing issue #4115

plus DRYing up a bunch of existing test code

Not 100% sure who to ask for review. Its not urgent. If no-one materializes in the next few days, I will ask

The only thing of interest here is really a new func call

chartCache.PurgeObsoleteChartVersions(charts)

executed before an old call to

SyncCharts()

There is a new integration test I added for this scenario.
Most everything else is test code cleanup and doesn't need any review

@netlify
Copy link

netlify bot commented Nov 16, 2022

Deploy Preview for kubeapps-dev canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit a42ee29
🔍 Latest deploy log https://app.netlify.com/sites/kubeapps-dev/deploys/637ae6c3d2088a000a3fe6cc

@gfichtenholt
Copy link
Contributor Author

could one of you guys review this when you get a chance? Thanks

Copy link
Contributor

@absoludity absoludity left a comment

Choose a reason for hiding this comment

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

Thanks for adding the (very helpful) PR description Greg. I just looked at the PurgeObsoleteChartVersions function.

return c.deleteChartsHelper(repo, sets.String{})
}

func (c *ChartCache) PurgeObsoleteChartVersions(keepThese []models.Chart) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just reading the code below, I think keepThese is the slice of charts for which you're wanting to keep all versions? (as in, below, each chart is iterated with the redis key for each version added to the set of keys to keep for that repo, which is then passed as keep to deleteChartsHelper).

I must be missing something here, because it looks like it only ever calls deleteChartsHelper with repos of charts that were in the keepThese slice? I expected to find a function that purges all other repositories, other than the ones you wanted to keep (maybe it does and I'm just mis-reading).

EDIT: Oh - reading further down, I think I understand: this function is called when re-importing charts after an update to the repo, for example, so keepThese is actually populated from the new data, meaning that if the new data no longer includes a certain version, it'll get purged here. OK, I think I was confused initially because it wasn't clear to me that keepThese was the new data that hadn't been synced yet. (?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, you got it

repos := map[types.NamespacedName]sets.String{}
for _, ch := range keepThese {
if ch.Repo == nil {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Should that be an error if this function is called with a chart with a nil repo? Or at least, logging the issue? Wondering why we'd not want to report that somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

shouldn't ever happen, but you're right. Let me at least log it

@gfichtenholt
Copy link
Contributor Author

thank you for reviewing

@gfichtenholt gfichtenholt merged commit e5fe86f into vmware-tanzu:main Nov 21, 2022
@gfichtenholt gfichtenholt deleted the flux-incremental-3 branch November 21, 2022 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

flux plugin: clean up old charts from chart cache after repo update
4 participants